Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(dcs): chat with folder backend (#585)

Eric Hayes0ded7f73e64f
diff --git a/rust/cloud-storage/ai_tools/src/read.rs b/rust/cloud-storage/ai_tools/src/read.rs
index c97c0a52f1..da43ffd722 100644
--- a/rust/cloud-storage/ai_tools/src/read.rs
+++ b/rust/cloud-storage/ai_tools/src/read.rs
@@ -1,5 +1,6 @@
use crate::tool_context::{RequestContext, ToolServiceContext};
use ai::tool::{AsyncTool, ToolCallError, ToolResult};
+use anyhow::anyhow;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use model::chat::ChatHistory;
@@ -39,6 +40,9 @@ pub enum ReadContent {
subject: Option<String>,
messages: Vec<EmailMessage>,
},
+ ItemPreviews {
+ formatted_preview: String,
+ },
}
#[derive(Debug, JsonSchema, Serialize)]
@@ -126,6 +130,7 @@ pub enum ContentType {
ChatMessage,
EmailThread,
EmailMessage,
+ Project,
}
#[async_trait]
@@ -160,6 +165,7 @@ impl AsyncTool<ToolServiceContext, RequestContext> for Read {
ContentType::EmailMessage => {
self.read_email_message(&context, &request_context).await?
}
+ ContentType::Project => self.read_project(&context, &request_context).await?,
};
let tool_response = ReadResponse { content };
@@ -184,6 +190,31 @@ impl Read {
Ok(self.ids[0].clone())
}
+ async fn read_project(
+ &self,
+ context: &ToolServiceContext,
+ request_context: &RequestContext,
+ ) -> Result<ReadContent, ToolCallError> {
+ let id = self.ids.first().ok_or(ToolCallError {
+ description: "Expected a single id to read a project".into(),
+ internal_error: anyhow!("Bad tool args"),
+ })?;
+
+ context
+ .scribe
+ .document
+ .fetch_project(id.to_owned(), request_context.jwt_token.clone())
+ .content()
+ .await
+ .map_err(|err| ToolCallError {
+ description: "failed to fetch project".into(),
+ internal_error: err,
+ })
+ .map(|s| ReadContent::ItemPreviews {
+ formatted_preview: s.to_string(),
+ })
+ }
+
async fn read_document(
&self,
context: &ToolServiceContext,
diff --git a/rust/cloud-storage/document_cognition_service/schemas/tools.json b/rust/cloud-storage/document_cognition_service/schemas/tools.json
index 89def84e0b..6e002a8509 100644
--- a/rust/cloud-storage/document_cognition_service/schemas/tools.json
+++ b/rust/cloud-storage/document_cognition_service/schemas/tools.json
@@ -1,988 +1,1424 @@
{
"schemas": [
{
- "name": "WebSearch",
+ "name": "Read",
"inputSchema": {
"additionalProperties": false,
- "description": "Trigger an intelligent internet search tool with a search query. Phrase the query as a natural language question. The search tool only has the information passed into the query string to include any relevant context from the conversation. Use this tool when the user specifically requests a web search, asks for resources, asks for links, asks you to read documentationWhen referencing links returned by search remember to use github markdown notation to format them like this [description](https://example.com)Our CEO describes when to use web search like this: I think some important criteria for choosing to search the web are\",\n if the user is asking for time-sensitive information (sports scores, news, current happenings, etc) that would have changed since the knowledge cutoff date\n Specific questions that reference external sources, eg contain a hyperlink in the user message or explicitly say “use webmd” or “check arxiv”\n do not use web search for things that are likely to find SEO slop content; this will make it worse than if it didn’t do it\n the LLM is be allowed to guess an answer and then use the web search tool to check AFTER providing the answer, if it feels it’s necessary. E.g. user asks “when was Caesar stabbed” -> llm gives answer -> if needed use web to double check\"\n do not use this tool many times in a single response, you think the user may need more information ask them before calling web search again. You should always sharethe results of your search with the user even if you are not sure if they are useful",
+ "description": "Read content by ID(s). Supports reading documents, channels, chats, and emails by their respective IDs. Use this tool when you need to retrieve the full content of a specific item(s).\n Channel transcripts only include 300 messages. Use 'messages_since' to see messages in a different time window.",
"properties": {
- "query": {
+ "contentType": {
"additionalProperties": false,
- "description": "The search string to search for. Should be long / descriptive",
- "type": "string"
- }
- },
- "required": [
- "query"
- ],
- "title": "WebSearch",
- "type": "object"
- },
- "outputSchema": {
- "properties": {
- "content": {
+ "description": "The type of content to read. Choose based on the type of content you want to retrieve.",
+ "enum": [
+ "document",
+ "channel",
+ "channel-message",
+ "chat-thread",
+ "chat-message",
+ "email-thread",
+ "email-message",
+ "project"
+ ],
"type": "string"
},
- "results": {
- "items": {
- "properties": {
- "name": {
- "type": "string"
- },
- "url": {
- "type": "string"
- }
- },
- "required": [
- "url",
- "name"
- ],
- "type": "object"
- },
- "type": "array"
- }
- },
- "required": [
- "content",
- "results"
- ],
- "title": "SearchResults",
- "type": "object"
- }
- },
- {
- "name": "ListDocuments",
- "inputSchema": {
- "additionalProperties": false,
- "description": "List documents the user has access to with optional filtering and pagination. Only applies to documents, not emails, AI conversations, chat/slack threads, projects aka folders. This tool returns document metadata including access levels and supports filtering by file type, minimum access level, and pagination. Use this tool to discover and browse documents before using the Read tool to access their content. Prefer using the search tool to search on a specific matching string within the content or the name of the entity.",
- "properties": {
- "exhaustiveSearch": {
- "additionalProperties": false,
- "default": false,
- "description": "Exhaustive search to get all results. Defaults to false. Set to true when you need all matching documents, ignoring pagination limits.",
- "type": "boolean"
- },
- "fileTypes": {
+ "ids": {
"additionalProperties": false,
- "description": "Document file types to include. Examples: ['pdf'], ['md', 'txt']. Leave empty to include all document types.",
+ "description": "ID(s) of the content to read. IMPORTANT: document, channel-message, chat-message, and email-message content types support MULTIPLE ids! For all other content types (channel, chat-thread, email-thread) provide a single id.",
"items": {
"additionalProperties": false,
"type": "string"
},
- "type": [
- "array",
- "null"
- ]
+ "type": "array"
},
- "minAccessLevel": {
+ "messagesSince": {
"additionalProperties": false,
- "description": "Minimum access level required. Defaults to 'view' if not specified.",
- "enum": [
- "view",
- "comment",
- "edit",
- "owner",
- null
- ],
+ "description": "A local datetime of the earliest message to include in a channel transcript ex: 2025-11-25 12:00:09 EST, only applicable to channels",
+ "format": "date-time",
"type": [
"string",
"null"
]
- },
- "pageOffset": {
- "additionalProperties": false,
- "default": 0,
- "description": "Page offset for pagination. Default is 0. Use higher values to get subsequent pages of results.",
- "format": "int64",
- "type": "integer"
- },
- "pageSize": {
- "additionalProperties": false,
- "default": 50,
- "description": "Number of results per page. Max is 100, default is 50. Use smaller values for focused results.",
- "format": "int64",
- "type": "integer"
}
},
"required": [
- "exhaustiveSearch",
- "fileTypes",
- "minAccessLevel",
- "pageOffset",
- "pageSize"
+ "contentType",
+ "ids",
+ "messagesSince"
],
- "title": "ListDocuments",
+ "title": "Read",
"type": "object"
},
"outputSchema": {
"properties": {
- "results": {
- "description": "The list results (truncated to `results_returned` limit if applicable)",
- "items": {
- "properties": {
- "access_level": {
- "description": "The user's access level to this document",
- "enum": [
- "view",
- "comment",
- "edit",
- "owner"
- ],
- "type": "string"
- },
- "created_at": {
- "description": "When the document was created",
- "format": "date-time",
- "type": "string"
- },
- "deleted_at": {
- "description": "When the document was deleted (null if not deleted)",
- "format": "date-time",
- "type": [
- "string",
- "null"
- ]
- },
- "document_id": {
- "description": "The document id",
- "type": "string"
- },
- "document_name": {
- "description": "The document name",
- "type": "string"
- },
- "file_type": {
- "description": "The file type of the document",
- "type": [
- "string",
- "null"
- ]
- },
- "owner": {
- "description": "The owner of the document",
- "type": "string"
+ "content": {
+ "oneOf": [
+ {
+ "properties": {
+ "documents": {
+ "items": {
+ "properties": {
+ "content": {
+ "type": "string"
+ },
+ "documentId": {
+ "type": "string"
+ },
+ "metadata": {
+ "properties": {
+ "deleted": {
+ "type": "boolean"
+ },
+ "documentName": {
+ "type": "string"
+ },
+ "fileType": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "owner": {
+ "type": "string"
+ },
+ "projectId": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "documentName",
+ "owner",
+ "deleted"
+ ],
+ "type": "object"
+ }
+ },
+ "required": [
+ "documentId",
+ "content",
+ "metadata"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "type": {
+ "const": "documents",
+ "type": "string"
+ }
},
- "project_id": {
- "description": "The project id containing the document",
- "type": [
- "string",
- "null"
- ]
+ "required": [
+ "type",
+ "documents"
+ ],
+ "type": "object"
+ },
+ {
+ "properties": {
+ "channel_id": {
+ "type": "string"
+ },
+ "channel_name": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "transcript": {
+ "type": "string"
+ },
+ "type": {
+ "const": "channel",
+ "type": "string"
+ }
},
- "updated_at": {
- "description": "When the document was last updated",
- "format": "date-time",
- "type": "string"
- }
+ "required": [
+ "type",
+ "channel_id",
+ "transcript"
+ ],
+ "type": "object"
},
- "required": [
- "document_id",
- "document_name",
- "owner",
- "created_at",
- "updated_at",
- "access_level"
- ],
- "type": "object"
- },
- "type": "array"
- },
- "resultsReturned": {
- "description": "The number of results returned",
- "format": "uint",
- "minimum": 0,
- "type": "integer"
- },
- "totalResults": {
- "description": "Total number of results found",
- "format": "uint",
- "minimum": 0,
- "type": "integer"
+ {
+ "properties": {
+ "conversation": {
+ "items": {
+ "properties": {
+ "chat_id": {
+ "type": "string"
+ },
+ "messages": {
+ "items": {
+ "properties": {
+ "attachment_summaries": {
+ "items": {
+ "oneOf": [
+ {
+ "additionalProperties": false,
+ "properties": {
+ "Summary": {
+ "properties": {
+ "created_at": {
+ "format": "date-time",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "document_id": {
+ "type": "string"
+ },
+ "id": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "summary": {
+ "type": "string"
+ },
+ "version_id": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "document_id",
+ "summary",
+ "version_id"
+ ],
+ "type": "object"
+ }
+ },
+ "required": [
+ "Summary"
+ ],
+ "type": "object"
+ },
+ {
+ "additionalProperties": false,
+ "properties": {
+ "NoSummary": {
+ "properties": {
+ "document_id": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "document_id"
+ ],
+ "type": "object"
+ }
+ },
+ "required": [
+ "NoSummary"
+ ],
+ "type": "object"
+ }
+ ]
+ },
+ "type": "array"
+ },
+ "content": {
+ "type": "string"
+ },
+ "date": {
+ "format": "date-time",
+ "type": "string"
+ }
+ },
+ "required": [
+ "content",
+ "date",
+ "attachment_summaries"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "title": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "chat_id",
+ "title",
+ "messages"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "type": {
+ "const": "chat",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "conversation"
+ ],
+ "type": "object"
+ },
+ {
+ "properties": {
+ "messages": {
+ "items": {
+ "properties": {
+ "bcc": {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "cc": {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "content": {
+ "type": "string"
+ },
+ "messageId": {
+ "type": "string"
+ },
+ "recipients": {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "sender": {
+ "type": "string"
+ },
+ "sentAt": {
+ "format": "date-time",
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "messageId",
+ "sender",
+ "recipients",
+ "cc",
+ "bcc",
+ "content"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "subject": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "thread_id": {
+ "type": "string"
+ },
+ "type": {
+ "const": "email",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "thread_id",
+ "messages"
+ ],
+ "type": "object"
+ },
+ {
+ "properties": {
+ "formatted_preview": {
+ "type": "string"
+ },
+ "type": {
+ "const": "itemPreviews",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "formatted_preview"
+ ],
+ "type": "object"
+ }
+ ]
}
},
"required": [
- "results",
- "totalResults",
- "resultsReturned"
+ "content"
],
- "title": "ListDocumentsResponse",
+ "title": "ReadResponse",
"type": "object"
}
},
{
- "name": "ListEmails",
+ "name": "MarkdownRewrite",
"inputSchema": {
"additionalProperties": false,
- "description": "List the emails the user has access to. Use this tool to discover and browse emails before using the Read tool to access their content. Prefer using the search tool to search on a specific matching string within the content or the name of the entity.",
+ "description": "Instruct an agent to edit a markdown file identified by an id.\n This tool should be used when the user include a markdown file in context and requests a revision or edit to that file",
"properties": {
- "cursor": {
+ "instructions": {
"additionalProperties": false,
- "default": null,
- "description": "A preview response will tell you what the next cursor id is.\n If expected emails are not in the current response and it gives you a cursor id, use this field to list the next page of emails. If no cursor id is provided you've reached the end",
- "type": [
- "string",
- "null"
- ]
+ "description": "Instructions for the revision agent to follow to edit the markdown. These instructions will be provided by the user.",
+ "type": "string"
},
- "limit": {
+ "markdown_file_id": {
"additionalProperties": false,
- "default": 20,
- "description": "limit the max emails returned. This defaults to 20 and has a maximum of 500",
- "format": "int64",
- "type": "integer"
- },
- "sortMethod": {
- "additionalProperties": false,
- "default": "viewed_at",
- "description": "Sort response by one of: viewed_at | updated_at | created_at | viewed_updated. Prefer viewed_at unless the otherwise specified",
- "enum": [
- "viewed_at",
- "updated_at",
- "created_at",
- "viewed_updated"
- ],
+ "description": "The markdown file id to target for editing. This file id will be in your context and labeled as a markdown (md) document",
"type": "string"
- },
- "view": {
- "additionalProperties": false,
- "default": {
- "standardLabel": null,
- "userLabel": null
- },
- "description": "Choose the view to list emails from. One of either standard label or user label must be specified, otherwise defaults to important.",
- "properties": {
- "standardLabel": {
- "additionalProperties": false,
- "description": "Prefer important or all. Leave empty if using a user label",
- "enum": [
- "Inbox",
- "Sent",
- "Drafts",
- "Starred",
- "All",
- "Important",
- "Other",
- null
- ],
- "type": [
- "string",
- "null"
- ]
- },
- "userLabel": {
- "additionalProperties": false,
- "description": "Choose a custom user label to filter by (optional). Standard label will take precedence over user label if both are specified.",
- "type": [
- "string",
- "null"
- ]
- }
- },
- "required": [
- "standardLabel",
- "userLabel"
- ],
- "type": "object"
}
},
"required": [
- "cursor",
- "limit",
- "sortMethod",
- "view"
+ "instructions",
+ "markdown_file_id"
],
- "title": "ListEmails",
+ "title": "MarkdownRewrite",
"type": "object"
},
"outputSchema": {
+ "additionalProperties": false,
"properties": {
- "items": {
+ "diffs": {
"items": {
+ "additionalProperties": false,
"properties": {
- "attachments": {
- "items": {
+ "markdown_text": {
+ "type": "string"
+ },
+ "node_key": {
+ "type": "string"
+ },
+ "operation": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "operation",
+ "node_key",
+ "markdown_text"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ }
+ },
+ "required": [
+ "diffs"
+ ],
+ "title": "AIDiffResponse",
+ "type": "object"
+ }
+ },
+ {
+ "name": "UnifiedSearch",
+ "inputSchema": {
+ "additionalProperties": false,
+ "description": "Universal search across all content types (documents, emails, AI conversations, chat/slack threads/channels, projects aka folders). This tool will return broad metadata from successful results and/or content matches. Use the Read tool next to read the results from those matches. Only ever refer to documents by name or with a document mention. Never state the id of the document in plaintext. User's are presented with the results of this tool as a UI element so there is no need to enumerate the information found from this tool.",
+ "properties": {
+ "exhaustiveSearch": {
+ "additionalProperties": false,
+ "default": true,
+ "description": "Exhaustive search across all results matching the query. Defaults to true. Use false when the user only requires a limitied subset of results to answer the question",
+ "type": "boolean"
+ },
+ "pageOffset": {
+ "additionalProperties": false,
+ "default": 0,
+ "description": "Page offset. Default is 0. Use a higher offset to page through results intelligently. Set exhaustive_search to true to get all results.",
+ "format": "int64",
+ "type": "integer"
+ },
+ "pageSize": {
+ "additionalProperties": false,
+ "default": 10,
+ "description": "Search count per search type (i.e. applies separately to each of documents, emails, ai_conversations, chats, projects). Max is 100. Default is 10. Does not apply when exhaustive_search is set to true.",
+ "format": "int64",
+ "type": "integer"
+ },
+ "request": {
+ "additionalProperties": false,
+ "description": "Aggregated search request, see individual fields for details",
+ "properties": {
+ "filters": {
+ "additionalProperties": false,
+ "description": "Search filters for various kinds of items. Set the entire filters property as `null` if you do not have specific filters for a given type, e.g. bcc for email filters.",
+ "properties": {
+ "channel": {
+ "additionalProperties": false,
+ "description": "Channel filters. `null` to not filter channels searched over.",
"properties": {
- "contentId": {
- "type": [
- "string",
- "null"
- ]
- },
- "createdAt": {
- "format": "int64",
- "type": "integer"
- },
- "filename": {
- "type": [
- "string",
- "null"
- ]
- },
- "id": {
- "format": "uuid",
- "type": "string"
- },
- "messageId": {
- "format": "uuid",
- "type": "string"
- },
- "mimeType": {
- "type": [
- "string",
- "null"
- ]
+ "channel_ids": {
+ "additionalProperties": false,
+ "description": "Channel IDs to search within. Examples: ['general']. Empty to search all accessible channels.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
},
- "providerAttachmentId": {
- "type": [
- "string",
- "null"
- ]
+ "mentions": {
+ "additionalProperties": false,
+ "description": "Channel user mentions to search for. Examples: ['@username']. Empty if not filtering by mentions.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
},
- "sizeBytes": {
+ "org_id": {
+ "additionalProperties": false,
+ "description": "Channel organization ID to search within. Empty to ignore organization filtering.",
"format": "int64",
"type": [
"integer",
"null"
]
+ },
+ "sender_ids": {
+ "additionalProperties": false,
+ "description": "Sender IDs to search within. Examples: ['user1']. Empty to search all accessible senders.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "thread_ids": {
+ "additionalProperties": false,
+ "description": "Channel thread IDs to search within. Examples: ['thread123']. Empty to search all threads.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
}
},
"required": [
- "id",
- "messageId",
- "createdAt"
+ "channel_ids",
+ "mentions",
+ "org_id",
+ "sender_ids",
+ "thread_ids"
],
- "type": "object"
+ "type": [
+ "object",
+ "null"
+ ]
},
- "type": "array"
- },
- "contacts": {
- "items": {
+ "chat": {
+ "additionalProperties": false,
+ "description": "Chat filters. `null` to not filter chats searched over.",
"properties": {
- "emailAddress": {
- "type": [
- "string",
- "null"
- ]
- },
- "id": {
- "format": "uuid",
- "type": "string"
+ "chat_ids": {
+ "additionalProperties": false,
+ "description": "Chat ids to search over. Examples: ['chat1'], ['chat1', 'chat2']. When provided, chat search will only match results on these chats. Empty to search all accessible chats.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
},
- "linkId": {
- "format": "uuid",
- "type": "string"
+ "owners": {
+ "additionalProperties": false,
+ "description": "Filter by chat owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
},
- "name": {
- "type": [
- "string",
- "null"
- ]
+ "project_ids": {
+ "additionalProperties": false,
+ "description": "A list of project ids to search within. Examples: ['project1']. Empty to ignore project filtering.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
},
- "sfsPhotoUrl": {
- "type": [
- "string",
- "null"
- ]
+ "role": {
+ "additionalProperties": false,
+ "description": "Chat message roles to search. Examples: ['user'], ['assistant']. Empty to search all roles.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
}
},
"required": [
- "id",
- "linkId"
+ "chat_ids",
+ "owners",
+ "project_ids",
+ "role"
],
- "type": "object"
+ "type": [
+ "object",
+ "null"
+ ]
},
- "type": "array"
- },
- "createdAt": {
- "format": "int64",
- "type": "integer"
- },
- "frecencyScore": {
- "format": "double",
- "type": [
- "number",
- "null"
- ]
- },
- "id": {
- "format": "uuid",
- "type": "string"
- },
- "inboxVisible": {
- "type": "boolean"
- },
- "isDraft": {
- "type": "boolean"
- },
- "isImportant": {
- "type": "boolean"
- },
- "isRead": {
- "type": "boolean"
- },
- "labels": {
- "items": {
+ "document": {
+ "additionalProperties": false,
+ "description": "Document filters. `null` to not filter documents searched over.",
"properties": {
- "createdAt": {
- "format": "date-time",
- "type": "string"
- },
- "id": {
- "format": "uuid",
- "type": "string"
- },
- "labelListVisibility": {
- "enum": [
- "LabelShow",
- "LabelShowIfUnread",
- "LabelHide"
- ],
- "type": "string"
- },
- "linkId": {
- "format": "uuid",
- "type": "string"
- },
- "messageListVisibility": {
- "enum": [
- "Show",
- "Hide"
- ],
- "type": "string"
+ "document_ids": {
+ "additionalProperties": false,
+ "description": "Document ids to search over. Examples: ['doc1'], ['doc1', 'doc2']. Empty to search all accessible documents.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
},
- "name": {
- "type": "string"
+ "file_types": {
+ "additionalProperties": false,
+ "description": "Document file types to search. Examples: ['pdf'], ['md', 'txt']. Empty to search all file types.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
},
- "providerLabelId": {
- "type": "string"
+ "owners": {
+ "additionalProperties": false,
+ "description": "Filter by document owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
},
- "type": {
- "enum": [
- "System",
- "User"
- ],
- "type": "string"
+ "project_ids": {
+ "additionalProperties": false,
+ "description": "A list of project ids to search within. Examples: ['project1'].\nfiltering. Empty to ignore project filtering.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
}
},
"required": [
- "id",
- "linkId",
- "providerLabelId",
- "name",
- "createdAt",
- "messageListVisibility",
- "labelListVisibility",
- "type"
+ "document_ids",
+ "file_types",
+ "owners",
+ "project_ids"
],
- "type": "object"
+ "type": [
+ "object",
+ "null"
+ ]
},
- "type": "array"
- },
- "macroAttachments": {
- "items": {
+ "email": {
+ "additionalProperties": false,
+ "description": "Email filters. `null` to not filter emails searched over.",
"properties": {
- "dbId": {
- "format": "uuid",
- "type": "string"
+ "bcc": {
+ "additionalProperties": false,
+ "description": "Email BCC addresses to filter by. Examples: ['[email protected]']. Empty if not filtering by BCC.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
},
- "itemId": {
- "format": "uuid",
- "type": "string"
+ "cc": {
+ "additionalProperties": false,
+ "description": "Email CC addresses to filter by. Examples: ['[email protected]']. Empty if not filtering by CC.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
},
- "itemType": {
- "type": "string"
+ "recipients": {
+ "additionalProperties": false,
+ "description": "Email Recipient addresses to filter by. Examples: ['[email protected]']. Empty if not filtering by Recipient.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
},
- "messageId": {
- "format": "uuid",
- "type": "string"
+ "senders": {
+ "additionalProperties": false,
+ "description": "Email sender addresses to filter by. Examples: ['[email protected]']. Empty to search all senders.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
}
},
"required": [
- "dbId",
- "messageId",
- "itemId",
- "itemType"
+ "bcc",
+ "cc",
+ "recipients",
+ "senders"
],
- "type": "object"
+ "type": [
+ "object",
+ "null"
+ ]
},
- "type": "array"
- },
- "name": {
- "type": [
- "string",
- "null"
- ]
- },
- "ownerId": {
- "type": "string"
+ "project": {
+ "additionalProperties": false,
+ "description": "Project filters. `null` to not filter projects searched over.",
+ "properties": {
+ "owners": {
+ "additionalProperties": false,
+ "description": "Filter by project owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "project_ids": {
+ "additionalProperties": false,
+ "description": "Project IDs to search within. Examples: ['project1']. Empty to search all accessible projects.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": "array"
+ }
+ },
+ "required": [
+ "owners",
+ "project_ids"
+ ],
+ "type": [
+ "object",
+ "null"
+ ]
+ }
},
- "providerId": {
- "type": [
- "string",
- "null"
- ]
- },
- "senderEmail": {
- "type": [
- "string",
- "null"
- ]
- },
- "senderName": {
- "type": [
- "string",
- "null"
- ]
- },
- "senderPhotoUrl": {
- "type": [
- "string",
- "null"
- ]
- },
- "snippet": {
- "type": [
- "string",
- "null"
- ]
- },
- "sortTs": {
- "format": "int64",
- "type": "integer"
- },
- "updatedAt": {
- "format": "int64",
- "type": "integer"
+ "required": [
+ "channel",
+ "chat",
+ "document",
+ "email",
+ "project"
+ ],
+ "type": [
+ "object",
+ "null"
+ ]
+ },
+ "include": {
+ "additionalProperties": false,
+ "default": [],
+ "description": "Include specific entity types from search. If empty, all entity types will be searched over. If you are unsure which types to search, use an empty array to search all.",
+ "items": {
+ "additionalProperties": false,
+ "enum": [
+ "documents",
+ "chats",
+ "emails",
+ "channels",
+ "projects"
+ ],
+ "type": "string"
},
- "viewedAt": {
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
- }
+ "type": "array"
},
- "required": [
- "id",
- "ownerId",
- "inboxVisible",
- "isRead",
- "isDraft",
- "isImportant",
- "sortTs",
- "createdAt",
- "updatedAt",
- "attachments",
- "macroAttachments",
- "contacts",
- "labels"
- ],
- "type": "object"
+ "match_type": {
+ "additionalProperties": false,
+ "description": "How to match the search terms. 'exact' for precise case-sensitive phrase matches, 'partial' for prefix/partial matches. REQUIRED field.",
+ "enum": [
+ "exact",
+ "partial",
+ "regexp"
+ ],
+ "type": "string"
+ },
+ "search_on": {
+ "additionalProperties": false,
+ "default": "content",
+ "description": "Fields to search on (Name, Content, NameContent). Defaults to Content",
+ "enum": [
+ "name",
+ "content",
+ "name_content"
+ ],
+ "type": "string"
+ },
+ "terms": {
+ "additionalProperties": false,
+ "description": "Multiple distinct search terms as separate strings. Use this for keyword-based searches where you want to find content containing any of these terms. Each term must be at least 3 characters (shorter terms are automatically filtered out). Examples: ['machine', 'learning', 'algorithms'], ['project', 'status', 'update']. `null` this field if searching without text terms to search all. This field matches query string against both name and content.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": [
+ "array",
+ "null"
+ ]
+ }
},
- "type": "array"
- },
- "next_cursor": {
- "type": [
- "string",
- "null"
- ]
- }
- },
- "required": [
- "items"
- ],
- "title": "ApiPaginatedThreadCursor",
- "type": "object"
- }
- },
- {
- "name": "Read",
- "inputSchema": {
- "additionalProperties": false,
- "description": "Read content by ID(s). Supports reading documents, channels, chats, and emails by their respective IDs. Use this tool when you need to retrieve the full content of a specific item(s).\n Channel transcripts only include 300 messages. Use 'messages_since' to see messages in a different time window.",
- "properties": {
- "contentType": {
- "additionalProperties": false,
- "description": "The type of content to read. Choose based on the type of content you want to retrieve.",
- "enum": [
- "document",
- "channel",
- "channel-message",
- "chat-thread",
- "chat-message",
- "email-thread",
- "email-message"
+ "required": [
+ "filters",
+ "include",
+ "match_type",
+ "search_on",
+ "terms"
],
- "type": "string"
- },
- "ids": {
- "additionalProperties": false,
- "description": "ID(s) of the content to read. IMPORTANT: document, channel-message, chat-message, and email-message content types support MULTIPLE ids! For all other content types (channel, chat-thread, email-thread) provide a single id.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
- },
- "messagesSince": {
- "additionalProperties": false,
- "description": "A local datetime of the earliest message to include in a channel transcript ex: 2025-11-25 12:00:09 EST, only applicable to channels",
- "format": "date-time",
- "type": [
- "string",
- "null"
- ]
+ "type": "object"
}
},
"required": [
- "contentType",
- "ids",
- "messagesSince"
+ "exhaustiveSearch",
+ "pageOffset",
+ "pageSize",
+ "request"
],
- "title": "Read",
+ "title": "UnifiedSearch",
"type": "object"
},
"outputSchema": {
"properties": {
- "content": {
- "oneOf": [
- {
- "properties": {
- "documents": {
- "items": {
+ "response": {
+ "description": "The search results",
+ "properties": {
+ "results": {
+ "description": "The search results (truncated to `results_returned` limit if applicable)",
+ "items": {
+ "oneOf": [
+ {
"properties": {
- "content": {
+ "document_id": {
+ "description": "The document id",
"type": "string"
},
- "documentId": {
+ "document_name": {
+ "description": "The document name",
"type": "string"
},
- "metadata": {
+ "file_type": {
+ "description": "The file type",
+ "type": "string"
+ },
+ "highlight": {
+ "description": "The highlights on the document",
"properties": {
- "deleted": {
- "type": "boolean"
- },
- "documentName": {
- "type": "string"
- },
- "fileType": {
- "type": [
- "string",
- "null"
- ]
- },
- "owner": {
- "type": "string"
+ "content": {
+ "description": "The highlight match on the content field",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
},
- "projectId": {
+ "name": {
+ "description": "The highlight match on the name field",
"type": [
"string",
"null"
]
}
},
- "required": [
- "documentName",
- "owner",
- "deleted"
- ],
"type": "object"
- }
- },
- "required": [
- "documentId",
- "content",
- "metadata"
- ],
- "type": "object"
- },
- "type": "array"
- },
- "type": {
- "const": "documents",
- "type": "string"
- }
- },
- "required": [
- "type",
- "documents"
- ],
- "type": "object"
- },
- {
- "properties": {
- "channel_id": {
- "type": "string"
- },
- "channel_name": {
- "type": [
- "string",
- "null"
- ]
- },
- "transcript": {
- "type": "string"
- },
- "type": {
- "const": "channel",
- "type": "string"
- }
- },
- "required": [
- "type",
- "channel_id",
- "transcript"
- ],
- "type": "object"
- },
- {
- "properties": {
- "conversation": {
- "items": {
+ },
+ "node_id": {
+ "description": "The node id",
+ "type": "string"
+ },
+ "owner_id": {
+ "description": "The owner id",
+ "type": "string"
+ },
+ "raw_content": {
+ "description": "The raw content of the document",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "type": {
+ "const": "document",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "The time the document was last updated",
+ "format": "date-time",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "document_id",
+ "document_name",
+ "node_id",
+ "owner_id",
+ "file_type",
+ "updated_at",
+ "highlight"
+ ],
+ "type": "object"
+ },
+ {
"properties": {
"chat_id": {
+ "description": "The chat id",
"type": "string"
},
- "messages": {
- "items": {
- "properties": {
- "attachment_summaries": {
- "items": {
- "oneOf": [
- {
- "additionalProperties": false,
- "properties": {
- "Summary": {
- "properties": {
- "created_at": {
- "format": "date-time",
- "type": [
- "string",
- "null"
- ]
- },
- "document_id": {
- "type": "string"
- },
- "id": {
- "type": [
- "string",
- "null"
- ]
- },
- "summary": {
- "type": "string"
- },
- "version_id": {
- "type": "string"
- }
- },
- "required": [
- "document_id",
- "summary",
- "version_id"
- ],
- "type": "object"
- }
- },
- "required": [
- "Summary"
- ],
- "type": "object"
- },
- {
- "additionalProperties": false,
- "properties": {
- "NoSummary": {
- "properties": {
- "document_id": {
- "type": "string"
- }
- },
- "required": [
- "document_id"
- ],
- "type": "object"
- }
- },
- "required": [
- "NoSummary"
- ],
- "type": "object"
- }
- ]
- },
- "type": "array"
- },
- "content": {
+ "chat_message_id": {
+ "description": "The chat message id",
+ "type": "string"
+ },
+ "highlight": {
+ "description": "The highlights on the chat",
+ "properties": {
+ "content": {
+ "description": "The highlight match on the content field",
+ "items": {
"type": "string"
},
- "date": {
- "format": "date-time",
- "type": "string"
- }
+ "type": "array"
},
- "required": [
- "content",
- "date",
- "attachment_summaries"
- ],
- "type": "object"
+ "name": {
+ "description": "The highlight match on the name field",
+ "type": [
+ "string",
+ "null"
+ ]
+ }
},
- "type": "array"
+ "type": "object"
+ },
+ "role": {
+ "description": "The role",
+ "type": "string"
},
"title": {
+ "description": "The title",
+ "type": "string"
+ },
+ "type": {
+ "const": "chat",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "The time the chat was last updated",
+ "format": "date-time",
+ "type": "string"
+ },
+ "user_id": {
+ "description": "The user id",
"type": "string"
}
},
"required": [
+ "type",
"chat_id",
+ "chat_message_id",
+ "user_id",
+ "role",
+ "updated_at",
"title",
- "messages"
+ "highlight"
],
"type": "object"
},
- "type": "array"
- },
- "type": {
- "const": "chat",
- "type": "string"
- }
- },
- "required": [
- "type",
- "conversation"
- ],
- "type": "object"
- },
- {
- "properties": {
- "messages": {
- "items": {
+ {
"properties": {
"bcc": {
+ "description": "The bcc",
"items": {
"type": "string"
},
"type": "array"
},
"cc": {
+ "description": "The cc",
"items": {
"type": "string"
},
"type": "array"
},
- "content": {
- "type": "string"
- },
- "messageId": {
- "type": "string"
+ "highlight": {
+ "description": "The highlights on the email",
+ "properties": {
+ "content": {
+ "description": "The highlight match on the content field",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "name": {
+ "description": "The highlight match on the name field",
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
},
- "recipients": {
+ "labels": {
+ "description": "The labels",
"items": {
"type": "string"
},
"type": "array"
},
- "sender": {
+ "link_id": {
+ "description": "The link id",
"type": "string"
},
- "sentAt": {
- "format": "date-time",
+ "message_id": {
+ "description": "The message id",
+ "type": "string"
+ },
+ "recipients": {
+ "description": "The recipients",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "sender": {
+ "description": "The sender",
+ "type": "string"
+ },
+ "sent_at": {
+ "description": "The time the email was sent",
+ "format": "date-time",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "subject": {
+ "description": "The subject",
"type": [
"string",
"null"
]
+ },
+ "thread_id": {
+ "description": "The thread id",
+ "type": "string"
+ },
+ "type": {
+ "const": "email",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "The time the email was last updated",
+ "format": "date-time",
+ "type": "string"
+ },
+ "user_id": {
+ "description": "The user id",
+ "type": "string"
}
},
"required": [
- "messageId",
+ "type",
+ "thread_id",
+ "message_id",
"sender",
"recipients",
"cc",
"bcc",
- "content"
+ "labels",
+ "link_id",
+ "user_id",
+ "updated_at",
+ "highlight"
],
"type": "object"
},
- "type": "array"
- },
- "subject": {
- "type": [
- "string",
- "null"
- ]
- },
- "thread_id": {
- "type": "string"
- },
- "type": {
- "const": "email",
- "type": "string"
- }
+ {
+ "properties": {
+ "channel_id": {
+ "description": "The channel id",
+ "type": "string"
+ },
+ "channel_type": {
+ "description": "The channel type",
+ "type": "string"
+ },
+ "created_at": {
+ "description": "The time the channel message was created",
+ "format": "date-time",
+ "type": "string"
+ },
+ "highlight": {
+ "description": "The highlights on the channel message",
+ "properties": {
+ "content": {
+ "description": "The highlight match on the content field",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "name": {
+ "description": "The highlight match on the name field",
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "mentions": {
+ "description": "The mentions",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "message_id": {
+ "description": "The message id",
+ "type": "string"
+ },
+ "org_id": {
+ "description": "The org id",
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "sender_id": {
+ "description": "The sender id",
+ "type": "string"
+ },
+ "thread_id": {
+ "description": "The thread id",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "type": {
+ "const": "channel",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "The time the channel message was last updated",
+ "format": "date-time",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "channel_id",
+ "channel_type",
+ "message_id",
+ "sender_id",
+ "mentions",
+ "created_at",
+ "updated_at",
+ "highlight"
+ ],
+ "type": "object"
+ },
+ {
+ "properties": {
+ "created_at": {
+ "description": "The time the project was created",
+ "format": "date-time",
+ "type": "string"
+ },
+ "highlight": {
+ "description": "The highlights on the project",
+ "properties": {
+ "content": {
+ "description": "The highlight match on the content field",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "name": {
+ "description": "The highlight match on the name field",
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "project_id": {
+ "description": "The project id",
+ "type": "string"
+ },
+ "project_name": {
+ "description": "The project name",
+ "type": "string"
+ },
+ "type": {
+ "const": "project",
+ "type": "string"
+ },
+ "updated_at": {
+ "description": "The time the project was last updated",
+ "format": "date-time",
+ "type": "string"
+ },
+ "user_id": {
+ "description": "The id of the user who created the project",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "project_id",
+ "updated_at",
+ "created_at",
+ "project_name",
+ "user_id",
+ "highlight"
+ ],
+ "type": "object"
+ }
+ ]
},
- "required": [
- "type",
- "thread_id",
- "messages"
- ],
- "type": "object"
+ "type": "array"
+ },
+ "resultsReturned": {
+ "description": "the number of results returned",
+ "format": "uint",
+ "minimum": 0,
+ "type": "integer"
+ },
+ "totalResults": {
+ "description": "total number of results from search",
+ "format": "uint",
+ "minimum": 0,
+ "type": "integer"
}
- ]
+ },
+ "required": [
+ "results",
+ "totalResults",
+ "resultsReturned"
+ ],
+ "type": "object"
+ },
+ "responseSchema": {
+ "description": "The JSON schema for the response so the LLM can understand it"
}
},
"required": [
- "content"
+ "response",
+ "responseSchema"
],
- "title": "ReadResponse",
+ "title": "UnifiedSearchResponseOutput",
"type": "object"
}
},
{
- "name": "MarkdownRewrite",
+ "name": "ListDocuments",
"inputSchema": {
"additionalProperties": false,
- "description": "Instruct an agent to edit a markdown file identified by an id.\n This tool should be used when the user include a markdown file in context and requests a revision or edit to that file",
+ "description": "List documents the user has access to with optional filtering and pagination. Only applies to documents, not emails, AI conversations, chat/slack threads, projects aka folders. This tool returns document metadata including access levels and supports filtering by file type, minimum access level, and pagination. Use this tool to discover and browse documents before using the Read tool to access their content. Prefer using the search tool to search on a specific matching string within the content or the name of the entity.",
"properties": {
- "instructions": {
+ "exhaustiveSearch": {
"additionalProperties": false,
- "description": "Instructions for the revision agent to follow to edit the markdown. These instructions will be provided by the user.",
- "type": "string"
+ "default": false,
+ "description": "Exhaustive search to get all results. Defaults to false. Set to true when you need all matching documents, ignoring pagination limits.",
+ "type": "boolean"
},
- "markdown_file_id": {
+ "fileTypes": {
"additionalProperties": false,
- "description": "The markdown file id to target for editing. This file id will be in your context and labeled as a markdown (md) document",
- "type": "string"
+ "description": "Document file types to include. Examples: ['pdf'], ['md', 'txt']. Leave empty to include all document types.",
+ "items": {
+ "additionalProperties": false,
+ "type": "string"
+ },
+ "type": [
+ "array",
+ "null"
+ ]
+ },
+ "minAccessLevel": {
+ "additionalProperties": false,
+ "description": "Minimum access level required. Defaults to 'view' if not specified.",
+ "enum": [
+ "view",
+ "comment",
+ "edit",
+ "owner",
+ null
+ ],
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "pageOffset": {
+ "additionalProperties": false,
+ "default": 0,
+ "description": "Page offset for pagination. Default is 0. Use higher values to get subsequent pages of results.",
+ "format": "int64",
+ "type": "integer"
+ },
+ "pageSize": {
+ "additionalProperties": false,
+ "default": 50,
+ "description": "Number of results per page. Max is 100, default is 50. Use smaller values for focused results.",
+ "format": "int64",
+ "type": "integer"
}
},
"required": [
- "instructions",
- "markdown_file_id"
+ "exhaustiveSearch",
+ "fileTypes",
+ "minAccessLevel",
+ "pageOffset",
+ "pageSize"
],
- "title": "MarkdownRewrite",
+ "title": "ListDocuments",
"type": "object"
},
"outputSchema": {
- "additionalProperties": false,
"properties": {
- "diffs": {
+ "results": {
+ "description": "The list results (truncated to `results_returned` limit if applicable)",
"items": {
- "additionalProperties": false,
"properties": {
- "markdown_text": {
+ "access_level": {
+ "description": "The user's access level to this document",
+ "enum": [
+ "view",
+ "comment",
+ "edit",
+ "owner"
+ ],
"type": "string"
},
- "node_key": {
+ "created_at": {
+ "description": "When the document was created",
+ "format": "date-time",
"type": "string"
},
- "operation": {
+ "deleted_at": {
+ "description": "When the document was deleted (null if not deleted)",
+ "format": "date-time",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "document_id": {
+ "description": "The document id",
+ "type": "string"
+ },
+ "document_name": {
+ "description": "The document name",
+ "type": "string"
+ },
+ "file_type": {
+ "description": "The file type of the document",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "owner": {
+ "description": "The owner of the document",
+ "type": "string"
+ },
+ "project_id": {
+ "description": "The project id containing the document",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "updated_at": {
+ "description": "When the document was last updated",
+ "format": "date-time",
"type": "string"
}
},
"required": [
- "operation",
- "node_key",
- "markdown_text"
+ "document_id",
+ "document_name",
+ "owner",
+ "created_at",
+ "updated_at",
+ "access_level"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "resultsReturned": {
+ "description": "The number of results returned",
+ "format": "uint",
+ "minimum": 0,
+ "type": "integer"
+ },
+ "totalResults": {
+ "description": "Total number of results found",
+ "format": "uint",
+ "minimum": 0,
+ "type": "integer"
+ }
+ },
+ "required": [
+ "results",
+ "totalResults",
+ "resultsReturned"
+ ],
+ "title": "ListDocumentsResponse",
+ "type": "object"
+ }
+ },
+ {
+ "name": "WebSearch",
+ "inputSchema": {
+ "additionalProperties": false,
+ "description": "Trigger an intelligent internet search tool with a search query. Phrase the query as a natural language question. The search tool only has the information passed into the query string to include any relevant context from the conversation. Use this tool when the user specifically requests a web search, asks for resources, asks for links, asks you to read documentationWhen referencing links returned by search remember to use github markdown notation to format them like this [description](https://example.com)Our CEO describes when to use web search like this: I think some important criteria for choosing to search the web are\",\n if the user is asking for time-sensitive information (sports scores, news, current happenings, etc) that would have changed since the knowledge cutoff date\n Specific questions that reference external sources, eg contain a hyperlink in the user message or explicitly say “use webmd” or “check arxiv”\n do not use web search for things that are likely to find SEO slop content; this will make it worse than if it didn’t do it\n the LLM is be allowed to guess an answer and then use the web search tool to check AFTER providing the answer, if it feels it’s necessary. E.g. user asks “when was Caesar stabbed” -> llm gives answer -> if needed use web to double check\"\n do not use this tool many times in a single response, you think the user may need more information ask them before calling web search again. You should always sharethe results of your search with the user even if you are not sure if they are useful",
+ "properties": {
+ "query": {
+ "additionalProperties": false,
+ "description": "The search string to search for. Should be long / descriptive",
+ "type": "string"
+ }
+ },
+ "required": [
+ "query"
+ ],
+ "title": "WebSearch",
+ "type": "object"
+ },
+ "outputSchema": {
+ "properties": {
+ "content": {
+ "type": "string"
+ },
+ "results": {
+ "items": {
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "url": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "url",
+ "name"
],
"type": "object"
},
@@ -990,815 +1426,424 @@
}
},
"required": [
- "diffs"
+ "content",
+ "results"
],
- "title": "AIDiffResponse",
+ "title": "SearchResults",
"type": "object"
}
},
{
- "name": "UnifiedSearch",
+ "name": "ListEmails",
"inputSchema": {
"additionalProperties": false,
- "description": "Universal search across all content types (documents, emails, AI conversations, chat/slack threads/channels, projects aka folders). This tool will return broad metadata from successful results and/or content matches. Use the Read tool next to read the results from those matches. Only ever refer to documents by name or with a document mention. Never state the id of the document in plaintext. User's are presented with the results of this tool as a UI element so there is no need to enumerate the information found from this tool.",
+ "description": "List the emails the user has access to. Use this tool to discover and browse emails before using the Read tool to access their content. Prefer using the search tool to search on a specific matching string within the content or the name of the entity.",
"properties": {
- "exhaustiveSearch": {
+ "cursor": {
"additionalProperties": false,
- "default": true,
- "description": "Exhaustive search across all results matching the query. Defaults to true. Use false when the user only requires a limitied subset of results to answer the question",
- "type": "boolean"
+ "default": null,
+ "description": "A preview response will tell you what the next cursor id is.\n If expected emails are not in the current response and it gives you a cursor id, use this field to list the next page of emails. If no cursor id is provided you've reached the end",
+ "type": [
+ "string",
+ "null"
+ ]
},
- "pageOffset": {
+ "limit": {
"additionalProperties": false,
- "default": 0,
- "description": "Page offset. Default is 0. Use a higher offset to page through results intelligently. Set exhaustive_search to true to get all results.",
+ "default": 20,
+ "description": "limit the max emails returned. This defaults to 20 and has a maximum of 500",
"format": "int64",
"type": "integer"
},
- "pageSize": {
+ "sortMethod": {
"additionalProperties": false,
- "default": 10,
- "description": "Search count per search type (i.e. applies separately to each of documents, emails, ai_conversations, chats, projects). Max is 100. Default is 10. Does not apply when exhaustive_search is set to true.",
- "format": "int64",
- "type": "integer"
+ "default": "viewed_at",
+ "description": "Sort response by one of: viewed_at | updated_at | created_at | viewed_updated. Prefer viewed_at unless the otherwise specified",
+ "enum": [
+ "viewed_at",
+ "updated_at",
+ "created_at",
+ "viewed_updated"
+ ],
+ "type": "string"
},
- "request": {
+ "view": {
"additionalProperties": false,
- "description": "Aggregated search request, see individual fields for details",
+ "default": {
+ "standardLabel": null,
+ "userLabel": null
+ },
+ "description": "Choose the view to list emails from. One of either standard label or user label must be specified, otherwise defaults to important.",
"properties": {
- "filters": {
+ "standardLabel": {
"additionalProperties": false,
- "description": "Search filters for various kinds of items. Set the entire filters property as `null` if you do not have specific filters for a given type, e.g. bcc for email filters.",
- "properties": {
- "channel": {
- "additionalProperties": false,
- "description": "Channel filters. `null` to not filter channels searched over.",
- "properties": {
- "channel_ids": {
- "additionalProperties": false,
- "description": "Channel IDs to search within. Examples: ['general']. Empty to search all accessible channels.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
- },
- "mentions": {
- "additionalProperties": false,
- "description": "Channel user mentions to search for. Examples: ['@username']. Empty if not filtering by mentions.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "description": "Prefer important or all. Leave empty if using a user label",
+ "enum": [
+ "Inbox",
+ "Sent",
+ "Drafts",
+ "Starred",
+ "All",
+ "Important",
+ "Other",
+ null
+ ],
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "userLabel": {
+ "additionalProperties": false,
+ "description": "Choose a custom user label to filter by (optional). Standard label will take precedence over user label if both are specified.",
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "standardLabel",
+ "userLabel"
+ ],
+ "type": "object"
+ }
+ },
+ "required": [
+ "cursor",
+ "limit",
+ "sortMethod",
+ "view"
+ ],
+ "title": "ListEmails",
+ "type": "object"
+ },
+ "outputSchema": {
+ "properties": {
+ "items": {
+ "items": {
+ "properties": {
+ "attachments": {
+ "items": {
+ "properties": {
+ "contentId": {
+ "type": [
+ "string",
+ "null"
+ ]
},
- "org_id": {
- "additionalProperties": false,
- "description": "Channel organization ID to search within. Empty to ignore organization filtering.",
+ "createdAt": {
"format": "int64",
+ "type": "integer"
+ },
+ "filename": {
"type": [
- "integer",
+ "string",
"null"
]
},
- "sender_ids": {
- "additionalProperties": false,
- "description": "Sender IDs to search within. Examples: ['user1']. Empty to search all accessible senders.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "id": {
+ "format": "uuid",
+ "type": "string"
},
- "thread_ids": {
- "additionalProperties": false,
- "description": "Channel thread IDs to search within. Examples: ['thread123']. Empty to search all threads.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
- }
- },
- "required": [
- "channel_ids",
- "mentions",
- "org_id",
- "sender_ids",
- "thread_ids"
- ],
- "type": [
- "object",
- "null"
- ]
- },
- "chat": {
- "additionalProperties": false,
- "description": "Chat filters. `null` to not filter chats searched over.",
- "properties": {
- "chat_ids": {
- "additionalProperties": false,
- "description": "Chat ids to search over. Examples: ['chat1'], ['chat1', 'chat2']. When provided, chat search will only match results on these chats. Empty to search all accessible chats.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "messageId": {
+ "format": "uuid",
+ "type": "string"
},
- "owners": {
- "additionalProperties": false,
- "description": "Filter by chat owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "mimeType": {
+ "type": [
+ "string",
+ "null"
+ ]
},
- "project_ids": {
- "additionalProperties": false,
- "description": "A list of project ids to search within. Examples: ['project1']. Empty to ignore project filtering.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "providerAttachmentId": {
+ "type": [
+ "string",
+ "null"
+ ]
},
- "role": {
- "additionalProperties": false,
- "description": "Chat message roles to search. Examples: ['user'], ['assistant']. Empty to search all roles.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "sizeBytes": {
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
}
},
"required": [
- "chat_ids",
- "owners",
- "project_ids",
- "role"
+ "id",
+ "messageId",
+ "createdAt"
],
- "type": [
- "object",
- "null"
- ]
+ "type": "object"
},
- "document": {
- "additionalProperties": false,
- "description": "Document filters. `null` to not filter documents searched over.",
+ "type": "array"
+ },
+ "contacts": {
+ "items": {
"properties": {
- "document_ids": {
- "additionalProperties": false,
- "description": "Document ids to search over. Examples: ['doc1'], ['doc1', 'doc2']. Empty to search all accessible documents.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "emailAddress": {
+ "type": [
+ "string",
+ "null"
+ ]
},
- "file_types": {
- "additionalProperties": false,
- "description": "Document file types to search. Examples: ['pdf'], ['md', 'txt']. Empty to search all file types.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "id": {
+ "format": "uuid",
+ "type": "string"
},
- "owners": {
- "additionalProperties": false,
- "description": "Filter by document owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "linkId": {
+ "format": "uuid",
+ "type": "string"
},
- "project_ids": {
- "additionalProperties": false,
- "description": "A list of project ids to search within. Examples: ['project1'].\nfiltering. Empty to ignore project filtering.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "name": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "sfsPhotoUrl": {
+ "type": [
+ "string",
+ "null"
+ ]
}
},
"required": [
- "document_ids",
- "file_types",
- "owners",
- "project_ids"
+ "id",
+ "linkId"
],
- "type": [
- "object",
- "null"
- ]
+ "type": "object"
},
- "email": {
- "additionalProperties": false,
- "description": "Email filters. `null` to not filter emails searched over.",
- "properties": {
- "bcc": {
- "additionalProperties": false,
- "description": "Email BCC addresses to filter by. Examples: ['[email protected]']. Empty if not filtering by BCC.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
- },
- "cc": {
- "additionalProperties": false,
- "description": "Email CC addresses to filter by. Examples: ['[email protected]']. Empty if not filtering by CC.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "type": "array"
+ },
+ "createdAt": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "frecencyScore": {
+ "format": "double",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "id": {
+ "format": "uuid",
+ "type": "string"
+ },
+ "inboxVisible": {
+ "type": "boolean"
+ },
+ "isDraft": {
+ "type": "boolean"
+ },
+ "isImportant": {
+ "type": "boolean"
+ },
+ "isRead": {
+ "type": "boolean"
+ },
+ "labels": {
+ "items": {
+ "properties": {
+ "createdAt": {
+ "format": "date-time",
+ "type": "string"
},
- "recipients": {
- "additionalProperties": false,
- "description": "Email Recipient addresses to filter by. Examples: ['[email protected]']. Empty if not filtering by Recipient.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "id": {
+ "format": "uuid",
+ "type": "string"
},
- "senders": {
- "additionalProperties": false,
- "description": "Email sender addresses to filter by. Examples: ['[email protected]']. Empty to search all senders.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "labelListVisibility": {
+ "enum": [
+ "LabelShow",
+ "LabelShowIfUnread",
+ "LabelHide"
+ ],
+ "type": "string"
+ },
+ "linkId": {
+ "format": "uuid",
+ "type": "string"
+ },
+ "messageListVisibility": {
+ "enum": [
+ "Show",
+ "Hide"
+ ],
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "providerLabelId": {
+ "type": "string"
+ },
+ "type": {
+ "enum": [
+ "System",
+ "User"
+ ],
+ "type": "string"
}
},
"required": [
- "bcc",
- "cc",
- "recipients",
- "senders"
+ "id",
+ "linkId",
+ "providerLabelId",
+ "name",
+ "createdAt",
+ "messageListVisibility",
+ "labelListVisibility",
+ "type"
],
- "type": [
- "object",
- "null"
- ]
+ "type": "object"
},
- "project": {
- "additionalProperties": false,
- "description": "Project filters. `null` to not filter projects searched over.",
+ "type": "array"
+ },
+ "macroAttachments": {
+ "items": {
"properties": {
- "owners": {
- "additionalProperties": false,
- "description": "Filter by project owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "dbId": {
+ "format": "uuid",
+ "type": "string"
},
- "project_ids": {
- "additionalProperties": false,
- "description": "Project IDs to search within. Examples: ['project1']. Empty to search all accessible projects.",
- "items": {
- "additionalProperties": false,
- "type": "string"
- },
- "type": "array"
+ "itemId": {
+ "format": "uuid",
+ "type": "string"
+ },
+ "itemType": {
+ "type": "string"
+ },
+ "messageId": {
+ "format": "uuid",
+ "type": "string"
}
},
"required": [
- "owners",
- "project_ids"
+ "dbId",
+ "messageId",
+ "itemId",
+ "itemType"
],
- "type": [
- "object",
- "null"
- ]
- }
+ "type": "object"
+ },
+ "type": "array"
},
- "required": [
- "channel",
- "chat",
- "document",
- "email",
- "project"
- ],
- "type": [
- "object",
- "null"
- ]
- },
- "include": {
- "additionalProperties": false,
- "default": [],
- "description": "Include specific entity types from search. If empty, all entity types will be searched over. If you are unsure which types to search, use an empty array to search all.",
- "items": {
- "additionalProperties": false,
- "enum": [
- "documents",
- "chats",
- "emails",
- "channels",
- "projects"
+ "metadata": {
+ "properties": {
+ "calendar_invite": {
+ "description": "if any email contains a calendar invite",
+ "type": "boolean"
+ },
+ "generic_sender": {
+ "description": "if any sender in the thread is a generic email",
+ "type": "boolean"
+ },
+ "known_sender": {
+ "description": "if user has previously emailed any sender in the thread",
+ "type": "boolean"
+ },
+ "tabular": {
+ "description": "if any email contains a <table> html tag",
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "known_sender",
+ "tabular",
+ "calendar_invite",
+ "generic_sender"
],
- "type": "string"
+ "type": "object"
},
- "type": "array"
- },
- "match_type": {
- "additionalProperties": false,
- "description": "How to match the search terms. 'exact' for precise case-sensitive phrase matches, 'partial' for prefix/partial matches. REQUIRED field.",
- "enum": [
- "exact",
- "partial",
- "regexp"
- ],
- "type": "string"
- },
- "search_on": {
- "additionalProperties": false,
- "default": "content",
- "description": "Fields to search on (Name, Content, NameContent). Defaults to Content",
- "enum": [
- "name",
- "content",
- "name_content"
- ],
- "type": "string"
- },
- "terms": {
- "additionalProperties": false,
- "description": "Multiple distinct search terms as separate strings. Use this for keyword-based searches where you want to find content containing any of these terms. Each term must be at least 3 characters (shorter terms are automatically filtered out). Examples: ['machine', 'learning', 'algorithms'], ['project', 'status', 'update']. `null` this field if searching without text terms to search all. This field matches query string against both name and content.",
- "items": {
- "additionalProperties": false,
+ "name": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "ownerId": {
"type": "string"
},
- "type": [
- "array",
- "null"
- ]
- }
- },
- "required": [
- "filters",
- "include",
- "match_type",
- "search_on",
- "terms"
- ],
- "type": "object"
- }
- },
- "required": [
- "exhaustiveSearch",
- "pageOffset",
- "pageSize",
- "request"
- ],
- "title": "UnifiedSearch",
- "type": "object"
- },
- "outputSchema": {
- "properties": {
- "response": {
- "description": "The search results",
- "properties": {
- "results": {
- "description": "The search results (truncated to `results_returned` limit if applicable)",
- "items": {
- "oneOf": [
- {
- "properties": {
- "document_id": {
- "description": "The document id",
- "type": "string"
- },
- "document_name": {
- "description": "The document name",
- "type": "string"
- },
- "file_type": {
- "description": "The file type",
- "type": "string"
- },
- "highlight": {
- "description": "The highlights on the document",
- "properties": {
- "content": {
- "description": "The highlight match on the content field",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "name": {
- "description": "The highlight match on the name field",
- "type": [
- "string",
- "null"
- ]
- }
- },
- "type": "object"
- },
- "node_id": {
- "description": "The node id",
- "type": "string"
- },
- "owner_id": {
- "description": "The owner id",
- "type": "string"
- },
- "raw_content": {
- "description": "The raw content of the document",
- "type": [
- "string",
- "null"
- ]
- },
- "type": {
- "const": "document",
- "type": "string"
- },
- "updated_at": {
- "description": "The time the document was last updated",
- "format": "date-time",
- "type": "string"
- }
- },
- "required": [
- "type",
- "document_id",
- "document_name",
- "node_id",
- "owner_id",
- "file_type",
- "updated_at",
- "highlight"
- ],
- "type": "object"
- },
- {
- "properties": {
- "chat_id": {
- "description": "The chat id",
- "type": "string"
- },
- "chat_message_id": {
- "description": "The chat message id",
- "type": "string"
- },
- "highlight": {
- "description": "The highlights on the chat",
- "properties": {
- "content": {
- "description": "The highlight match on the content field",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "name": {
- "description": "The highlight match on the name field",
- "type": [
- "string",
- "null"
- ]
- }
- },
- "type": "object"
- },
- "role": {
- "description": "The role",
- "type": "string"
- },
- "title": {
- "description": "The title",
- "type": "string"
- },
- "type": {
- "const": "chat",
- "type": "string"
- },
- "updated_at": {
- "description": "The time the chat was last updated",
- "format": "date-time",
- "type": "string"
- },
- "user_id": {
- "description": "The user id",
- "type": "string"
- }
- },
- "required": [
- "type",
- "chat_id",
- "chat_message_id",
- "user_id",
- "role",
- "updated_at",
- "title",
- "highlight"
- ],
- "type": "object"
- },
- {
- "properties": {
- "bcc": {
- "description": "The bcc",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "cc": {
- "description": "The cc",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "highlight": {
- "description": "The highlights on the email",
- "properties": {
- "content": {
- "description": "The highlight match on the content field",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "name": {
- "description": "The highlight match on the name field",
- "type": [
- "string",
- "null"
- ]
- }
- },
- "type": "object"
- },
- "labels": {
- "description": "The labels",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "link_id": {
- "description": "The link id",
- "type": "string"
- },
- "message_id": {
- "description": "The message id",
- "type": "string"
- },
- "recipients": {
- "description": "The recipients",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "sender": {
- "description": "The sender",
- "type": "string"
- },
- "sent_at": {
- "description": "The time the email was sent",
- "format": "date-time",
- "type": [
- "string",
- "null"
- ]
- },
- "subject": {
- "description": "The subject",
- "type": [
- "string",
- "null"
- ]
- },
- "thread_id": {
- "description": "The thread id",
- "type": "string"
- },
- "type": {
- "const": "email",
- "type": "string"
- },
- "updated_at": {
- "description": "The time the email was last updated",
- "format": "date-time",
- "type": "string"
- },
- "user_id": {
- "description": "The user id",
- "type": "string"
- }
- },
- "required": [
- "type",
- "thread_id",
- "message_id",
- "sender",
- "recipients",
- "cc",
- "bcc",
- "labels",
- "link_id",
- "user_id",
- "updated_at",
- "highlight"
- ],
- "type": "object"
- },
- {
- "properties": {
- "channel_id": {
- "description": "The channel id",
- "type": "string"
- },
- "channel_type": {
- "description": "The channel type",
- "type": "string"
- },
- "created_at": {
- "description": "The time the channel message was created",
- "format": "date-time",
- "type": "string"
- },
- "highlight": {
- "description": "The highlights on the channel message",
- "properties": {
- "content": {
- "description": "The highlight match on the content field",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "name": {
- "description": "The highlight match on the name field",
- "type": [
- "string",
- "null"
- ]
- }
- },
- "type": "object"
- },
- "mentions": {
- "description": "The mentions",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "message_id": {
- "description": "The message id",
- "type": "string"
- },
- "org_id": {
- "description": "The org id",
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
- },
- "sender_id": {
- "description": "The sender id",
- "type": "string"
- },
- "thread_id": {
- "description": "The thread id",
- "type": [
- "string",
- "null"
- ]
- },
- "type": {
- "const": "channel",
- "type": "string"
- },
- "updated_at": {
- "description": "The time the channel message was last updated",
- "format": "date-time",
- "type": "string"
- }
- },
- "required": [
- "type",
- "channel_id",
- "channel_type",
- "message_id",
- "sender_id",
- "mentions",
- "created_at",
- "updated_at",
- "highlight"
- ],
- "type": "object"
- },
- {
- "properties": {
- "created_at": {
- "description": "The time the project was created",
- "format": "date-time",
- "type": "string"
- },
- "highlight": {
- "description": "The highlights on the project",
- "properties": {
- "content": {
- "description": "The highlight match on the content field",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "name": {
- "description": "The highlight match on the name field",
- "type": [
- "string",
- "null"
- ]
- }
- },
- "type": "object"
- },
- "project_id": {
- "description": "The project id",
- "type": "string"
- },
- "project_name": {
- "description": "The project name",
- "type": "string"
- },
- "type": {
- "const": "project",
- "type": "string"
- },
- "updated_at": {
- "description": "The time the project was last updated",
- "format": "date-time",
- "type": "string"
- },
- "user_id": {
- "description": "The id of the user who created the project",
- "type": "string"
- }
- },
- "required": [
- "type",
- "project_id",
- "updated_at",
- "created_at",
- "project_name",
- "user_id",
- "highlight"
- ],
- "type": "object"
- }
+ "providerId": {
+ "type": [
+ "string",
+ "null"
]
},
- "type": "array"
- },
- "resultsReturned": {
- "description": "the number of results returned",
- "format": "uint",
- "minimum": 0,
- "type": "integer"
+ "senderEmail": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "senderName": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "senderPhotoUrl": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "snippet": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "sortTs": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "updatedAt": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "viewedAt": {
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
},
- "totalResults": {
- "description": "total number of results from search",
- "format": "uint",
- "minimum": 0,
- "type": "integer"
- }
+ "required": [
+ "id",
+ "ownerId",
+ "inboxVisible",
+ "isRead",
+ "isDraft",
+ "isImportant",
+ "sortTs",
+ "createdAt",
+ "updatedAt",
+ "attachments",
+ "macroAttachments",
+ "contacts",
+ "labels",
+ "metadata"
+ ],
+ "type": "object"
},
- "required": [
- "results",
- "totalResults",
- "resultsReturned"
- ],
- "type": "object"
+ "type": "array"
},
- "responseSchema": {
- "description": "The JSON schema for the response so the LLM can understand it"
+ "next_cursor": {
+ "type": [
+ "string",
+ "null"
+ ]
}
},
"required": [
- "response",
- "responseSchema"
+ "items"
],
- "title": "UnifiedSearchResponseOutput",
+ "title": "ApiPaginatedThreadCursor",
"type": "object"
}
}
diff --git a/rust/cloud-storage/document_cognition_service/src/api/attachments/get_models_for_attachments.rs b/rust/cloud-storage/document_cognition_service/src/api/attachments/get_models_for_attachments.rs
index 397515757e..1cb0ffdc76 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/attachments/get_models_for_attachments.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/attachments/get_models_for_attachments.rs
@@ -1,7 +1,12 @@
use crate::{
api::context::ApiContext,
- core::constants::{DEFAULT_CHANNEL_TOKENS, DEFAULT_EMAIL_TOKENS, DEFAULT_IMAGE_TOKENS},
- core::model::CHAT_MODELS,
+ core::{
+ constants::{
+ DEFAULT_CHANNEL_TOKENS, DEFAULT_EMAIL_TOKENS, DEFAULT_IMAGE_TOKENS,
+ DEFAULT_PROJECT_TOKENS,
+ },
+ model::CHAT_MODELS,
+ },
model::request::chats::NewAttachment,
service::attachment::document::get_document_token_count,
};
@@ -76,9 +81,13 @@ pub async fn get_models_for_attachments_handler(
}
}
+ // computer virus
for attachment in &req.attachments {
let token_count =
match attachment.attachment_type {
+ AttachmentType::Project => {
+ DEFAULT_PROJECT_TOKENS
+ }
AttachmentType::Document => {
get_document_token_count(&state, attachment.attachment_id.as_str())
.await
diff --git a/rust/cloud-storage/document_cognition_service/src/api/chats/create_user_chat.rs b/rust/cloud-storage/document_cognition_service/src/api/chats/create_user_chat.rs
index 744bd640e0..094bc5f5cd 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/chats/create_user_chat.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/chats/create_user_chat.rs
@@ -3,6 +3,7 @@ use crate::{
core::{
constants::{
DEFAULT_CHANNEL_TOKENS, DEFAULT_CHAT_NAME, DEFAULT_EMAIL_TOKENS, DEFAULT_IMAGE_TOKENS,
+ DEFAULT_PROJECT_TOKENS,
},
model::FALLBACK_MODEL,
},
@@ -117,9 +118,11 @@ pub async fn create_user_chat_v2(
.await
.context("failed to get document token count")
}
+
AttachmentType::Image => Ok(DEFAULT_IMAGE_TOKENS),
AttachmentType::Channel => Ok(DEFAULT_CHANNEL_TOKENS),
AttachmentType::Email => Ok(DEFAULT_EMAIL_TOKENS),
+ AttachmentType::Project => Ok(DEFAULT_PROJECT_TOKENS),
}
}
},
diff --git a/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/ai_request.rs b/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/ai_request.rs
index 1e49573903..70bf0b8789 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/ai_request.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/ai_request.rs
@@ -16,10 +16,12 @@ pub async fn build_chat_completion_request(
chat: &ChatResponse,
incoming_message: &SendChatMessagePayload,
static_system_prompt: &str,
+ jwt: &str,
) -> Result<ChatCompletionRequest> {
let attachments = fetch::fetchium(
ctx.scribe.clone(),
incoming_message.attachments.clone().unwrap_or_default(),
+ jwt,
)
.await
.context("failed to fetch attachment content")?;
diff --git a/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rs
index 8da5e44e52..3ef238cbc6 100644
--- a/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rs
+++ b/rust/cloud-storage/document_cognition_service/src/api/ws/chat_message/mod.rs
@@ -320,15 +320,20 @@ pub async fn handle_send_chat_message(
})?;
let toolset = toolset::choose_toolset(&incoming_message);
- let request =
- build_chat_completion_request(ctx.clone(), &chat, &incoming_message, toolset.prompt)
- .await
- .map_err(|err| {
- tracing::error!(error=?err, "failed to build chat completion request");
- StreamError::InternalError {
- stream_id: incoming_message.stream_id.clone(),
- }
- })?;
+ let request = build_chat_completion_request(
+ ctx.clone(),
+ &chat,
+ &incoming_message,
+ toolset.prompt,
+ jwt_token,
+ )
+ .await
+ .map_err(|err| {
+ tracing::error!(error=?err, "failed to build chat completion request");
+ StreamError::InternalError {
+ stream_id: incoming_message.stream_id.clone(),
+ }
+ })?;
log::log_timing(log::LatencyMetric::TimeToSendRequest, model, now.elapsed());
let StreamChatResponse { new_messages } = stream_chat_response(
diff --git a/rust/cloud-storage/document_cognition_service/src/core/constants.rs b/rust/cloud-storage/document_cognition_service/src/core/constants.rs
index 50fa46d5ca..b3070b385d 100644
--- a/rust/cloud-storage/document_cognition_service/src/core/constants.rs
+++ b/rust/cloud-storage/document_cognition_service/src/core/constants.rs
@@ -1,4 +1,5 @@
pub const DEFAULT_CHAT_NAME: &str = "New Chat";
+/// max tokens the a model can respond with
pub const DEFAULT_MAX_TOKENS: u32 = 16000;
/// Default batch size for querying documents from rds
@@ -7,9 +8,12 @@ pub const DEFAULT_DOCUMENT_BATCH_LIMIT: i64 = 1000;
/// max token size openai image
pub const DEFAULT_IMAGE_TOKENS: i64 = 1105;
+// these are computer virust
+// we're estimating tokens of attachments for some reason but the estimates are not used
+// todo: remove estimates
pub const DEFAULT_CHANNEL_TOKENS: i64 = 5000;
-
pub const DEFAULT_EMAIL_TOKENS: i64 = 3000;
+pub const DEFAULT_PROJECT_TOKENS: i64 = 1000;
/// The transcript will include messages up to the smaller of
/// CHANNEL_TRANSCRIPT_MAX_MESSAGES or CHANNEL_TRANSCRIPT_MAX_DAYS
diff --git a/rust/cloud-storage/document_cognition_service/src/service/attachment/fetch.rs b/rust/cloud-storage/document_cognition_service/src/service/attachment/fetch.rs
index 5eb6018809..9217d6d253 100644
--- a/rust/cloud-storage/document_cognition_service/src/service/attachment/fetch.rs
+++ b/rust/cloud-storage/document_cognition_service/src/service/attachment/fetch.rs
@@ -2,7 +2,6 @@ use crate::api::context::DcsScribe;
use crate::core::constants::CHANNEL_TRANSCRIPT_MAX_MESSAGES;
use ai::types::{Attachment, PromptAttachment};
use ai_tools::read::EmailMessage;
-use anyhow::Context;
use model::{
chat::{AttachmentType, ChatAttachmentWithName},
document::FileTypeExt,
@@ -15,21 +14,37 @@ pub const EMAIL_THREAD_MESSAGE_LIMIT: i64 = 20;
pub async fn fetchium(
scribe: Arc<DcsScribe>,
attachments: Vec<ChatAttachmentWithName>,
+ jwt: &str,
) -> Result<Vec<Attachment>, anyhow::Error> {
// --- closure to fetch single attachment ---
#[tracing::instrument(err, skip(scribe))]
async fn fetchington(
attachment: ChatAttachmentWithName,
scribe: Arc<DcsScribe>,
+ jwt: &str,
) -> Result<Attachment, anyhow::Error> {
match attachment.attachment_type {
+ AttachmentType::Project => {
+ // fetch id's of stuff in folder
+ let project_items = scribe
+ .document
+ .fetch_project(attachment.attachment_id.clone(), jwt.to_owned())
+ .content()
+ .await?
+ .to_string();
+ Ok(Attachment::Text(PromptAttachment {
+ id: attachment.attachment_id.clone(),
+ file_type: "Project".into(),
+ name: attachment.name().unwrap_or_default().into(),
+ content: project_items,
+ }))
+ }
AttachmentType::Image => {
let base64_image = scribe
.static_file
.fetch(attachment.attachment_id.clone())
.file_content()
- .await
- .context("failed to fetch image content")?
+ .await?
.content
.base64_compressed_webp()?;
@@ -44,8 +59,7 @@ pub async fn fetchium(
None,
Some(CHANNEL_TRANSCRIPT_MAX_MESSAGES),
)
- .await
- .context("failed to fetch channel transcript")?;
+ .await?;
Ok(Attachment::Text(PromptAttachment {
content: transcript,
@@ -59,8 +73,7 @@ pub async fn fetchium(
.document
.fetch(attachment.attachment_id.clone())
.document_content()
- .await
- .context("failed to fetch document content")?;
+ .await?;
if document.file_type().is_image() {
Ok(Attachment::ImageUrl(
document.content.base64_compressed_webp()?,
@@ -83,8 +96,7 @@ pub async fn fetchium(
EMAIL_THREAD_MESSAGE_LIMIT,
None,
)
- .await
- .context("failed to fetch email message")?;
+ .await?;
let subject = thread
.first()
@@ -103,8 +115,7 @@ pub async fn fetchium(
messages: thread,
};
- let content = serde_json::to_string_pretty(&formatted_content)
- .context("error stringifying json")?;
+ let content = serde_json::to_string_pretty(&formatted_content)?;
Ok(Attachment::Text(PromptAttachment {
id: attachment.attachment_id,
@@ -115,25 +126,13 @@ pub async fn fetchium(
}
}
}
- //--- end closure --
- let handles = attachments.into_iter().map(|attachment| {
- let scribe = scribe.clone();
- tokio::spawn(async move { fetchington(attachment, scribe).await })
- });
+ let futures = attachments
+ .into_iter()
+ .map(|attachment| fetchington(attachment, scribe.clone(), jwt));
- let results = futures::future::try_join_all(handles)
- .await
- .context("failed to join attachment fetch tasks")?;
-
- if results.iter().any(Result::is_err) {
- let errors: Vec<_> = results.iter().filter_map(|r| r.as_ref().err()).collect();
- tracing::error!(
- error_count = errors.len(),
- "failed to fetch one or more attachments"
- );
- Err(anyhow::anyhow!("failed to get one or more attachments"))
- } else {
- Ok(results.into_iter().flatten().collect())
- }
+ let results = futures::future::try_join_all(futures).await.inspect_err(
+ |err| tracing::error!(error=?err, "failed to fetch one or more attachments"),
+ )?;
+ Ok(results)
}
diff --git a/rust/cloud-storage/document_cognition_service/src/service/get_chat.rs b/rust/cloud-storage/document_cognition_service/src/service/get_chat.rs
index 1e8bfcb6fe..29e336d998 100644
--- a/rust/cloud-storage/document_cognition_service/src/service/get_chat.rs
+++ b/rust/cloud-storage/document_cognition_service/src/service/get_chat.rs
@@ -37,6 +37,13 @@ pub async fn get_chat(
})
.ok()
}
+ AttachmentType::Project => {
+ get_document_name_and_type(db.clone(), &attachment.attachment_id)
+ .await
+ .map(|(name, _)| AttachmentMetadata::Project { project_name: name })
+ .ok()
+ }
+
AttachmentType::Document => {
get_document_name_and_type(db.clone(), &attachment.attachment_id)
.await
diff --git a/rust/cloud-storage/document_storage_service_client/src/lib.rs b/rust/cloud-storage/document_storage_service_client/src/lib.rs
index afeea46859..ac6de185cd 100644
--- a/rust/cloud-storage/document_storage_service_client/src/lib.rs
+++ b/rust/cloud-storage/document_storage_service_client/src/lib.rs
@@ -6,6 +6,7 @@ pub mod document;
pub mod error;
pub mod item_ids;
pub mod notification;
+pub mod project;
pub mod thread;
pub mod update_channel_share_permission;
pub mod update_user_channel_permissions;
diff --git a/rust/cloud-storage/document_storage_service_client/src/project.rs b/rust/cloud-storage/document_storage_service_client/src/project.rs
new file mode 100644
index 0000000000..eaa823bf80
--- /dev/null
+++ b/rust/cloud-storage/document_storage_service_client/src/project.rs
@@ -0,0 +1,23 @@
+use anyhow::Result;
+use model::project::response::GetProjectContentResponse;
+
+use super::DocumentStorageServiceClient;
+
+impl DocumentStorageServiceClient {
+ #[tracing::instrument(skip(self), err)]
+ pub async fn get_project(
+ &self,
+ project_id: &str,
+ jwt: &str,
+ ) -> Result<GetProjectContentResponse> {
+ let path = format!("/projects/{}/content", project_id);
+ let json = self
+ .external_request(reqwest::Method::GET, path.as_str(), jwt)
+ .send()
+ .await?
+ .json()
+ .await?;
+
+ serde_json::from_value(json).map_err(Into::into)
+ }
+}
diff --git a/rust/cloud-storage/model/src/chat/mod.rs b/rust/cloud-storage/model/src/chat/mod.rs
index 41d2e97676..4e76a63b83 100644
--- a/rust/cloud-storage/model/src/chat/mod.rs
+++ b/rust/cloud-storage/model/src/chat/mod.rs
@@ -64,11 +64,12 @@ pub enum AttachmentType {
Image,
Channel,
Email,
+ Project,
}
#[derive(sqlx::FromRow, Serialize, Deserialize, Eq, PartialEq, Debug, Clone, ToSchema)]
pub struct ChatAttachment {
- /// Id of the attachment
+ /// db attachment id - unused
pub id: String,
/// The type of attachment
pub attachment_type: AttachmentType,
@@ -90,6 +91,9 @@ pub enum AttachmentMetadata {
/// Name of the document
document_name: String,
},
+ Project {
+ project_name: String,
+ },
Image {
/// jpg | png | etc
image_extension: FileType,
@@ -101,7 +105,9 @@ pub enum AttachmentMetadata {
channel_type: ChannelType,
},
/// an email thread
- Email { email_subject: String },
+ Email {
+ email_subject: String,
+ },
}
#[derive(sqlx::FromRow, Serialize, Deserialize, Eq, PartialEq, Debug, Clone, ToSchema)]
@@ -124,6 +130,7 @@ impl ChatAttachmentWithName {
AttachmentMetadata::Document { document_name, .. } => document_name.as_str(),
AttachmentMetadata::Image { image_name, .. } => image_name.as_str(),
AttachmentMetadata::Email { email_subject, .. } => email_subject.as_str(),
+ AttachmentMetadata::Project { project_name: name } => name.as_str(),
})
}
diff --git a/rust/cloud-storage/model/src/item/mod.rs b/rust/cloud-storage/model/src/item/mod.rs
index ce2032ab29..88e9bdd754 100644
--- a/rust/cloud-storage/model/src/item/mod.rs
+++ b/rust/cloud-storage/model/src/item/mod.rs
@@ -77,6 +77,23 @@ impl PartialSchema for Item {
}
}
+impl Item {
+ pub fn name(&self) -> &str {
+ match self {
+ Self::Chat(chat) => &chat.name,
+ Self::Project(project) => &project.name,
+ Self::Document(document) => &document.document_name,
+ }
+ }
+
+ pub fn file_type(&self) -> Option<&str> {
+ match self {
+ Self::Document(document) => document.file_type.as_deref(),
+ _ => None,
+ }
+ }
+}
+
impl PartialOrd for Item {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
diff --git a/rust/cloud-storage/model/src/project/response.rs b/rust/cloud-storage/model/src/project/response.rs
index ed4568cb32..b5e103d918 100644
--- a/rust/cloud-storage/model/src/project/response.rs
+++ b/rust/cloud-storage/model/src/project/response.rs
@@ -15,7 +15,7 @@ pub struct GetProjectsResponse {
pub data: Vec<Project>,
}
-#[derive(serde::Serialize, serde::Deserialize, Debug, ToSchema)]
+#[derive(serde::Serialize, serde::Deserialize, Debug, ToSchema, Clone)]
#[serde(rename_all = "camelCase")]
pub struct GetProjectContentResponse {
/// Indicates if an error occurred
diff --git a/rust/cloud-storage/scribe/src/document/client.rs b/rust/cloud-storage/scribe/src/document/client.rs
index f525b58fb5..de3ebbb5a0 100644
--- a/rust/cloud-storage/scribe/src/document/client.rs
+++ b/rust/cloud-storage/scribe/src/document/client.rs
@@ -1,4 +1,5 @@
use super::fetcher::NewDocumentFetcher;
+use super::project::ProjectFetcher;
use document_storage_service_client::DocumentStorageServiceClient;
use lexical_client::LexicalClient;
use std::sync::Arc;
@@ -53,6 +54,10 @@ impl DocumentClient {
)
.with_jwt_token(jwt_token)
}
+
+ pub fn fetch_project(&self, id: String, jwt: String) -> ProjectFetcher<()> {
+ ProjectFetcher::new(self.dss_client.clone(), id, jwt)
+ }
}
// --- builder --- //
diff --git a/rust/cloud-storage/scribe/src/document/mod.rs b/rust/cloud-storage/scribe/src/document/mod.rs
index b6c2b9ff45..a509cf0f82 100644
--- a/rust/cloud-storage/scribe/src/document/mod.rs
+++ b/rust/cloud-storage/scribe/src/document/mod.rs
@@ -1,6 +1,7 @@
use crate::client::ScribeClient;
mod client;
mod fetcher;
+mod project;
pub mod types;
pub use client::DocumentClient;
diff --git a/rust/cloud-storage/scribe/src/document/project.rs b/rust/cloud-storage/scribe/src/document/project.rs
new file mode 100644
index 0000000000..68873d31d2
--- /dev/null
+++ b/rust/cloud-storage/scribe/src/document/project.rs
@@ -0,0 +1,86 @@
+use anyhow::Result;
+use document_storage_service_client::DocumentStorageServiceClient;
+use model::item::{Item, ItemWithUserAccessLevel};
+use model::project::response::GetProjectContentResponse;
+use std::sync::Arc;
+
+#[derive(Debug, Clone)]
+pub struct ScribeProjectPreview(pub GetProjectContentResponse);
+
+pub fn format_item_with_access(
+ item: &ItemWithUserAccessLevel,
+ f: &mut std::fmt::Formatter<'_>,
+) -> std::fmt::Result {
+ if let Some(file_type) = item.item.file_type() {
+ writeln!(f, "name: {} {}", item.item.name(), file_type)?;
+ } else {
+ writeln!(f, "name: {}", item.item.name())?;
+ }
+ writeln!(
+ f,
+ "id: {}",
+ match &item.item {
+ Item::Document(doc) => doc.document_id.as_str(),
+ Item::Project(project) => project.id.as_str(),
+ Item::Chat(chat) => chat.id.as_str(),
+ }
+ )?;
+ writeln!(
+ f,
+ "type: {}",
+ match &item.item {
+ Item::Chat(_) => "Chat",
+ Item::Project(_) => "Project",
+ Item::Document(_) => "Document",
+ }
+ )?;
+ writeln!(f, "access_level: {}", item.user_access_level)
+}
+
+impl std::fmt::Display for ScribeProjectPreview {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ for (i, item) in self.0.data.iter().enumerate() {
+ writeln!(f, "{}.", i)?;
+ format_item_with_access(item, f)?;
+ }
+ Ok(())
+ }
+}
+
+pub struct ProjectFetcher<Content> {
+ inner_dss: Arc<DocumentStorageServiceClient>,
+ pub content: Content,
+ pub id: String,
+ pub jwt: String,
+}
+
+pub type NoData = ();
+
+impl ProjectFetcher<NoData> {
+ pub fn new(client: Arc<DocumentStorageServiceClient>, id: String, jwt: String) -> Self {
+ Self {
+ content: (),
+ id,
+ jwt,
+ inner_dss: client,
+ }
+ }
+
+ pub async fn content(&mut self) -> Result<ProjectFetcher<ScribeProjectPreview>> {
+ self.inner_dss
+ .get_project(&self.id, &self.jwt)
+ .await
+ .map(|response| ProjectFetcher {
+ content: ScribeProjectPreview(response),
+ id: self.id.clone(),
+ inner_dss: self.inner_dss.clone(),
+ jwt: self.jwt.clone(),
+ })
+ }
+}
+
+impl std::fmt::Display for ProjectFetcher<ScribeProjectPreview> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "Items in project {}\n{}", self.id, self.content)
+ }
+}
diff --git a/rust/cloud-storage/scribe/src/lib.rs b/rust/cloud-storage/scribe/src/lib.rs
index f6b4cb2c38..6715c25187 100644
--- a/rust/cloud-storage/scribe/src/lib.rs
+++ b/rust/cloud-storage/scribe/src/lib.rs
@@ -6,6 +6,7 @@ mod compress_image;
pub mod dcs;
#[cfg(feature = "document")]
pub mod document;
+
#[cfg(feature = "email")]
pub mod email;
#[cfg(feature = "static_file")]