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(ai): web_fetch tool (#964)

Eric Hayes445631404f58
diff --git a/js/app/packages/app/component/rightbar/Rightbar.tsx b/js/app/packages/app/component/rightbar/Rightbar.tsx
index 05f1a8f958..ea3c2ff0b4 100644
--- a/js/app/packages/app/component/rightbar/Rightbar.tsx
+++ b/js/app/packages/app/component/rightbar/Rightbar.tsx
@@ -604,6 +604,7 @@ export const RightbarWrapper = (_props: { isBigChat?: boolean }) => {
hotkeyToken: TOKENS.chat.spotlight.close,
condition: () => Boolean(bigChatOpen() || isRightPanelOpen()),
description: 'Close chat',
+ runWithInputFocused: true,
keyDownHandler: () => {
if (bigChatOpen()) {
setBigChatOpen(false);
diff --git a/js/app/packages/core/component/AI/component/tool/WebFetch.tsx b/js/app/packages/core/component/AI/component/tool/WebFetch.tsx
new file mode 100644
index 0000000000..0cd25a2e72
--- /dev/null
+++ b/js/app/packages/core/component/AI/component/tool/WebFetch.tsx
@@ -0,0 +1,83 @@
+import Globe from '@phosphor-icons/core/regular/globe.svg';
+import { Match, Switch } from 'solid-js';
+import { BaseTool } from './BaseTool';
+import { createToolRenderer } from './ToolRenderer';
+
+// Runtime type for successful web fetch (schema differs from generated types)
+type WebFetchSuccess = {
+ content: {
+ title?: string | null;
+ source: { data: string; media_type: string; type: 'text' | 'base64' };
+ citations?: { enabled: boolean } | null;
+ };
+ retrieved_at: string;
+ url: string;
+};
+
+// Runtime type for error web fetch
+type WebFetchError = {
+ error_code: string;
+};
+
+function isWebFetchError(content: unknown): content is WebFetchError {
+ return (
+ typeof content === 'object' && content !== null && 'error_code' in content
+ );
+}
+
+function isWebFetchSuccess(content: unknown): content is WebFetchSuccess {
+ return typeof content === 'object' && content !== null && 'url' in content;
+}
+
+const handler = createToolRenderer({
+ name: 'web_fetch',
+ renderCall: (ctx) => (
+ <BaseTool
+ icon={Globe}
+ text="Fetching"
+ renderContext={ctx.renderContext}
+ type="call"
+ >
+ <a
+ href={ctx.tool.data.url}
+ target="_blank"
+ rel="noopener noreferrer"
+ class="italic text-accent hover:underline"
+ >
+ {ctx.tool.data.url}
+ </a>
+ </BaseTool>
+ ),
+ renderResponse: (ctx) => {
+ const content = ctx.tool.data.content as unknown;
+ return (
+ <BaseTool
+ icon={Globe}
+ text="Fetched"
+ renderContext={ctx.renderContext}
+ type="response"
+ >
+ <Switch>
+ <Match when={isWebFetchError(content)}>
+ <div class="text-ink-error">
+ Error: {(content as WebFetchError).error_code}
+ </div>
+ </Match>
+ <Match when={isWebFetchSuccess(content)}>
+ <a
+ href={(content as WebFetchSuccess).url}
+ target="_blank"
+ rel="noopener noreferrer"
+ class="text-accent hover:underline"
+ >
+ {(content as WebFetchSuccess).content?.title ??
+ (content as WebFetchSuccess).url}
+ </a>
+ </Match>
+ </Switch>
+ </BaseTool>
+ );
+ },
+});
+
+export const webFetchHandler = handler;
diff --git a/js/app/packages/core/component/AI/component/tool/handler.tsx b/js/app/packages/core/component/AI/component/tool/handler.tsx
index 54284bc90c..da60312554 100644
--- a/js/app/packages/core/component/AI/component/tool/handler.tsx
+++ b/js/app/packages/core/component/AI/component/tool/handler.tsx
@@ -16,6 +16,7 @@ import { rewriteHandler } from './MarkdownRewrite';
import { readHandler } from './Read';
import { contentSearchHandler, nameSearchHandler } from './Search';
import type { RenderContext } from './ToolRenderer';
+import { webFetchHandler } from './WebFetch';
import { webSearchHandler } from './WebSearch';
const [renderStore, setRenderStore] = createStore<
@@ -25,6 +26,7 @@ const [renderStore, setRenderStore] = createStore<
const toolHandlers: ToolHandlerMap<RenderContext> = {
ContentSearch: contentSearchHandler,
NameSearch: nameSearchHandler,
+ web_fetch: webFetchHandler,
web_search: webSearchHandler,
MarkdownRewrite: rewriteHandler,
Read: readHandler,
diff --git a/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts b/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts
index c61883ea4f..a7ed7248e4 100644
--- a/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts
+++ b/js/app/packages/service-clients/service-cognition/generated/tools/schemas.ts
@@ -471,6 +471,100 @@ export const ReadResponse = z.object({
}),
});
+export const WebFetchToolCall = z.object({ url: z.string() });
+
+export const WebFetchResponse = z.object({
+ content: z.any().superRefine((x, ctx) => {
+ const schemas = [
+ z.object({
+ content: z.object({
+ citations: z
+ .union([z.object({ enabled: z.boolean() }), z.null()])
+ .optional(),
+ source: z.any().superRefine((x, ctx) => {
+ const schemas = [
+ z.object({
+ data: z.string(),
+ media_type: z.string(),
+ type: z.literal('text'),
+ }),
+ z.object({
+ data: z.string(),
+ media_type: z.string(),
+ type: z.literal('base64'),
+ }),
+ ];
+ const errors = schemas.reduce<z.ZodError[]>(
+ (errors, schema) =>
+ ((result) =>
+ result.error ? [...errors, result.error] : errors)(
+ schema.safeParse(x)
+ ),
+ []
+ );
+ if (schemas.length - errors.length !== 1) {
+ ctx.addIssue({
+ path: ctx.path,
+ code: 'invalid_union',
+ unionErrors: errors,
+ message: 'Invalid input: Should pass single schema',
+ });
+ }
+ }),
+ title: z.union([z.string(), z.null()]).optional(),
+ }),
+ retrieved_at: z.string(),
+ url: z.string(),
+ }),
+ z.object({
+ error_code: z.any().superRefine((x, ctx) => {
+ const schemas = [
+ z.literal('invalid_input'),
+ z.literal('url_too_long'),
+ z.literal('url_not_allowed'),
+ z.literal('url_not_accessible'),
+ z.literal('too_many_requests'),
+ z.literal('unsupported_content_type'),
+ z.literal('max_uses_exceeded'),
+ z.literal('unavailable'),
+ ];
+ const errors = schemas.reduce<z.ZodError[]>(
+ (errors, schema) =>
+ ((result) => (result.error ? [...errors, result.error] : errors))(
+ schema.safeParse(x)
+ ),
+ []
+ );
+ if (schemas.length - errors.length !== 1) {
+ ctx.addIssue({
+ path: ctx.path,
+ code: 'invalid_union',
+ unionErrors: errors,
+ message: 'Invalid input: Should pass single schema',
+ });
+ }
+ }),
+ }),
+ ];
+ const errors = schemas.reduce<z.ZodError[]>(
+ (errors, schema) =>
+ ((result) => (result.error ? [...errors, result.error] : errors))(
+ schema.safeParse(x)
+ ),
+ []
+ );
+ if (schemas.length - errors.length !== 1) {
+ ctx.addIssue({
+ path: ctx.path,
+ code: 'invalid_union',
+ unionErrors: errors,
+ message: 'Invalid input: Should pass single schema',
+ });
+ }
+ }),
+ tool_use_id: z.string(),
+});
+
export const WebSearchToolCall = z.object({ query: z.string() });
export const WebSearchResponse = z.object({
diff --git a/js/app/packages/service-clients/service-cognition/generated/tools/tool.ts b/js/app/packages/service-clients/service-cognition/generated/tools/tool.ts
index 9c3d56663d..8e43932a69 100644
--- a/js/app/packages/service-clients/service-cognition/generated/tools/tool.ts
+++ b/js/app/packages/service-clients/service-cognition/generated/tools/tool.ts
@@ -27,6 +27,7 @@ type ToolParserMap = {
};
NameSearch: { call: types.NameSearch; response: types.SearchToolResponse };
Read: { call: types.Read; response: types.ReadResponse };
+ web_fetch: { call: types.WebFetchToolCall; response: types.WebFetchResponse };
web_search: {
call: types.WebSearchToolCall;
response: types.WebSearchResponse;
@@ -55,6 +56,10 @@ const toolParserMap = {
response: schemas.SearchToolResponse,
},
Read: { call: schemas.Read, response: schemas.ReadResponse },
+ web_fetch: {
+ call: schemas.WebFetchToolCall,
+ response: schemas.WebFetchResponse,
+ },
web_search: {
call: schemas.WebSearchToolCall,
response: schemas.WebSearchResponse,
@@ -88,6 +93,7 @@ type ToolDataMap = {
};
NameSearch: { call: types.NameSearch; response: types.SearchToolResponse };
Read: { call: types.Read; response: types.ReadResponse };
+ web_fetch: { call: types.WebFetchToolCall; response: types.WebFetchResponse };
web_search: {
call: types.WebSearchToolCall;
response: types.WebSearchResponse;
diff --git a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts b/js/app/packages/service-clients/service-cognition/generated/tools/types.ts
index ee1aba4e88..22b910bb4f 100644
--- a/js/app/packages/service-clients/service-cognition/generated/tools/types.ts
+++ b/js/app/packages/service-clients/service-cognition/generated/tools/types.ts
@@ -575,7 +575,7 @@ export interface ListDocumentsResponse {
*/
/**
- * 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.
+ * List the emails the user has access to. Use this tool to find all emails from / to a specific person. Prefer using the search tool to search on a specific matching string within the content or the name of the entity.
*/
export interface ListEmails {
/**
@@ -840,6 +840,52 @@ export interface ReadResponse {
};
}
+/* eslint-disable */
+/**
+ * This file was automatically generated by json-schema-to-typescript.
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
+ * and run json-schema-to-typescript to regenerate this file.
+ */
+
+/**
+ * The expected shape of the streamed JSON following a `server_tool_use` in content_block_start event
+ */
+export interface WebFetchToolCall {
+ url: string;
+}
+
+/* eslint-disable */
+/**
+ * This file was automatically generated by json-schema-to-typescript.
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
+ * and run json-schema-to-typescript to regenerate this file.
+ */
+
+/**
+ * Content of a web fetch response - either a successful result or an error
+ */
+export type WebFetchContent = WebFetchResult | WebFetchToolError;
+
+/**
+ * Web fetch tool response content returned by Claude when using the web_fetch tool
+ */
+export interface WebFetchResponse {
+ content: WebFetchContent;
+ tool_use_id: string;
+}
+/**
+ * Successful web fetch result containing the fetched content
+ */
+export interface WebFetchResult {
+ type: 'web_fetch_result';
+}
+/**
+ * Error returned when web fetch fails
+ */
+export interface WebFetchToolError {
+ type: 'web_fetch_tool_result_error';
+}
+
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index 3cf51a2691..3255c22636 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -242,6 +242,7 @@ dependencies = [
"futures",
"lazy_static",
"rand 0.9.0",
+ "regex",
"reqwest",
"reqwest-eventsource",
"schemars",
diff --git a/rust/cloud-storage/ai/src/tool/tool_loop/ai_client.rs b/rust/cloud-storage/ai/src/tool/tool_loop/ai_client.rs
index 7b3d1fcc7e..953bb87d49 100644
--- a/rust/cloud-storage/ai/src/tool/tool_loop/ai_client.rs
+++ b/rust/cloud-storage/ai/src/tool/tool_loop/ai_client.rs
@@ -23,7 +23,10 @@ where
R: Clone + Send + Sync,
{
pub fn new(toolset: AsyncToolSet<T, R>, context: T) -> Self {
- let extensions = AnthropicRequestExtensions(vec![AnthropicRequestExtension::WebSearchTool]);
+ let extensions = AnthropicRequestExtensions(vec![
+ AnthropicRequestExtension::WebSearchTool,
+ AnthropicRequestExtension::FetchTool,
+ ]);
let client = AnthropicClient::new(extensions);
let toolset = Arc::new(toolset);
Self {
diff --git a/rust/cloud-storage/ai/src/types/client/anthropic.rs b/rust/cloud-storage/ai/src/types/client/anthropic.rs
index ffce467a3e..668387ab45 100644
--- a/rust/cloud-storage/ai/src/types/client/anthropic.rs
+++ b/rust/cloud-storage/ai/src/types/client/anthropic.rs
@@ -17,7 +17,7 @@ pub struct AnthropicClient {
impl AnthropicClient {
pub fn new(extensions: AnthropicRequestExtensions) -> Self {
- let client = anthropic::client::Client::dangerously_try_from_env();
+ let client = anthropic::client::Client::dangerously_try_from_env(Some(extensions.clone()));
Self {
inner: client,
extensions,
@@ -75,6 +75,16 @@ impl ExtendedClient for AnthropicClient {
name: "web_search".into(),
}))
}
+ AnthropicResponseExtension::WebFetchToolResponse(response) => {
+ let id = response.tool_use_id.clone();
+ let json = serde_json::to_value(&response).ok()?;
+
+ Some(StreamPart::ToolResponse(ToolResponse::Json {
+ id,
+ json,
+ name: "web_fetch".into(),
+ }))
+ }
}
}
}
diff --git a/rust/cloud-storage/ai_tools/src/lib.rs b/rust/cloud-storage/ai_tools/src/lib.rs
index bf1abc3030..01f6880131 100644
--- a/rust/cloud-storage/ai_tools/src/lib.rs
+++ b/rust/cloud-storage/ai_tools/src/lib.rs
@@ -6,7 +6,9 @@ pub mod read;
pub mod rewrite;
pub mod search;
mod tool_context;
+pub mod web_fetch;
use search::web::anthropic_web_search::anthropic_web_search_tool;
+use web_fetch::anthropic_web_fetch_tool;
pub use search::search_toolset;
pub use tool_context::*;
@@ -26,6 +28,7 @@ impl ToolSchemaGenerator for ToolSetWithPrompt {
}
}
+/// These are actually sent to the AI provider
pub fn all_tools() -> ToolSetWithPrompt {
let toolset = AsyncToolSet::new()
.add_toolset(search_toolset())
@@ -40,9 +43,12 @@ pub fn all_tools() -> ToolSetWithPrompt {
ToolSetWithPrompt { toolset, prompt }
}
+/// These are used to generate schemas for the frontend
+/// See [ai::tool::types::schema::PhantomTool]
pub fn all_tool_schemas() -> ToolSchemas {
all_tools()
.merge(&*anthropic_web_search_tool)
+ .merge(&*anthropic_web_fetch_tool)
.generate_schemas()
}
diff --git a/rust/cloud-storage/ai_tools/src/web_fetch.rs b/rust/cloud-storage/ai_tools/src/web_fetch.rs
new file mode 100644
index 0000000000..090bc407ac
--- /dev/null
+++ b/rust/cloud-storage/ai_tools/src/web_fetch.rs
@@ -0,0 +1,8 @@
+use ai::tool::schema::PhantomTool;
+use anthropic::types::response::web_fetch::{WebFetchResponse, WebFetchToolCall};
+use lazy_static::lazy_static;
+
+lazy_static! {
+ pub static ref anthropic_web_fetch_tool: PhantomTool<WebFetchToolCall, WebFetchResponse> =
+ PhantomTool::new("web_fetch");
+}
diff --git a/rust/cloud-storage/anthropic/Cargo.toml b/rust/cloud-storage/anthropic/Cargo.toml
index 2d0897b4df..1e60fb0532 100644
--- a/rust/cloud-storage/anthropic/Cargo.toml
+++ b/rust/cloud-storage/anthropic/Cargo.toml
@@ -27,3 +27,4 @@ tokio-stream = { workspace = true }
async-openai = { workspace = true, optional = true}
chrono.workspace = true
lazy_static = {workspace = true}
+regex = { workspace = true }
diff --git a/rust/cloud-storage/anthropic/examples/chat.rs b/rust/cloud-storage/anthropic/examples/chat.rs
index f4c6205b23..785614fa40 100644
--- a/rust/cloud-storage/anthropic/examples/chat.rs
+++ b/rust/cloud-storage/anthropic/examples/chat.rs
@@ -10,7 +10,7 @@ use futures::StreamExt;
#[tokio::main]
async fn main() {
- let client = Client::dangerously_try_from_env();
+ let client = Client::dangerously_try_from_env(None);
let mut request = CreateMessageRequestBody::default();
request.max_tokens = 1000;
request.system = Some(SystemPrompt::Text(
diff --git a/rust/cloud-storage/anthropic/examples/chat_openai.rs b/rust/cloud-storage/anthropic/examples/chat_openai.rs
index 1ac5ff304f..4c1dae883a 100644
--- a/rust/cloud-storage/anthropic/examples/chat_openai.rs
+++ b/rust/cloud-storage/anthropic/examples/chat_openai.rs
@@ -13,7 +13,7 @@ use futures::StreamExt;
#[tokio::main]
async fn main() {
- let client = Client::dangerously_try_from_env();
+ let client = Client::dangerously_try_from_env(None);
let mut request = CreateChatCompletionRequestArgs::default()
.model("claude-haiku-4-5")
diff --git a/rust/cloud-storage/anthropic/examples/only_openai_chat.rs b/rust/cloud-storage/anthropic/examples/only_openai_chat.rs
index 54916109e2..bcdcc0c5c6 100644
--- a/rust/cloud-storage/anthropic/examples/only_openai_chat.rs
+++ b/rust/cloud-storage/anthropic/examples/only_openai_chat.rs
@@ -18,7 +18,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
.build()?;
println!("{:#?}", request);
- let client = anthropic::client::Client::dangerously_try_from_env();
+ let client = anthropic::client::Client::dangerously_try_from_env(None);
let mut stream = client.chat().create_stream_openai_lossy(request).await;
let mut lock = stdout().lock();
diff --git a/rust/cloud-storage/anthropic/examples/only_openai_tools.rs b/rust/cloud-storage/anthropic/examples/only_openai_tools.rs
index 882cf6a6e3..0c625a31f6 100644
--- a/rust/cloud-storage/anthropic/examples/only_openai_tools.rs
+++ b/rust/cloud-storage/anthropic/examples/only_openai_tools.rs
@@ -51,7 +51,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.tools(tools.clone())
.build()?;
- let client = anthropic::client::Client::dangerously_try_from_env();
+ let client = anthropic::client::Client::dangerously_try_from_env(None);
let mut stream = client.chat().create_stream_openai_lossy(request).await;
let tool_call_states: Arc<Mutex<HashMap<(u32, u32), ChatCompletionMessageToolCall>>> =
diff --git a/rust/cloud-storage/anthropic/examples/server_tool.rs b/rust/cloud-storage/anthropic/examples/server_tool.rs
index 10c09efbf6..150f04617e 100644
--- a/rust/cloud-storage/anthropic/examples/server_tool.rs
+++ b/rust/cloud-storage/anthropic/examples/server_tool.rs
@@ -14,7 +14,7 @@ const LOG_MODE: bool = false;
#[tokio::main]
async fn main() {
- let client = Client::dangerously_try_from_env();
+ let client = Client::dangerously_try_from_env(None);
let mut request = CreateMessageRequestBody::default();
request.max_tokens = 1000;
request.system = Some(SystemPrompt::Text(
diff --git a/rust/cloud-storage/anthropic/examples/tools.rs b/rust/cloud-storage/anthropic/examples/tools.rs
index 962f8f4616..e165cca5aa 100644
--- a/rust/cloud-storage/anthropic/examples/tools.rs
+++ b/rust/cloud-storage/anthropic/examples/tools.rs
@@ -31,7 +31,7 @@ async fn main() {
}
);
- let client = anthropic::client::Client::dangerously_try_from_env();
+ let client = anthropic::client::Client::dangerously_try_from_env(None);
let mut request = anthropic::types::request::CreateMessageRequestBody::default();
request.model = "claude-haiku-4-5".into();
request.max_tokens = 6767;
diff --git a/rust/cloud-storage/anthropic/examples/tools_openai.rs b/rust/cloud-storage/anthropic/examples/tools_openai.rs
index 43d3c844f4..6c6d3a961c 100644
--- a/rust/cloud-storage/anthropic/examples/tools_openai.rs
+++ b/rust/cloud-storage/anthropic/examples/tools_openai.rs
@@ -34,7 +34,7 @@ async fn main() {
.build()
.expect("tool");
- let client = Client::dangerously_try_from_env();
+ let client = Client::dangerously_try_from_env(None);
let request = CreateChatCompletionRequestArgs::default()
.model("claude-haiku-4-5")
.max_completion_tokens(1000_u32)
diff --git a/rust/cloud-storage/anthropic/src/client/chat.rs b/rust/cloud-storage/anthropic/src/client/chat.rs
index 3db3dcd7a0..10562fdbff 100644
--- a/rust/cloud-storage/anthropic/src/client/chat.rs
+++ b/rust/cloud-storage/anthropic/src/client/chat.rs
@@ -6,6 +6,7 @@ use std::pin::Pin;
use super::Client;
use crate::error::AnthropicError;
use crate::types::request::CreateMessageRequestBody;
+use crate::types::request::transform_request_web_fetch;
use crate::types::response::StreamEvent;
pub type MessageCompletionResponseStream =
@@ -28,6 +29,7 @@ impl<'c> Chat<'c> {
{
let mut request = request.into();
request.stream = Some(true);
+ let request = transform_request_web_fetch(request);
self.create_stream_unchecked(request).await
}
diff --git a/rust/cloud-storage/anthropic/src/client/mod.rs b/rust/cloud-storage/anthropic/src/client/mod.rs
index a4d8ec17c7..319a0aa0f0 100644
--- a/rust/cloud-storage/anthropic/src/client/mod.rs
+++ b/rust/cloud-storage/anthropic/src/client/mod.rs
@@ -1,7 +1,9 @@
pub mod chat;
-use crate::config::Config;
use crate::error::AnthropicError;
+use crate::openai::request::AnthropicRequestExtension;
use crate::prelude::ApiError;
+use crate::types::request::WEB_FETCH_TOOL_HEADER;
+use crate::{config::Config, openai::request::AnthropicRequestExtensions};
use futures::stream::{Stream, StreamExt};
use reqwest::Client as RequestClient;
use reqwest_eventsource::{Event, EventSource, RequestBuilderExt};
@@ -15,8 +17,21 @@ pub struct Client {
}
impl Client {
- pub fn dangerously_try_from_env() -> Self {
- let config = Config::dangrously_try_from_env();
+ pub fn dangerously_try_from_env(extensions: Option<AnthropicRequestExtensions>) -> Self {
+ let mut config = Config::dangrously_try_from_env();
+ if let Some(extensions) = extensions
+ && extensions
+ .0
+ .into_iter()
+ .any(|f| f == AnthropicRequestExtension::FetchTool)
+ {
+ tracing::debug!("Adding web_fetch beta header");
+ config.headers.append(
+ WEB_FETCH_TOOL_HEADER.0.clone(),
+ WEB_FETCH_TOOL_HEADER.1.clone(),
+ );
+ }
+ tracing::debug!("Anthropic client headers: {:?}", config.headers);
Self::with_config(config)
}
}
diff --git a/rust/cloud-storage/anthropic/src/openai/request/request_extension.rs b/rust/cloud-storage/anthropic/src/openai/request/request_extension.rs
index 9d54d16c52..60bd8aaf0f 100644
--- a/rust/cloud-storage/anthropic/src/openai/request/request_extension.rs
+++ b/rust/cloud-storage/anthropic/src/openai/request/request_extension.rs
@@ -1,16 +1,19 @@
-use crate::types::request::WEB_SEARCH_TOOL;
+use crate::{
+ prelude::{ServerTool, WEB_FETCH_TOOL},
+ types::request::WEB_SEARCH_TOOL,
+};
/// Request extensions are functionality that is supported by the anthropic API but not supported by OpenAI/completions/v1
/// These will affect the request sent to anthropic
///
/// Server tools are the main features we need to support that are only supported by anthropic but not OpenAI
-#[derive(Clone, Debug, Copy)]
+#[derive(Clone, Debug, Copy, PartialEq, Eq)]
pub enum AnthropicRequestExtension {
/// <https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool>
WebSearchTool,
// https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-fetch-tool
- // FetchTool,
+ FetchTool,
}
#[derive(Clone, Debug)]
@@ -28,22 +31,25 @@ impl AnthropicRequestExtensions {
}
}
+fn add_tool(tool: ServerTool, request: &mut crate::types::request::CreateMessageRequestBody) {
+ if let Some(ref mut tools) = request.tools {
+ let search = tool.into();
+ if !tools.iter().any(|t| t == &search) {
+ tools.push(search);
+ }
+ } else {
+ request.tools = Some(vec![tool.into()])
+ }
+}
+
impl AnthropicRequestExtension {
pub(crate) fn extend_request(
&self,
request: &mut crate::types::request::CreateMessageRequestBody,
) {
match self {
- Self::WebSearchTool => {
- if let Some(ref mut tools) = request.tools {
- let search = WEB_SEARCH_TOOL.clone().into();
- if !tools.iter().any(|t| t == &search) {
- tools.push(search);
- }
- } else {
- request.tools = Some(vec![WEB_SEARCH_TOOL.clone().into()])
- }
- }
+ Self::WebSearchTool => add_tool(WEB_SEARCH_TOOL.clone(), request),
+ Self::FetchTool => add_tool(WEB_FETCH_TOOL.clone(), request),
}
}
}
diff --git a/rust/cloud-storage/anthropic/src/openai/stream_extension.rs b/rust/cloud-storage/anthropic/src/openai/stream_extension.rs
index 6cce2e146e..ef4eaf4126 100644
--- a/rust/cloud-storage/anthropic/src/openai/stream_extension.rs
+++ b/rust/cloud-storage/anthropic/src/openai/stream_extension.rs
@@ -1,5 +1,6 @@
use crate::prelude::ServerToolUse;
use crate::types::response::Citation;
+use crate::types::response::web_fetch::WebFetchResponse;
use crate::types::response::web_search::WebSearchResponse;
use async_openai::error::OpenAIError;
use async_openai::types::CreateChatCompletionStreamResponse;
@@ -11,6 +12,7 @@ use std::pin::Pin;
pub enum AnthropicResponseExtension {
Citation(Citation),
WebSearchToolResponse(WebSearchResponse),
+ WebFetchToolResponse(WebFetchResponse),
ServerToolUse(ServerToolUse),
}
diff --git a/rust/cloud-storage/anthropic/src/openai/stream_response.rs b/rust/cloud-storage/anthropic/src/openai/stream_response.rs
index f4f78e18c1..a5d6e7feab 100644
--- a/rust/cloud-storage/anthropic/src/openai/stream_response.rs
+++ b/rust/cloud-storage/anthropic/src/openai/stream_response.rs
@@ -3,7 +3,7 @@ use super::stream_extension::{ExtendedAnthropicStreamItem, ExtendedStream};
use crate::client::chat::MessageCompletionResponseStream;
use crate::error::AnthropicError;
use crate::openai::stream_extension::AnthropicResponseExtension;
-use crate::prelude::ServerToolUse;
+use crate::prelude::{ServerToolUse, transform_request_web_fetch};
use crate::types::response::{ContentDeltaEvent, StopReason, StreamEvent, Usage};
use crate::{client::chat::Chat, prelude::CreateMessageRequestBody};
use async_openai::error::{ApiError, OpenAIError};
@@ -207,6 +207,9 @@ fn map_stream_extended(mut stream: MessageCompletionResponseStream) -> ExtendedS
ContentDeltaEvent::WebSearchToolResult(web_search_response) => {
yield Ok(AnthropicResponseExtension::WebSearchToolResponse(web_search_response).into());
}
+ ContentDeltaEvent::WebFetchToolResult(web_fetch_response) => {
+ yield Ok(AnthropicResponseExtension::WebFetchToolResponse(web_fetch_response).into());
+ }
_ => {}
}
// Skip content block start events
@@ -222,6 +225,9 @@ fn map_stream_extended(mut stream: MessageCompletionResponseStream) -> ExtendedS
ContentDeltaEvent::WebSearchToolResult(web_search_response) => {
yield Ok(AnthropicResponseExtension::WebSearchToolResponse(web_search_response).into());
}
+ ContentDeltaEvent::WebFetchToolResult(web_fetch_response) => {
+ yield Ok(AnthropicResponseExtension::WebFetchToolResponse(web_fetch_response).into());
+ }
ContentDeltaEvent::TextDelta { text } | ContentDeltaEvent::StartTextDelta { text } => {
yield Ok(create_response(
&message_id.clone().unwrap_or_default(),
@@ -364,6 +370,7 @@ impl<'c> Chat<'c> {
{
let mut request = request.into();
request.stream = Some(true);
+ let request = transform_request_web_fetch(request);
self.create_stream_openai_unchecked(request).await
}
@@ -379,6 +386,7 @@ impl<'c> Chat<'c> {
let mut request = request.into();
request.stream = Some(true);
let request = extensions.extend_request(request);
+ let request = transform_request_web_fetch(request);
self.create_stream_extended_unchecked(request).await
}
diff --git a/rust/cloud-storage/anthropic/src/types/request/server_tools.rs b/rust/cloud-storage/anthropic/src/types/request/server_tools.rs
index dcaa1d22a5..ce9b6725c3 100644
--- a/rust/cloud-storage/anthropic/src/types/request/server_tools.rs
+++ b/rust/cloud-storage/anthropic/src/types/request/server_tools.rs
@@ -1,5 +1,7 @@
use super::types::ServerTool;
+use crate::types::request::*;
use lazy_static::lazy_static;
+use regex::{Captures, Regex};
use serde_json::Value;
lazy_static! {
@@ -8,4 +10,62 @@ lazy_static! {
r#type: "web_search_20250305".into(),
args: Value::Null,
};
+ pub static ref WEB_FETCH_TOOL: ServerTool = ServerTool {
+ name: "web_fetch".into(),
+ r#type: "web_fetch_20250910".into(),
+ args: Value::Null,
+ };
+}
+
+pub static WEB_FETCH_TOOL_HEADER: (reqwest::header::HeaderName, reqwest::header::HeaderValue) = (
+ reqwest::header::HeaderName::from_static("anthropic-beta"),
+ reqwest::header::HeaderValue::from_static("web-fetch-2025-09-10"),
+);
+
+lazy_static! {
+ static ref re: Regex = Regex::new("<m-link>(.+?)</m-link>").expect("link-regex");
+}
+
+fn replace_links(s: String) -> String {
+ re.replace_all(&s, |caps: &Captures| {
+ let json_str = &caps[1];
+ serde_json::from_str::<serde_json::Value>(json_str)
+ .ok()
+ .and_then(|v| v.get("url")?.as_str().map(String::from))
+ .unwrap_or_else(|| caps[0].to_string())
+ })
+ .into_owned()
+}
+
+// yes this is a compute virus
+pub(crate) fn transform_request_web_fetch(
+ mut request: CreateMessageRequestBody,
+) -> CreateMessageRequestBody {
+ request.messages = request
+ .messages
+ .into_iter()
+ .map(|mut message| {
+ message.content = match message.content {
+ RequestContent::Text(t) => RequestContent::Text(replace_links(t)),
+ RequestContent::Blocks(b) => RequestContent::Blocks(
+ b.into_iter()
+ .map(|b| match b {
+ RequestContentKind::Text {
+ text,
+ cache_control,
+ citations,
+ } => RequestContentKind::Text {
+ text: replace_links(text),
+ cache_control,
+ citations,
+ },
+ other => other,
+ })
+ .collect(),
+ ),
+ };
+ message
+ })
+ .collect();
+ request
}
diff --git a/rust/cloud-storage/anthropic/src/types/response/mod.rs b/rust/cloud-storage/anthropic/src/types/response/mod.rs
index c3188b71a1..1f4a966850 100644
--- a/rust/cloud-storage/anthropic/src/types/response/mod.rs
+++ b/rust/cloud-storage/anthropic/src/types/response/mod.rs
@@ -1,5 +1,8 @@
mod stream_types;
+#[cfg(test)]
+mod test;
mod types;
+pub mod web_fetch;
pub mod web_search;
pub use stream_types::*;
diff --git a/rust/cloud-storage/anthropic/src/types/response/stream_types.rs b/rust/cloud-storage/anthropic/src/types/response/stream_types.rs
index a92d91593d..3af0d29699 100644
--- a/rust/cloud-storage/anthropic/src/types/response/stream_types.rs
+++ b/rust/cloud-storage/anthropic/src/types/response/stream_types.rs
@@ -1,5 +1,6 @@
use crate::prelude::ServerToolUse;
+use super::web_fetch::WebFetchResponse;
use super::web_search::WebSearchResponse;
use super::{MessageResponse, Usage};
@@ -69,6 +70,7 @@ pub enum ContentDeltaEvent {
citation: Citation,
},
WebSearchToolResult(WebSearchResponse),
+ WebFetchToolResult(WebFetchResponse),
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
diff --git a/rust/cloud-storage/anthropic/src/types/response/test.rs b/rust/cloud-storage/anthropic/src/types/response/test.rs
new file mode 100644
index 0000000000..48f50d4a39
--- /dev/null
+++ b/rust/cloud-storage/anthropic/src/types/response/test.rs
@@ -0,0 +1,87 @@
+use super::web_fetch::*;
+
+#[test]
+fn test_deserialize_web_fetch_result() {
+ let json = r#"{
+ "tool_use_id": "srvtoolu_01234567890abcdef",
+ "content": {
+ "type": "web_fetch_result",
+ "url": "https://example.com/article",
+ "content": {
+ "source": {
+ "type": "text",
+ "media_type": "text/plain",
+ "data": "Full text content of the article..."
+ },
+ "title": "Article Title",
+ "citations": {"enabled": true}
+ },
+ "retrieved_at": "2025-08-25T10:30:00Z"
+ }
+ }"#;
+
+ let result: WebFetchResponse = serde_json::from_str(json).expect("deserialize");
+ assert_eq!(result.tool_use_id, "srvtoolu_01234567890abcdef");
+ if let WebFetchContent::WebFetchResult(r) = result.content {
+ assert_eq!(r.url, "https://example.com/article");
+ assert_eq!(r.content.title, Some("Article Title".to_string()));
+ } else {
+ panic!("Expected WebFetchResult");
+ }
+}
+
+#[test]
+fn test_deserialize_web_fetch_pdf() {
+ let json = r#"{
+ "tool_use_id": "srvtoolu_02",
+ "content": {
+ "type": "web_fetch_result",
+ "url": "https://example.com/paper.pdf",
+ "content": {
+ "source": {
+ "type": "base64",
+ "media_type": "application/pdf",
+ "data": "JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmo..."
+ },
+ "citations": {"enabled": true}
+ },
+ "retrieved_at": "2025-08-25T10:30:02Z"
+ }
+ }"#;
+
+ let result: WebFetchResponse = serde_json::from_str(json).expect("deserialize");
+ if let WebFetchContent::WebFetchResult(r) = result.content {
+ if let WebFetchSource::Base64 { media_type, .. } = r.content.source {
+ assert_eq!(media_type, "application/pdf");
+ } else {
+ panic!("Expected Base64 source");
+ }
+ } else {
+ panic!("Expected WebFetchResult");
+ }
+}
+
+#[test]
+fn test_deserialize_web_fetch_error() {
+ let json = r#"{
+ "tool_use_id": "srvtoolu_a93jad",
+ "content": {
+ "type": "web_fetch_tool_result_error",
+ "error_code": "url_not_accessible"
+ }
+ }"#;
+
+ let result: WebFetchResponse = serde_json::from_str(json).expect("deserialize");
+ if let WebFetchContent::WebFetchToolError(e) = result.content {
+ assert_eq!(e.error_code, WebFetchErrorCode::UrlNotAccessible);
+ } else {
+ panic!("Expected WebFetchToolError");
+ }
+}
+
+#[test]
+fn test_deserialize_tool_call() {
+ let json = r#"{"url": "https://example.com/article"}"#;
+ let call: WebFetchToolCall = serde_json::from_str(json).expect("deserialize");
+ assert_eq!(call.url, "https://example.com/article");
+}
diff --git a/rust/cloud-storage/anthropic/src/types/response/web_fetch.rs b/rust/cloud-storage/anthropic/src/types/response/web_fetch.rs
new file mode 100644
index 0000000000..cfe4efd2a8
--- /dev/null
+++ b/rust/cloud-storage/anthropic/src/types/response/web_fetch.rs
@@ -0,0 +1,93 @@
+use schemars::JsonSchema;
+use serde::{Deserialize, Serialize};
+
+/// Web fetch tool response content returned by Claude when using the web_fetch tool
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub struct WebFetchResponse {
+ pub tool_use_id: String,
+ pub content: WebFetchContent,
+}
+
+/// Content of a web fetch response - either a successful result or an error
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
+#[serde(tag = "type", rename_all = "snake_case")]
+pub enum WebFetchContent {
+ WebFetchResult(WebFetchResult),
+ #[serde(rename = "web_fetch_tool_result_error")]
+ WebFetchToolError(WebFetchToolError),
+}
+
+/// Successful web fetch result containing the fetched content
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
+pub struct WebFetchResult {
+ /// The URL that was fetched
+ pub url: String,
+ /// The fetched document content
+ pub content: WebFetchDocument,
+ /// Timestamp when the content was retrieved
+ pub retrieved_at: String,
+}
+
+/// Document content from a web fetch
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
+pub struct WebFetchDocument {
+ /// The source content (text or base64)
+ pub source: WebFetchSource,
+ /// Optional title of the document
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub title: Option<String>,
+ /// Optional citations configuration
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub citations: Option<CitationsConfig>,
+}
+
+/// Source content of a fetched document
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
+#[serde(tag = "type", rename_all = "snake_case")]
+pub enum WebFetchSource {
+ /// Plain text content
+ Text { media_type: String, data: String },
+ /// Base64-encoded content (e.g., PDF)
+ Base64 { media_type: String, data: String },
+}
+
+/// Citations configuration for web fetch
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
+pub struct CitationsConfig {
+ pub enabled: bool,
+}
+
+/// Error returned when web fetch fails
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
+pub struct WebFetchToolError {
+ pub error_code: WebFetchErrorCode,
+}
+
+/// Possible error codes for web fetch failures
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum WebFetchErrorCode {
+ /// Invalid URL format
+ InvalidInput,
+ /// URL exceeds maximum length (250 characters)
+ UrlTooLong,
+ /// URL blocked by domain filtering rules and model restrictions
+ UrlNotAllowed,
+ /// Failed to fetch content (HTTP error)
+ UrlNotAccessible,
+ /// Rate limit exceeded
+ TooManyRequests,
+ /// Content type not supported (only text and PDF)
+ UnsupportedContentType,
+ /// Maximum web fetch tool uses exceeded
+ MaxUsesExceeded,
+ /// An internal error occurred
+ Unavailable,
+}
+
+/// The expected shape of the streamed JSON following a `server_tool_use` in content_block_start event
+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
+pub struct WebFetchToolCall {
+ pub url: String,
+}
diff --git a/rust/cloud-storage/document_cognition_service/schemas/tools.json b/rust/cloud-storage/document_cognition_service/schemas/tools.json
index 260faba6c6..036529fdfe 100644
--- a/rust/cloud-storage/document_cognition_service/schemas/tools.json
+++ b/rust/cloud-storage/document_cognition_service/schemas/tools.json
@@ -1,424 +1,162 @@
{
"schemas": [
{
- "name": "Read",
+ "name": "ContentSearch",
"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.",
+ "description": "Search for items by their content. For documents, this searches the document body text. For emails, this searches the email message body. For chats, this searches the message content. This tool finds items based on what's inside them, not their titles or names.",
"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",
- "project"
- ],
- "type": "string"
- },
- "ids": {
+ "entityTypes": {
"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.",
+ "default": [],
+ "description": "Which types of items to search. Leave empty to search all types. Examples: ['documents'], ['emails', 'documents'], ['channels']",
"items": {
"additionalProperties": false,
+ "enum": [
+ "documents",
+ "chats",
+ "emails",
+ "channels",
+ "projects"
+ ],
"type": "string"
},
"type": "array"
},
- "messagesSince": {
+ "query": {
"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"
- ]
+ "description": "The text content to search for. This searches within the body of documents, emails, and messages.",
+ "type": "string"
}
},
"required": [
- "contentType",
- "ids",
- "messagesSince"
+ "entityTypes",
+ "query"
],
- "title": "Read",
+ "title": "ContentSearch",
"type": "object"
},
"outputSchema": {
"properties": {
- "content": {
- "oneOf": [
- {
- "properties": {
- "documents": {
- "items": {
- "properties": {
- "formattedDocument": {
- "type": "string"
- }
- },
- "required": [
- "formattedDocument"
- ],
- "type": "object"
+ "results": {
+ "items": {
+ "oneOf": [
+ {
+ "description": "DocumentSearchResponseItem object with document metadata we fetch from macrodb. we don't store these\ntimestamps in opensearch as they would require us to update document page record\nevery time the document updates (specifically for updated_at and viewed_at)",
+ "properties": {
+ "document_id": {
+ "description": "The id of the document",
+ "format": "uuid",
+ "type": "string"
},
- "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": {
- "properties": {
- "chat_id": {
- "type": "string"
- },
- "messages": {
- "items": {
+ "document_name": {
+ "description": "The name of the document",
+ "type": "string"
+ },
+ "document_search_results": {
+ "description": "The search results for the document\nThis may be empty if the search result match was on the document name only",
+ "items": {
+ "description": "A document match for a given node",
+ "properties": {
+ "highlight": {
+ "description": "The highlights for the document",
"properties": {
- "attachmentIds": {
+ "bcc": {
+ "description": "The highlight match on the bcc (email only)",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "cc": {
+ "description": "The highlight match on the cc (email only)",
"items": {
"type": "string"
},
"type": "array"
},
"content": {
- "type": "string"
+ "description": "The highlight match on the content field",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
},
- "date": {
- "format": "date-time",
- "type": "string"
+ "name": {
+ "description": "The highlight match on the name field",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "recipients": {
+ "description": "The highlight match on the recipients (email only)",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "sender": {
+ "description": "The highlight match on the sender (email only)",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "user_id": {
+ "description": "The highlight match on the user (owner) of the entity",
+ "type": [
+ "string",
+ "null"
+ ]
}
},
- "required": [
- "content",
- "date",
- "attachmentIds"
- ],
"type": "object"
},
- "type": "array"
+ "node_id": {
+ "description": "The node id for the document.\nThis is only useful for markdown at the moment\nThis will only be provided if the match was on content",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "raw_content": {
+ "description": "The raw content of the document.\nThis is only included for markdown files and will be the raw json node of the match",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "score": {
+ "description": "The score of the result",
+ "format": "double",
+ "type": [
+ "number",
+ "null"
+ ]
+ }
},
- "title": {
- "type": "string"
- }
+ "required": [
+ "highlight"
+ ],
+ "type": "object"
},
- "required": [
- "chat_id",
- "title",
- "messages"
- ],
- "type": "object"
+ "type": "array"
},
- "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": [
- "content"
- ],
- "title": "ReadResponse",
- "type": "object"
- }
- },
- {
- "name": "NameSearch",
- "inputSchema": {
- "additionalProperties": false,
- "description": "Search for items by their name or title. For documents, this searches the document name. For emails, this searches the subject line. For chats, this searches the chat title. For projects (folders), this searches the project name. This tool finds items based on what they're called, not their content.",
- "properties": {
- "entityTypes": {
- "additionalProperties": false,
- "default": [],
- "description": "Which types of items to search. Leave empty to search all types. Examples: ['documents'], ['emails', 'documents'], ['channels']",
- "items": {
- "additionalProperties": false,
- "enum": [
- "documents",
- "chats",
- "emails",
- "channels",
- "projects"
- ],
- "type": "string"
- },
- "type": "array"
- },
- "name": {
- "additionalProperties": false,
- "description": "The name or title to search for. For emails, this is the subject line. For channels, this can be the channel name or participant names.",
- "type": "string"
- }
- },
- "required": [
- "entityTypes",
- "name"
- ],
- "title": "NameSearch",
- "type": "object"
- },
- "outputSchema": {
- "properties": {
- "results": {
- "items": {
- "oneOf": [
- {
- "description": "DocumentSearchResponseItem object with document metadata we fetch from macrodb. we don't store these\ntimestamps in opensearch as they would require us to update document page record\nevery time the document updates (specifically for updated_at and viewed_at)",
- "properties": {
- "document_id": {
- "description": "The id of the document",
- "format": "uuid",
- "type": "string"
- },
- "document_name": {
- "description": "The name of the document",
- "type": "string"
- },
- "document_search_results": {
- "description": "The search results for the document\nThis may be empty if the search result match was on the document name only",
- "items": {
- "description": "A document match for a given node",
- "properties": {
- "highlight": {
- "description": "The highlights for the document",
- "properties": {
- "bcc": {
- "description": "The highlight match on the bcc (email only)",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "cc": {
- "description": "The highlight match on the cc (email only)",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "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"
- ]
- },
- "recipients": {
- "description": "The highlight match on the recipients (email only)",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "sender": {
- "description": "The highlight match on the sender (email only)",
- "type": [
- "string",
- "null"
- ]
- },
- "user_id": {
- "description": "The highlight match on the user (owner) of the entity",
- "type": [
- "string",
- "null"
- ]
- }
- },
- "type": "object"
- },
- "node_id": {
- "description": "The node id for the document.\nThis is only useful for markdown at the moment\nThis will only be provided if the match was on content",
- "type": [
- "string",
- "null"
- ]
- },
- "raw_content": {
- "description": "The raw content of the document.\nThis is only included for markdown files and will be the raw json node of the match",
- "type": [
- "string",
- "null"
- ]
- },
- "score": {
- "description": "The score of the result",
- "format": "double",
- "type": [
- "number",
- "null"
- ]
- }
- },
- "required": [
- "highlight"
- ],
- "type": "object"
- },
- "type": "array"
- },
- "file_type": {
- "description": "The file type of the document",
- "type": [
- "string",
- "null"
- ]
- },
- "id": {
- "description": "Standardized fields that all item types will share.\nThese field names are being aligned across all item types\nfor consistency in our data model.",
- "format": "uuid",
- "type": "string"
- },
- "metadata": {
- "description": "Metadata from the database. None if the document doesn't exist in the database.",
+ "file_type": {
+ "description": "The file type of the document",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "id": {
+ "description": "Standardized fields that all item types will share.\nThese field names are being aligned across all item types\nfor consistency in our data model.",
+ "format": "uuid",
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Metadata from the database. None if the document doesn't exist in the database.",
"properties": {
"created_at": {
"format": "int64",
@@ -1228,641 +966,799 @@
}
},
{
- "name": "ContentSearch",
+ "name": "MarkdownRewrite",
"inputSchema": {
"additionalProperties": false,
- "description": "Search for items by their content. For documents, this searches the document body text. For emails, this searches the email message body. For chats, this searches the message content. This tool finds items based on what's inside them, not their titles or names.",
+ "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": {
- "entityTypes": {
+ "instructions": {
"additionalProperties": false,
- "default": [],
- "description": "Which types of items to search. Leave empty to search all types. Examples: ['documents'], ['emails', 'documents'], ['channels']",
+ "description": "Instructions for the revision agent to follow to edit the markdown. These instructions will be provided by the user.",
+ "type": "string"
+ },
+ "markdown_file_id": {
+ "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"
+ }
+ },
+ "required": [
+ "instructions",
+ "markdown_file_id"
+ ],
+ "title": "MarkdownRewrite",
+ "type": "object"
+ },
+ "outputSchema": {
+ "additionalProperties": false,
+ "properties": {
+ "diffs": {
"items": {
"additionalProperties": false,
- "enum": [
- "documents",
- "chats",
- "emails",
- "channels",
- "projects"
+ "properties": {
+ "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": "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",
+ "project"
+ ],
+ "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"
},
- "query": {
+ "messagesSince": {
"additionalProperties": false,
- "description": "The text content to search for. This searches within the body of documents, emails, and messages.",
- "type": "string"
+ "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"
+ ]
}
},
"required": [
- "entityTypes",
- "query"
+ "contentType",
+ "ids",
+ "messagesSince"
],
- "title": "ContentSearch",
+ "title": "Read",
"type": "object"
},
"outputSchema": {
"properties": {
- "results": {
- "items": {
- "oneOf": [
- {
- "description": "DocumentSearchResponseItem object with document metadata we fetch from macrodb. we don't store these\ntimestamps in opensearch as they would require us to update document page record\nevery time the document updates (specifically for updated_at and viewed_at)",
- "properties": {
- "document_id": {
- "description": "The id of the document",
- "format": "uuid",
- "type": "string"
- },
- "document_name": {
- "description": "The name of the document",
- "type": "string"
+ "content": {
+ "oneOf": [
+ {
+ "properties": {
+ "documents": {
+ "items": {
+ "properties": {
+ "formattedDocument": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "formattedDocument"
+ ],
+ "type": "object"
},
- "document_search_results": {
- "description": "The search results for the document\nThis may be empty if the search result match was on the document name only",
- "items": {
- "description": "A document match for a given node",
- "properties": {
- "highlight": {
- "description": "The highlights for the document",
+ "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": {
+ "properties": {
+ "chat_id": {
+ "type": "string"
+ },
+ "messages": {
+ "items": {
"properties": {
- "bcc": {
- "description": "The highlight match on the bcc (email only)",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "cc": {
- "description": "The highlight match on the cc (email only)",
+ "attachmentIds": {
"items": {
"type": "string"
},
"type": "array"
},
"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"
- ]
- },
- "recipients": {
- "description": "The highlight match on the recipients (email only)",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "sender": {
- "description": "The highlight match on the sender (email only)",
- "type": [
- "string",
- "null"
- ]
+ "type": "string"
},
- "user_id": {
- "description": "The highlight match on the user (owner) of the entity",
- "type": [
- "string",
- "null"
- ]
+ "date": {
+ "format": "date-time",
+ "type": "string"
}
},
+ "required": [
+ "content",
+ "date",
+ "attachmentIds"
+ ],
"type": "object"
},
- "node_id": {
- "description": "The node id for the document.\nThis is only useful for markdown at the moment\nThis will only be provided if the match was on content",
- "type": [
- "string",
- "null"
- ]
- },
- "raw_content": {
- "description": "The raw content of the document.\nThis is only included for markdown files and will be the raw json node of the match",
- "type": [
- "string",
- "null"
- ]
- },
- "score": {
- "description": "The score of the result",
- "format": "double",
- "type": [
- "number",
- "null"
- ]
- }
+ "type": "array"
},
- "required": [
- "highlight"
- ],
- "type": "object"
+ "title": {
+ "type": "string"
+ }
},
- "type": "array"
- },
- "file_type": {
- "description": "The file type of the document",
- "type": [
- "string",
- "null"
- ]
- },
- "id": {
- "description": "Standardized fields that all item types will share.\nThese field names are being aligned across all item types\nfor consistency in our data model.",
- "format": "uuid",
- "type": "string"
+ "required": [
+ "chat_id",
+ "title",
+ "messages"
+ ],
+ "type": "object"
},
- "metadata": {
- "description": "Metadata from the database. None if the document doesn't exist in the database.",
+ "type": "array"
+ },
+ "type": {
+ "const": "chat",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "conversation"
+ ],
+ "type": "object"
+ },
+ {
+ "properties": {
+ "messages": {
+ "items": {
"properties": {
- "created_at": {
- "format": "int64",
- "type": "integer"
+ "bcc": {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
},
- "deleted_at": {
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
+ "cc": {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
},
- "project_id": {
- "type": [
- "string",
- "null"
- ]
+ "content": {
+ "type": "string"
},
- "updated_at": {
- "format": "int64",
- "type": "integer"
+ "messageId": {
+ "type": "string"
},
- "viewed_at": {
- "format": "int64",
+ "recipients": {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "sender": {
+ "type": "string"
+ },
+ "sentAt": {
+ "format": "date-time",
"type": [
- "integer",
+ "string",
"null"
]
}
},
"required": [
- "created_at",
- "updated_at"
- ],
- "type": [
- "object",
- "null"
- ]
- },
- "name": {
- "type": "string"
- },
- "owner_id": {
- "type": "string"
- },
- "sub_type": {
- "anyOf": [
- {
- "description": "The document sub type enum represents all values of document sub types.\nThese values should match the `document_sub_type_value` table in macrodb.",
- "oneOf": [
- {
- "const": "task",
- "description": "A task document",
- "type": "string"
- }
- ]
- },
- {
- "type": "null"
- }
+ "messageId",
+ "sender",
+ "recipients",
+ "cc",
+ "bcc",
+ "content"
],
- "description": "The sub type of the document if present."
+ "type": "object"
},
- "type": {
- "const": "document",
- "type": "string"
- }
+ "type": "array"
},
- "required": [
- "type",
- "id",
- "name",
- "owner_id",
- "document_id",
- "document_name",
- "document_search_results"
- ],
- "type": "object"
+ "subject": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "thread_id": {
+ "type": "string"
+ },
+ "type": {
+ "const": "email",
+ "type": "string"
+ }
},
- {
- "description": "ChatSearchResponse object with channel metadata we fetch from macrodb. we don't store these\ntimestamps in opensearch as they would require us to update each chat message record for the chat\nevery time the chat updates (specifically for updated_at and viewed_at)",
- "properties": {
- "chat_id": {
- "description": "The id of the chat",
- "format": "uuid",
- "type": "string"
- },
- "chat_search_results": {
- "description": "The search results for the chat\nThis may be empty if the search result match was on the chat title only",
- "items": {
- "description": "A chat match for a given message id",
- "properties": {
- "chat_message_id": {
- "description": "The chat message id for the chat\nThis is only present if the search match was on the chat message content",
- "format": "uuid",
- "type": [
- "string",
- "null"
- ]
- },
- "highlight": {
- "description": "The highlights for the chat message",
- "properties": {
- "bcc": {
- "description": "The highlight match on the bcc (email only)",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "cc": {
- "description": "The highlight match on the cc (email only)",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "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"
- ]
- },
- "recipients": {
- "description": "The highlight match on the recipients (email only)",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "sender": {
- "description": "The highlight match on the sender (email only)",
- "type": [
- "string",
- "null"
- ]
- },
- "user_id": {
- "description": "The highlight match on the user (owner) of the entity",
- "type": [
- "string",
- "null"
- ]
- }
- },
- "type": "object"
- },
- "role": {
- "description": "The role of the chat message\nThis is only present if the search match was on the chat message content",
- "type": [
- "string",
- "null"
- ]
- },
- "score": {
- "description": "The score of the result",
- "format": "double",
- "type": [
- "number",
- "null"
- ]
- }
- },
- "required": [
- "highlight"
- ],
- "type": "object"
- },
- "type": "array"
- },
- "id": {
- "description": "Standardized fields that all item types will share.\nThese field names are being aligned across all item types\nfor consistency in our data model.",
- "format": "uuid",
- "type": "string"
- },
- "metadata": {
- "description": "Metadata from the database. None if the chat doesn't exist in the database.",
- "properties": {
- "created_at": {
- "format": "int64",
- "type": "integer"
- },
- "deleted_at": {
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
- },
- "project_id": {
- "type": [
- "string",
- "null"
- ]
- },
- "updated_at": {
- "format": "int64",
- "type": "integer"
- },
- "viewed_at": {
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
- }
- },
- "required": [
- "created_at",
- "updated_at"
- ],
- "type": [
- "object",
- "null"
- ]
- },
- "name": {
- "type": "string"
- },
- "owner_id": {
- "type": "string"
- },
- "type": {
- "const": "chat",
- "type": "string"
- },
- "user_id": {
- "description": "The id of the creator of the chat",
- "type": "string"
- }
+ "required": [
+ "type",
+ "thread_id",
+ "messages"
+ ],
+ "type": "object"
+ },
+ {
+ "properties": {
+ "formatted_preview": {
+ "type": "string"
},
- "required": [
- "type",
- "id",
- "name",
- "owner_id",
- "chat_id",
- "user_id",
- "chat_search_results"
- ],
- "type": "object"
+ "type": {
+ "const": "itemPreviews",
+ "type": "string"
+ }
},
- {
- "description": "EmailSearchResponseItem object with email metadata we fetch from email service. we don't store these\ntimestamps in opensearch as they would require us to update each email message record for the thread\nevery time the thread updates (specifically for updated_at and viewed_at)",
- "properties": {
- "created_at": {
- "format": "int64",
- "type": "integer"
- },
- "email_message_search_results": {
- "description": "The search results for the document\nThis may be empty if the search result match was on the email subject only",
- "items": {
- "description": "A email message match for a given thread id",
- "properties": {
- "bcc": {
- "description": "This is only present if the search result is on the message content",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "cc": {
- "description": "This is only present if the search result is on the message content",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "highlight": {
- "description": "The highlights for the email message",
- "properties": {
- "bcc": {
- "description": "The highlight match on the bcc (email only)",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "cc": {
- "description": "The highlight match on the cc (email only)",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "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"
- ]
- },
- "recipients": {
- "description": "The highlight match on the recipients (email only)",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "sender": {
- "description": "The highlight match on the sender (email only)",
- "type": [
- "string",
- "null"
- ]
- },
- "user_id": {
- "description": "The highlight match on the user (owner) of the entity",
- "type": [
- "string",
- "null"
- ]
- }
- },
- "type": "object"
- },
- "labels": {
- "description": "This is only present if the search result is on the message content",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "message_id": {
- "description": "The email message id.\nThis is only present if the search result is on the message content",
- "format": "uuid",
- "type": [
- "string",
- "null"
- ]
- },
- "pretty_sender": {
- "description": "The pretty sender.\nIf the match is on the subject, the pretty sender is the latest sender on the thread.\nThis could be the sender's email if there is no contact name for the sender.",
- "type": "string"
- },
- "recipients": {
- "description": "This is only present if the search result is on the message content",
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- "score": {
- "description": "The score of the result",
- "format": "double",
- "type": [
- "number",
- "null"
- ]
- },
- "sender": {
- "description": "The sender.\nIf the match is on the subject, the sender is the latest sender on the thread.",
- "type": "string"
- },
- "sent_at": {
- "description": "When the email message was sent\nThis is only present if the search result is on the message content",
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
- }
- },
- "required": [
- "sender",
- "pretty_sender",
- "recipients",
- "cc",
- "bcc",
- "labels",
- "highlight"
- ],
- "type": "object"
+ "required": [
+ "type",
+ "formatted_preview"
+ ],
+ "type": "object"
+ }
+ ]
+ }
+ },
+ "required": [
+ "content"
+ ],
+ "title": "ReadResponse",
+ "type": "object"
+ }
+ },
+ {
+ "name": "ListEmails",
+ "inputSchema": {
+ "additionalProperties": false,
+ "description": "List the emails the user has access to. Use this tool to find all emails from / to a specific person. Prefer using the search tool to search on a specific matching string within the content or the name of the entity.",
+ "properties": {
+ "cursor": {
+ "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"
+ ]
+ },
+ "limit": {
+ "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"
+ ],
+ "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"
+ ],
+ "title": "ListEmails",
+ "type": "object"
+ },
+ "outputSchema": {
+ "properties": {
+ "items": {
+ "items": {
+ "properties": {
+ "attachments": {
+ "items": {
+ "properties": {
+ "contentId": {
+ "type": [
+ "string",
+ "null"
+ ]
},
- "type": "array"
- },
- "id": {
- "description": "Standardized fields that all item types will share.\nThese field names are being aligned across all item types\nfor consistency in our data model.",
- "format": "uuid",
- "type": "string"
- },
- "name": {
- "description": "Subject of the email thread",
- "type": [
- "string",
- "null"
- ]
- },
- "owner_id": {
- "type": "string"
+ "createdAt": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "filename": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "id": {
+ "format": "uuid",
+ "type": "string"
+ },
+ "messageId": {
+ "format": "uuid",
+ "type": "string"
+ },
+ "mimeType": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "providerAttachmentId": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "sizeBytes": {
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
},
- "snippet": {
- "type": [
- "string",
- "null"
- ]
+ "required": [
+ "id",
+ "messageId",
+ "createdAt"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "contacts": {
+ "items": {
+ "properties": {
+ "emailAddress": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "id": {
+ "format": "uuid",
+ "type": "string"
+ },
+ "linkId": {
+ "format": "uuid",
+ "type": "string"
+ },
+ "name": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "sfsPhotoUrl": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
},
- "subject": {
- "description": "The subject of the email\nThis is only present if the search result is on the message content",
- "type": [
- "string",
- "null"
- ]
+ "required": [
+ "id",
+ "linkId"
+ ],
+ "type": "object"
+ },
+ "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"
+ },
+ "id": {
+ "format": "uuid",
+ "type": "string"
+ },
+ "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"
+ }
},
- "thread_id": {
- "description": "The id of the email thread",
- "format": "uuid",
- "type": "string"
+ "required": [
+ "id",
+ "linkId",
+ "providerLabelId",
+ "name",
+ "createdAt",
+ "messageListVisibility",
+ "labelListVisibility",
+ "type"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "macroAttachments": {
+ "items": {
+ "properties": {
+ "dbId": {
+ "format": "uuid",
+ "type": "string"
+ },
+ "itemId": {
+ "format": "uuid",
+ "type": "string"
+ },
+ "itemType": {
+ "type": "string"
+ },
+ "messageId": {
+ "format": "uuid",
+ "type": "string"
+ }
},
- "type": {
- "const": "email",
- "type": "string"
+ "required": [
+ "dbId",
+ "messageId",
+ "itemId",
+ "itemType"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "metadata": {
+ "properties": {
+ "calendar_invite": {
+ "description": "if any email contains a calendar invite",
+ "type": "boolean"
},
- "updated_at": {
- "format": "int64",
- "type": "integer"
+ "generic_sender": {
+ "description": "if any sender in the thread is a generic email",
+ "type": "boolean"
},
- "user_id": {
- "description": "The id of the owner of the email thread",
- "type": "string"
+ "known_sender": {
+ "description": "if user has previously emailed any sender in the thread",
+ "type": "boolean"
},
- "viewed_at": {
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
+ "tabular": {
+ "description": "if any email contains a <table> html tag",
+ "type": "boolean"
}
},
"required": [
- "type",
- "created_at",
- "updated_at",
- "id",
- "owner_id",
- "thread_id",
- "user_id",
- "email_message_search_results"
+ "known_sender",
+ "tabular",
+ "calendar_invite",
+ "generic_sender"
],
"type": "object"
},
+ "name": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "ownerId": {
+ "type": "string"
+ },
+ "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"
+ },
+ "viewedAt": {
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "id",
+ "ownerId",
+ "inboxVisible",
+ "isRead",
+ "isDraft",
+ "isImportant",
+ "sortTs",
+ "createdAt",
+ "updatedAt",
+ "attachments",
+ "macroAttachments",
+ "contacts",
+ "labels",
+ "metadata"
+ ],
+ "type": "object"
+ },
+ "type": "array"
+ },
+ "next_cursor": {
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "items"
+ ],
+ "title": "ApiPaginatedThreadCursor",
+ "type": "object"
+ }
+ },
+ {
+ "name": "NameSearch",
+ "inputSchema": {
+ "additionalProperties": false,
+ "description": "Search for items by their name or title. For documents, this searches the document name. For emails, this searches the subject line. For chats, this searches the chat title. For projects (folders), this searches the project name. This tool finds items based on what they're called, not their content.",
+ "properties": {
+ "entityTypes": {
+ "additionalProperties": false,
+ "default": [],
+ "description": "Which types of items to search. Leave empty to search all types. Examples: ['documents'], ['emails', 'documents'], ['channels']",
+ "items": {
+ "additionalProperties": false,
+ "enum": [
+ "documents",
+ "chats",
+ "emails",
+ "channels",
+ "projects"
+ ],
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "name": {
+ "additionalProperties": false,
+ "description": "The name or title to search for. For emails, this is the subject line. For channels, this can be the channel name or participant names.",
+ "type": "string"
+ }
+ },
+ "required": [
+ "entityTypes",
+ "name"
+ ],
+ "title": "NameSearch",
+ "type": "object"
+ },
+ "outputSchema": {
+ "properties": {
+ "results": {
+ "items": {
+ "oneOf": [
{
- "description": "ChannelSearchResponseItem object with channel metadata we fetch from macrodb. we don't store these\ntimestamps in opensearch as they would require us to update each chat message record for the chat\nevery time the chat updates (specifically for updated_at and viewed_at and interacted_at)",
+ "description": "DocumentSearchResponseItem object with document metadata we fetch from macrodb. we don't store these\ntimestamps in opensearch as they would require us to update document page record\nevery time the document updates (specifically for updated_at and viewed_at)",
"properties": {
- "channel_id": {
- "description": "The id of the channel",
+ "document_id": {
+ "description": "The id of the document",
"format": "uuid",
"type": "string"
},
- "channel_message_search_results": {
- "description": "The search results for the channel\nThis may be empty if the search result match was not on content",
+ "document_name": {
+ "description": "The name of the document",
+ "type": "string"
+ },
+ "document_search_results": {
+ "description": "The search results for the document\nThis may be empty if the search result match was on the document name only",
"items": {
- "description": "A channel message match for a given channel id",
+ "description": "A document match for a given node",
"properties": {
- "created_at": {
- "description": "When the channel message was created\nThis is only prsent if the search result is on the message content",
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
- },
"highlight": {
- "description": "The highlights for the channel message",
+ "description": "The highlights for the document",
"properties": {
"bcc": {
"description": "The highlight match on the bcc (email only)",
@@ -1916,42 +1812,25 @@
},
"type": "object"
},
- "message_id": {
- "description": "The channel message id\nThis is only prsent if the search result is on the message content",
- "format": "uuid",
- "type": [
- "string",
- "null"
- ]
- },
- "score": {
- "description": "The score of the result",
- "format": "double",
- "type": [
- "number",
- "null"
- ]
- },
- "sender_id": {
- "description": "The sender id\nThis is only prsent if the search result is on the message content",
+ "node_id": {
+ "description": "The node id for the document.\nThis is only useful for markdown at the moment\nThis will only be provided if the match was on content",
"type": [
"string",
"null"
]
},
- "thread_id": {
- "description": "The channel message thread id",
- "format": "uuid",
+ "raw_content": {
+ "description": "The raw content of the document.\nThis is only included for markdown files and will be the raw json node of the match",
"type": [
"string",
"null"
]
},
- "updated_at": {
- "description": "When the channel message was last updated\nThis is only prsent if the search result is on the message content",
- "format": "int64",
+ "score": {
+ "description": "The score of the result",
+ "format": "double",
"type": [
- "integer",
+ "number",
"null"
]
}
@@ -1963,85 +1842,20 @@
},
"type": "array"
},
- "channel_type": {
- "description": "The type of channel",
- "type": "string"
- },
- "id": {
- "description": "Standardized fields that all item types will share.\nThese field names are being aligned across all item types\nfor consistency in our data model.",
- "format": "uuid",
- "type": "string"
- },
- "metadata": {
- "description": "Metadata from the database. None if the channel doesn't exist in the database.",
- "properties": {
- "created_at": {
- "format": "int64",
- "type": "integer"
- },
- "interacted_at": {
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
- },
- "updated_at": {
- "format": "int64",
- "type": "integer"
- },
- "viewed_at": {
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
- }
- },
- "required": [
- "created_at",
- "updated_at"
- ],
- "type": [
- "object",
- "null"
- ]
- },
- "owner_id": {
- "description": "we don't store this for channels atm but keeping it here for consistency",
+ "file_type": {
+ "description": "The file type of the document",
"type": [
"string",
"null"
]
},
- "type": {
- "const": "channel",
- "type": "string"
- }
- },
- "required": [
- "type",
- "id",
- "channel_type",
- "channel_id",
- "channel_message_search_results"
- ],
- "type": "object"
- },
- {
- "description": "ProjectSearchResponseItem object with project metadata we fetch from macrodb. we don't store these\ntimestamps in opensearch as they would require us to update the project record\nevery time the project updates (specifically for updated_at and viewed_at)",
- "properties": {
- "created_at": {
- "format": "int64",
- "type": "integer"
- },
"id": {
"description": "Standardized fields that all item types will share.\nThese field names are being aligned across all item types\nfor consistency in our data model.",
"format": "uuid",
"type": "string"
},
"metadata": {
- "description": "Metadata from the database. None if the project doesn't exist in the database.",
+ "description": "Metadata from the database. None if the document doesn't exist in the database.",
"properties": {
"created_at": {
"format": "int64",
@@ -2054,7 +1868,7 @@
"null"
]
},
- "parent_project_id": {
+ "project_id": {
"type": [
"string",
"null"
@@ -2087,10 +1901,63 @@
"owner_id": {
"type": "string"
},
- "project_search_results": {
+ "sub_type": {
+ "anyOf": [
+ {
+ "description": "The document sub type enum represents all values of document sub types.\nThese values should match the `document_sub_type_value` table in macrodb.",
+ "oneOf": [
+ {
+ "const": "task",
+ "description": "A task document",
+ "type": "string"
+ }
+ ]
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "The sub type of the document if present."
+ },
+ "type": {
+ "const": "document",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "id",
+ "name",
+ "owner_id",
+ "document_id",
+ "document_name",
+ "document_search_results"
+ ],
+ "type": "object"
+ },
+ {
+ "description": "ChatSearchResponse object with channel metadata we fetch from macrodb. we don't store these\ntimestamps in opensearch as they would require us to update each chat message record for the chat\nevery time the chat updates (specifically for updated_at and viewed_at)",
+ "properties": {
+ "chat_id": {
+ "description": "The id of the chat",
+ "format": "uuid",
+ "type": "string"
+ },
+ "chat_search_results": {
+ "description": "The search results for the chat\nThis may be empty if the search result match was on the chat title only",
"items": {
+ "description": "A chat match for a given message id",
"properties": {
+ "chat_message_id": {
+ "description": "The chat message id for the chat\nThis is only present if the search match was on the chat message content",
+ "format": "uuid",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
"highlight": {
+ "description": "The highlights for the chat message",
"properties": {
"bcc": {
"description": "The highlight match on the bcc (email only)",
@@ -2137,530 +2004,663 @@
"user_id": {
"description": "The highlight match on the user (owner) of the entity",
"type": [
- "string",
- "null"
- ]
- }
- },
- "type": "object"
- },
- "score": {
- "description": "The score of the result",
- "format": "double",
- "type": [
- "number",
- "null"
- ]
- }
- },
- "required": [
- "highlight"
- ],
- "type": "object"
- },
- "type": "array"
- },
- "type": {
- "const": "project",
- "type": "string"
- },
- "updated_at": {
- "format": "int64",
- "type": "integer"
- }
- },
- "required": [
- "type",
- "id",
- "name",
- "owner_id",
- "updated_at",
- "created_at",
- "project_search_results"
- ],
- "type": "object"
- }
- ]
- },
- "type": "array"
- }
- },
- "required": [
- "results"
- ],
- "title": "SearchToolResponse",
- "type": "object"
- }
- },
- {
- "name": "MarkdownRewrite",
- "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",
- "properties": {
- "instructions": {
- "additionalProperties": false,
- "description": "Instructions for the revision agent to follow to edit the markdown. These instructions will be provided by the user.",
- "type": "string"
- },
- "markdown_file_id": {
- "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"
- }
- },
- "required": [
- "instructions",
- "markdown_file_id"
- ],
- "title": "MarkdownRewrite",
- "type": "object"
- },
- "outputSchema": {
- "additionalProperties": false,
- "properties": {
- "diffs": {
- "items": {
- "additionalProperties": false,
- "properties": {
- "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": "ListEmails",
- "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.",
- "properties": {
- "cursor": {
- "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"
- ]
- },
- "limit": {
- "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"
- ],
- "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"
- ],
- "title": "ListEmails",
- "type": "object"
- },
- "outputSchema": {
- "properties": {
- "items": {
- "items": {
- "properties": {
- "attachments": {
- "items": {
- "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"
- ]
+ "string",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "role": {
+ "description": "The role of the chat message\nThis is only present if the search match was on the chat message content",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "score": {
+ "description": "The score of the result",
+ "format": "double",
+ "type": [
+ "number",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "highlight"
+ ],
+ "type": "object"
},
- "providerAttachmentId": {
- "type": [
- "string",
- "null"
- ]
+ "type": "array"
+ },
+ "id": {
+ "description": "Standardized fields that all item types will share.\nThese field names are being aligned across all item types\nfor consistency in our data model.",
+ "format": "uuid",
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Metadata from the database. None if the chat doesn't exist in the database.",
+ "properties": {
+ "created_at": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "deleted_at": {
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "project_id": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "updated_at": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "viewed_at": {
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
},
- "sizeBytes": {
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
- }
+ "required": [
+ "created_at",
+ "updated_at"
+ ],
+ "type": [
+ "object",
+ "null"
+ ]
},
- "required": [
- "id",
- "messageId",
- "createdAt"
- ],
- "type": "object"
+ "name": {
+ "type": "string"
+ },
+ "owner_id": {
+ "type": "string"
+ },
+ "type": {
+ "const": "chat",
+ "type": "string"
+ },
+ "user_id": {
+ "description": "The id of the creator of the chat",
+ "type": "string"
+ }
},
- "type": "array"
+ "required": [
+ "type",
+ "id",
+ "name",
+ "owner_id",
+ "chat_id",
+ "user_id",
+ "chat_search_results"
+ ],
+ "type": "object"
},
- "contacts": {
- "items": {
- "properties": {
- "emailAddress": {
- "type": [
- "string",
- "null"
- ]
- },
- "id": {
- "format": "uuid",
- "type": "string"
- },
- "linkId": {
- "format": "uuid",
- "type": "string"
- },
- "name": {
- "type": [
- "string",
- "null"
- ]
+ {
+ "description": "EmailSearchResponseItem object with email metadata we fetch from email service. we don't store these\ntimestamps in opensearch as they would require us to update each email message record for the thread\nevery time the thread updates (specifically for updated_at and viewed_at)",
+ "properties": {
+ "created_at": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "email_message_search_results": {
+ "description": "The search results for the document\nThis may be empty if the search result match was on the email subject only",
+ "items": {
+ "description": "A email message match for a given thread id",
+ "properties": {
+ "bcc": {
+ "description": "This is only present if the search result is on the message content",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "cc": {
+ "description": "This is only present if the search result is on the message content",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "highlight": {
+ "description": "The highlights for the email message",
+ "properties": {
+ "bcc": {
+ "description": "The highlight match on the bcc (email only)",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "cc": {
+ "description": "The highlight match on the cc (email only)",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "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"
+ ]
+ },
+ "recipients": {
+ "description": "The highlight match on the recipients (email only)",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "sender": {
+ "description": "The highlight match on the sender (email only)",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "user_id": {
+ "description": "The highlight match on the user (owner) of the entity",
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "labels": {
+ "description": "This is only present if the search result is on the message content",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "message_id": {
+ "description": "The email message id.\nThis is only present if the search result is on the message content",
+ "format": "uuid",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "pretty_sender": {
+ "description": "The pretty sender.\nIf the match is on the subject, the pretty sender is the latest sender on the thread.\nThis could be the sender's email if there is no contact name for the sender.",
+ "type": "string"
+ },
+ "recipients": {
+ "description": "This is only present if the search result is on the message content",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "score": {
+ "description": "The score of the result",
+ "format": "double",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "sender": {
+ "description": "The sender.\nIf the match is on the subject, the sender is the latest sender on the thread.",
+ "type": "string"
+ },
+ "sent_at": {
+ "description": "When the email message was sent\nThis is only present if the search result is on the message content",
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "sender",
+ "pretty_sender",
+ "recipients",
+ "cc",
+ "bcc",
+ "labels",
+ "highlight"
+ ],
+ "type": "object"
},
- "sfsPhotoUrl": {
- "type": [
- "string",
- "null"
- ]
- }
+ "type": "array"
},
- "required": [
- "id",
- "linkId"
- ],
- "type": "object"
+ "id": {
+ "description": "Standardized fields that all item types will share.\nThese field names are being aligned across all item types\nfor consistency in our data model.",
+ "format": "uuid",
+ "type": "string"
+ },
+ "name": {
+ "description": "Subject of the email thread",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "owner_id": {
+ "type": "string"
+ },
+ "snippet": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "subject": {
+ "description": "The subject of the email\nThis is only present if the search result is on the message content",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "thread_id": {
+ "description": "The id of the email thread",
+ "format": "uuid",
+ "type": "string"
+ },
+ "type": {
+ "const": "email",
+ "type": "string"
+ },
+ "updated_at": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "user_id": {
+ "description": "The id of the owner of the email thread",
+ "type": "string"
+ },
+ "viewed_at": {
+ "format": "int64",
+ "type": [
+ "integer",
+ "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"
+ "required": [
+ "type",
+ "created_at",
+ "updated_at",
+ "id",
+ "owner_id",
+ "thread_id",
+ "user_id",
+ "email_message_search_results"
+ ],
+ "type": "object"
},
- "labels": {
- "items": {
- "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"
+ {
+ "description": "ChannelSearchResponseItem object with channel metadata we fetch from macrodb. we don't store these\ntimestamps in opensearch as they would require us to update each chat message record for the chat\nevery time the chat updates (specifically for updated_at and viewed_at and interacted_at)",
+ "properties": {
+ "channel_id": {
+ "description": "The id of the channel",
+ "format": "uuid",
+ "type": "string"
+ },
+ "channel_message_search_results": {
+ "description": "The search results for the channel\nThis may be empty if the search result match was not on content",
+ "items": {
+ "description": "A channel message match for a given channel id",
+ "properties": {
+ "created_at": {
+ "description": "When the channel message was created\nThis is only prsent if the search result is on the message content",
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "highlight": {
+ "description": "The highlights for the channel message",
+ "properties": {
+ "bcc": {
+ "description": "The highlight match on the bcc (email only)",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "cc": {
+ "description": "The highlight match on the cc (email only)",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "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"
+ ]
+ },
+ "recipients": {
+ "description": "The highlight match on the recipients (email only)",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "sender": {
+ "description": "The highlight match on the sender (email only)",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "user_id": {
+ "description": "The highlight match on the user (owner) of the entity",
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "message_id": {
+ "description": "The channel message id\nThis is only prsent if the search result is on the message content",
+ "format": "uuid",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "score": {
+ "description": "The score of the result",
+ "format": "double",
+ "type": [
+ "number",
+ "null"
+ ]
+ },
+ "sender_id": {
+ "description": "The sender id\nThis is only prsent if the search result is on the message content",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "thread_id": {
+ "description": "The channel message thread id",
+ "format": "uuid",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "updated_at": {
+ "description": "When the channel message was last updated\nThis is only prsent if the search result is on the message content",
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "highlight"
],
- "type": "string"
- },
- "name": {
- "type": "string"
- },
- "providerLabelId": {
- "type": "string"
+ "type": "object"
},
- "type": {
- "enum": [
- "System",
- "User"
- ],
- "type": "string"
- }
+ "type": "array"
},
- "required": [
- "id",
- "linkId",
- "providerLabelId",
- "name",
- "createdAt",
- "messageListVisibility",
- "labelListVisibility",
- "type"
- ],
- "type": "object"
- },
- "type": "array"
- },
- "macroAttachments": {
- "items": {
- "properties": {
- "dbId": {
- "format": "uuid",
- "type": "string"
- },
- "itemId": {
- "format": "uuid",
- "type": "string"
- },
- "itemType": {
- "type": "string"
+ "channel_type": {
+ "description": "The type of channel",
+ "type": "string"
+ },
+ "id": {
+ "description": "Standardized fields that all item types will share.\nThese field names are being aligned across all item types\nfor consistency in our data model.",
+ "format": "uuid",
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Metadata from the database. None if the channel doesn't exist in the database.",
+ "properties": {
+ "created_at": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "interacted_at": {
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "updated_at": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "viewed_at": {
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
},
- "messageId": {
- "format": "uuid",
- "type": "string"
- }
+ "required": [
+ "created_at",
+ "updated_at"
+ ],
+ "type": [
+ "object",
+ "null"
+ ]
},
- "required": [
- "dbId",
- "messageId",
- "itemId",
- "itemType"
- ],
- "type": "object"
+ "owner_id": {
+ "description": "we don't store this for channels atm but keeping it here for consistency",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "type": {
+ "const": "channel",
+ "type": "string"
+ }
},
- "type": "array"
+ "required": [
+ "type",
+ "id",
+ "channel_type",
+ "channel_id",
+ "channel_message_search_results"
+ ],
+ "type": "object"
},
- "metadata": {
+ {
+ "description": "ProjectSearchResponseItem object with project metadata we fetch from macrodb. we don't store these\ntimestamps in opensearch as they would require us to update the project record\nevery time the project updates (specifically for updated_at and viewed_at)",
"properties": {
- "calendar_invite": {
- "description": "if any email contains a calendar invite",
- "type": "boolean"
+ "created_at": {
+ "format": "int64",
+ "type": "integer"
},
- "generic_sender": {
- "description": "if any sender in the thread is a generic email",
- "type": "boolean"
+ "id": {
+ "description": "Standardized fields that all item types will share.\nThese field names are being aligned across all item types\nfor consistency in our data model.",
+ "format": "uuid",
+ "type": "string"
+ },
+ "metadata": {
+ "description": "Metadata from the database. None if the project doesn't exist in the database.",
+ "properties": {
+ "created_at": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "deleted_at": {
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ },
+ "parent_project_id": {
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "updated_at": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "viewed_at": {
+ "format": "int64",
+ "type": [
+ "integer",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "created_at",
+ "updated_at"
+ ],
+ "type": [
+ "object",
+ "null"
+ ]
+ },
+ "name": {
+ "type": "string"
+ },
+ "owner_id": {
+ "type": "string"
+ },
+ "project_search_results": {
+ "items": {
+ "properties": {
+ "highlight": {
+ "properties": {
+ "bcc": {
+ "description": "The highlight match on the bcc (email only)",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "cc": {
+ "description": "The highlight match on the cc (email only)",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "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"
+ ]
+ },
+ "recipients": {
+ "description": "The highlight match on the recipients (email only)",
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ },
+ "sender": {
+ "description": "The highlight match on the sender (email only)",
+ "type": [
+ "string",
+ "null"
+ ]
+ },
+ "user_id": {
+ "description": "The highlight match on the user (owner) of the entity",
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "type": "object"
+ },
+ "score": {
+ "description": "The score of the result",
+ "format": "double",
+ "type": [
+ "number",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "highlight"
+ ],
+ "type": "object"
+ },
+ "type": "array"
},
- "known_sender": {
- "description": "if user has previously emailed any sender in the thread",
- "type": "boolean"
+ "type": {
+ "const": "project",
+ "type": "string"
},
- "tabular": {
- "description": "if any email contains a <table> html tag",
- "type": "boolean"
+ "updated_at": {
+ "format": "int64",
+ "type": "integer"
}
},
"required": [
- "known_sender",
- "tabular",
- "calendar_invite",
- "generic_sender"
+ "type",
+ "id",
+ "name",
+ "owner_id",
+ "updated_at",
+ "created_at",
+ "project_search_results"
],
"type": "object"
- },
- "name": {
- "type": [
- "string",
- "null"
- ]
- },
- "ownerId": {
- "type": "string"
- },
- "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"
- },
- "viewedAt": {
- "format": "int64",
- "type": [
- "integer",
- "null"
- ]
}
- },
- "required": [
- "id",
- "ownerId",
- "inboxVisible",
- "isRead",
- "isDraft",
- "isImportant",
- "sortTs",
- "createdAt",
- "updatedAt",
- "attachments",
- "macroAttachments",
- "contacts",
- "labels",
- "metadata"
- ],
- "type": "object"
+ ]
},
"type": "array"
- },
- "next_cursor": {
- "type": [
- "string",
- "null"
- ]
}
},
"required": [
- "items"
+ "results"
],
- "title": "ApiPaginatedThreadCursor",
+ "title": "SearchToolResponse",
"type": "object"
}
},
@@ -2888,6 +2888,244 @@
"title": "WebSearchResponse",
"type": "object"
}
+ },
+ {
+ "name": "web_fetch",
+ "inputSchema": {
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "description": "The expected shape of the streamed JSON following a `server_tool_use` in content_block_start event",
+ "properties": {
+ "url": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "url"
+ ],
+ "title": "WebFetchToolCall",
+ "type": "object"
+ },
+ "outputSchema": {
+ "$defs": {
+ "CitationsConfig": {
+ "description": "Citations configuration for web fetch",
+ "properties": {
+ "enabled": {
+ "type": "boolean"
+ }
+ },
+ "required": [
+ "enabled"
+ ],
+ "type": "object"
+ },
+ "WebFetchContent": {
+ "description": "Content of a web fetch response - either a successful result or an error",
+ "oneOf": [
+ {
+ "$ref": "#/$defs/WebFetchResult",
+ "properties": {
+ "type": {
+ "const": "web_fetch_result",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type"
+ ],
+ "type": "object"
+ },
+ {
+ "$ref": "#/$defs/WebFetchToolError",
+ "properties": {
+ "type": {
+ "const": "web_fetch_tool_result_error",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type"
+ ],
+ "type": "object"
+ }
+ ]
+ },
+ "WebFetchDocument": {
+ "description": "Document content from a web fetch",
+ "properties": {
+ "citations": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/CitationsConfig"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Optional citations configuration"
+ },
+ "source": {
+ "$ref": "#/$defs/WebFetchSource",
+ "description": "The source content (text or base64)"
+ },
+ "title": {
+ "description": "Optional title of the document",
+ "type": [
+ "string",
+ "null"
+ ]
+ }
+ },
+ "required": [
+ "source"
+ ],
+ "type": "object"
+ },
+ "WebFetchErrorCode": {
+ "description": "Possible error codes for web fetch failures",
+ "oneOf": [
+ {
+ "const": "invalid_input",
+ "description": "Invalid URL format",
+ "type": "string"
+ },
+ {
+ "const": "url_too_long",
+ "description": "URL exceeds maximum length (250 characters)",
+ "type": "string"
+ },
+ {
+ "const": "url_not_allowed",
+ "description": "URL blocked by domain filtering rules and model restrictions",
+ "type": "string"
+ },
+ {
+ "const": "url_not_accessible",
+ "description": "Failed to fetch content (HTTP error)",
+ "type": "string"
+ },
+ {
+ "const": "too_many_requests",
+ "description": "Rate limit exceeded",
+ "type": "string"
+ },
+ {
+ "const": "unsupported_content_type",
+ "description": "Content type not supported (only text and PDF)",
+ "type": "string"
+ },
+ {
+ "const": "max_uses_exceeded",
+ "description": "Maximum web fetch tool uses exceeded",
+ "type": "string"
+ },
+ {
+ "const": "unavailable",
+ "description": "An internal error occurred",
+ "type": "string"
+ }
+ ]
+ },
+ "WebFetchResult": {
+ "description": "Successful web fetch result containing the fetched content",
+ "properties": {
+ "content": {
+ "$ref": "#/$defs/WebFetchDocument",
+ "description": "The fetched document content"
+ },
+ "retrieved_at": {
+ "description": "Timestamp when the content was retrieved",
+ "type": "string"
+ },
+ "url": {
+ "description": "The URL that was fetched",
+ "type": "string"
+ }
+ },
+ "required": [
+ "url",
+ "content",
+ "retrieved_at"
+ ],
+ "type": "object"
+ },
+ "WebFetchSource": {
+ "description": "Source content of a fetched document",
+ "oneOf": [
+ {
+ "description": "Plain text content",
+ "properties": {
+ "data": {
+ "type": "string"
+ },
+ "media_type": {
+ "type": "string"
+ },
+ "type": {
+ "const": "text",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "media_type",
+ "data"
+ ],
+ "type": "object"
+ },
+ {
+ "description": "Base64-encoded content (e.g., PDF)",
+ "properties": {
+ "data": {
+ "type": "string"
+ },
+ "media_type": {
+ "type": "string"
+ },
+ "type": {
+ "const": "base64",
+ "type": "string"
+ }
+ },
+ "required": [
+ "type",
+ "media_type",
+ "data"
+ ],
+ "type": "object"
+ }
+ ]
+ },
+ "WebFetchToolError": {
+ "description": "Error returned when web fetch fails",
+ "properties": {
+ "error_code": {
+ "$ref": "#/$defs/WebFetchErrorCode"
+ }
+ },
+ "required": [
+ "error_code"
+ ],
+ "type": "object"
+ }
+ },
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "description": "Web fetch tool response content returned by Claude when using the web_fetch tool",
+ "properties": {
+ "content": {
+ "$ref": "#/$defs/WebFetchContent"
+ },
+ "tool_use_id": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "tool_use_id",
+ "content"
+ ],
+ "title": "WebFetchResponse",
+ "type": "object"
+ }
}
]
}
\ No newline at end of file