Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(ai): list channels tool (#976)
Eric Hayesed857d1b5531
diff --git a/js/app/packages/core/component/AI/component/tool/ListChannels.tsx b/js/app/packages/core/component/AI/component/tool/ListChannels.tsxnew file mode 100644index 0000000000..f4ea6582b6--- /dev/null+++ b/js/app/packages/core/component/AI/component/tool/ListChannels.tsx@@ -0,0 +1,25 @@+import Channel from '@icon/duotone/hash-duotone.svg';+import { BaseTool } from './BaseTool';+import { createToolRenderer } from './ToolRenderer';++const handler = createToolRenderer({+ name: 'ListChannels',+ renderCall: (ctx) => (+ <BaseTool+ icon={Channel}+ text="Listing channels..."+ renderContext={ctx.renderContext}+ type="call"+ />+ ),+ renderResponse: (ctx) => (+ <BaseTool+ icon={Channel}+ text={`Found ${ctx.tool.data.total} channel${ctx.tool.data.total === 1 ? '' : 's'}`}+ renderContext={ctx.renderContext}+ type="response"+ />+ ),+});++export const listChannelsHandler = handler;diff --git a/js/app/packages/core/component/AI/component/tool/handler.tsx b/js/app/packages/core/component/AI/component/tool/handler.tsxindex da60312554..488f99a30c 100644--- a/js/app/packages/core/component/AI/component/tool/handler.tsx+++ b/js/app/packages/core/component/AI/component/tool/handler.tsx@@ -10,6 +10,7 @@ import {} from '@service-cognition/generated/tools/tool';import { createStore } from 'solid-js/store';import { Dynamic, Show } from 'solid-js/web';+import { listChannelsHandler } from './ListChannels';import { listDocumentsHandler } from './ListDocuments';import { listEmailsHandler } from './ListEmails';import { rewriteHandler } from './MarkdownRewrite';@@ -30,6 +31,7 @@ const toolHandlers: ToolHandlerMap<RenderContext> = {web_search: webSearchHandler,MarkdownRewrite: rewriteHandler,Read: readHandler,+ ListChannels: listChannelsHandler,ListDocuments: listDocumentsHandler,ListEmails: listEmailsHandler,};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.tsindex a7ed7248e4..aac0e86837 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@@ -219,6 +219,26 @@ export const SearchToolResponse = z.object({),});+export const ListChannels = z+ .object({ unused: z.null().default(null) })+ .strict();++export const ListChannelsResponse = z.object({+ channels: z.array(+ z.object({+ channelType: z.enum([+ 'public',+ 'organization',+ 'private',+ 'direct_message',+ ]),+ id: z.string().uuid(),+ name: z.union([z.string(), z.null()]).optional(),+ })+ ),+ total: z.number().int().gte(0),+});+export const ListDocuments = z.object({exhaustiveSearch: z.boolean().default(false),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.tsindex 8e43932a69..b4687bf6d8 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@@ -13,6 +13,10 @@ type ToolParserMap = {call: types.ContentSearch;response: types.SearchToolResponse;};+ ListChannels: {+ call: types.ListChannels;+ response: types.ListChannelsResponse;+ };ListDocuments: {call: types.ListDocuments;response: types.ListDocumentsResponse;@@ -39,6 +43,10 @@ const toolParserMap = {call: schemas.ContentSearch,response: schemas.SearchToolResponse,},+ ListChannels: {+ call: schemas.ListChannels,+ response: schemas.ListChannelsResponse,+ },ListDocuments: {call: schemas.ListDocuments,response: schemas.ListDocumentsResponse,@@ -79,6 +87,10 @@ type ToolDataMap = {call: types.ContentSearch;response: types.SearchToolResponse;};+ ListChannels: {+ call: types.ListChannels;+ response: types.ListChannelsResponse;+ };ListDocuments: {call: types.ListDocuments;response: types.ListDocumentsResponse;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.tsindex 22b910bb4f..506db952bf 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@@ -475,6 +475,54 @@ export interface SearchToolResponse {)[];}+/* 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.+ */++/**+ * List all chat channels the user has access to. Returns channel names, IDs, and types. Use this tool to discover available channels for reading messages or participating in conversations.+ */+export interface ListChannels {+ unused: null;+}++/* 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.+ */++/**+ * Response from listing channels+ */+export interface ListChannelsResponse {+ /**+ * The list of channels the user has access to+ */+ channels: {+ /**+ * The type of channel (public, private, organization, or direct_message)+ */+ channelType: 'public' | 'organization' | 'private' | 'direct_message';+ /**+ * The channel's unique identifier+ */+ id: string;+ /**+ * The channel's display name (may be None for direct messages)+ */+ name?: string | null;+ }[];+ /**+ * Total number of channels returned+ */+ total: number;+}+/* 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.lockindex 3255c22636..999d365cc1 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -91,6 +91,7 @@ dependencies = ["anyhow","async-trait","chrono",+ "comms_service_client","cool_asserts","email","email_service_client",diff --git a/rust/cloud-storage/ai_tools/Cargo.toml b/rust/cloud-storage/ai_tools/Cargo.tomlindex 978ce8f782..cbc1ad52cc 100644--- a/rust/cloud-storage/ai_tools/Cargo.toml+++ b/rust/cloud-storage/ai_tools/Cargo.toml@@ -9,6 +9,7 @@ ai = { path = "../ai" }anyhow.workspace = trueasync-trait.workspace = truechrono.workspace = true+comms_service_client = { path = "../comms_service_client" }email = { path = "../email", features = ["ai_schema", "axum"] }email_service_client = { path = "../email_service_client" }lazy_static.workspace = truediff --git a/rust/cloud-storage/ai_tools/src/list/channel/mod.rs b/rust/cloud-storage/ai_tools/src/list/channel/mod.rsnew file mode 100644index 0000000000..5a25088343--- /dev/null+++ b/rust/cloud-storage/ai_tools/src/list/channel/mod.rs@@ -0,0 +1,5 @@+#[cfg(test)]+mod test;+mod tool;++pub use tool::*;diff --git a/rust/cloud-storage/ai_tools/src/list/channel/test.rs b/rust/cloud-storage/ai_tools/src/list/channel/test.rsnew file mode 100644index 0000000000..8e84b0cfd5--- /dev/null+++ b/rust/cloud-storage/ai_tools/src/list/channel/test.rs@@ -0,0 +1,38 @@+use super::*;+use ai::generate_tool_input_schema;+use ai::tool::types::tool_object::validate_tool_schema;++#[test]+fn test_list_channels_schema_validation() {+ let schema = generate_tool_input_schema!(ListChannels);++ let result = validate_tool_schema(&schema);+ assert!(result.is_ok(), "{:?}", result);++ let (name, description) = result.unwrap();+ assert_eq!(+ name, "ListChannels",+ "Tool name should match the schemars title"+ );+ assert!(+ description.contains("List all chat channels"),+ "Description should contain expected text"+ );+}++// run `cargo test -p ai_tools list::channel::test::print_input_schema -- --nocapture --include-ignored`+#[test]+#[ignore = "prints the input schema"]+fn print_input_schema() {+ let schema = generate_tool_input_schema!(ListChannels);+ println!("{}", serde_json::to_string_pretty(&schema).unwrap());+}++// run `cargo test -p ai_tools list::channel::test::print_output_schema -- --nocapture --include-ignored`+#[test]+#[ignore = "prints the output schema"]+fn print_output_schema() {+ let generator = ai::tool::minimized_output_schema_generator();+ let schema = generator.into_root_schema_for::<ListChannelsResponse>();+ println!("{}", serde_json::to_string_pretty(&schema).unwrap());+}diff --git a/rust/cloud-storage/ai_tools/src/list/channel/tool.rs b/rust/cloud-storage/ai_tools/src/list/channel/tool.rsnew file mode 100644index 0000000000..a061a9ce01--- /dev/null+++ b/rust/cloud-storage/ai_tools/src/list/channel/tool.rs@@ -0,0 +1,81 @@+use crate::tool_context::{RequestContext, ToolServiceContext};+use ai::tool::{AsyncTool, ToolCallError, ToolResult};+use async_trait::async_trait;+use model::comms::ChannelType;+use schemars::JsonSchema;+use serde::{Deserialize, Serialize};+use uuid::Uuid;++/// A channel item returned by the list channels tool+#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]+#[serde(rename_all = "camelCase")]+pub struct ChannelListItem {+ /// The channel's unique identifier+ pub id: Uuid,+ /// The channel's display name (may be None for direct messages)+ pub name: Option<String>,+ /// The type of channel (public, private, organization, or direct_message)+ pub channel_type: ChannelType,+}++/// Response from listing channels+#[derive(Debug, JsonSchema, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct ListChannelsResponse {+ /// The list of channels the user has access to+ pub channels: Vec<ChannelListItem>,+ /// Total number of channels returned+ pub total: usize,+}++/// List channels tool - lists all channels the user has access to+#[derive(Debug, JsonSchema, Deserialize, Clone)]+#[serde(rename_all = "camelCase")]+#[schemars(+ description = "List all chat channels the user has access to. Returns channel names, IDs, and types. Use this tool to discover available channels for reading messages or participating in conversations.",+ title = "ListChannels"+)]+pub struct ListChannels {+ #[serde(default)]+ _unused: (),+}++#[async_trait]+impl AsyncTool<ToolServiceContext, RequestContext> for ListChannels {+ type Output = ListChannelsResponse;++ #[tracing::instrument(skip_all, fields(user_id=?request_context.user_id), err)]+ async fn call(+ &self,+ context: ToolServiceContext,+ request_context: RequestContext,+ ) -> ToolResult<Self::Output> {+ tracing::info!("List channels");++ let channels = context+ .scribe+ .channel+ .list_channels(&request_context.jwt_token)+ .await+ .map_err(|e| ToolCallError {+ description: format!("failed to list channels: {}", e),+ internal_error: e,+ })?;++ let channel_items: Vec<ChannelListItem> = channels+ .into_iter()+ .map(|c| ChannelListItem {+ id: c.id.0,+ name: c.name,+ channel_type: c.channel_type,+ })+ .collect();++ let total = channel_items.len();++ Ok(ListChannelsResponse {+ channels: channel_items,+ total,+ })+ }+}diff --git a/rust/cloud-storage/ai_tools/src/list/mod.rs b/rust/cloud-storage/ai_tools/src/list/mod.rsindex 45bdc83429..7e2dc7fe87 100644--- a/rust/cloud-storage/ai_tools/src/list/mod.rs+++ b/rust/cloud-storage/ai_tools/src/list/mod.rs@@ -1,10 +1,13 @@use crate::AiToolSet;use ai::tool::AsyncToolSet;+mod channel;mod email;mod file;pub fn list_toolset() -> AiToolSet {AsyncToolSet::new()+ .add_tool::<channel::ListChannels>()+ .expect("failed to add list channels").add_tool::<email::ListEmails>().expect("failed to add list email").add_tool::<file::ListDocuments>()diff --git a/rust/cloud-storage/comms_service_client/src/channels.rs b/rust/cloud-storage/comms_service_client/src/channels.rsindex 86b7e8fe49..3cbc9084a7 100644--- a/rust/cloud-storage/comms_service_client/src/channels.rs+++ b/rust/cloud-storage/comms_service_client/src/channels.rs@@ -1,7 +1,10 @@use super::CommsServiceClient;use crate::error::{ClientError, ResponseExt};-use model::comms::ChannelType;-use model::comms::{GetChannelsHistoryRequest, GetChannelsHistoryResponse};+use model::comms::{+ ChannelMessage, ChannelParticipant, ChannelType, GetChannelsHistoryRequest,+ GetChannelsHistoryResponse,+};+use models_comms::channel::{ChannelId, OrganizationId};use serde::{Deserialize, Serialize};use urlencoding;use uuid::Uuid;@@ -17,11 +20,71 @@ pub struct ChannelTranscriptResponse {pub transcript: String,}+/// Channel with latest message from GET /channels response+#[derive(Debug, Clone, Serialize, Deserialize)]+pub struct ApiChannelWithLatest {+ /// Channel ID+ pub id: ChannelId,+ /// Channel name (may be None for DMs)+ pub name: Option<String>,+ /// Channel type+ pub channel_type: ChannelType,+ /// Organization ID if applicable+ pub org_id: Option<OrganizationId>,+ /// When the channel was created+ pub created_at: chrono::DateTime<chrono::Utc>,+ /// When the channel was last updated+ pub updated_at: chrono::DateTime<chrono::Utc>,+ /// Owner user ID+ pub owner_id: String,+ /// Channel participants+ pub participants: Vec<ChannelParticipant>,+ /// Latest message in the channel+ pub latest_message: Option<ChannelMessage>,+ /// Latest non-thread message+ pub latest_non_thread_message: Option<ChannelMessage>,+ /// When the user last viewed the channel+ pub viewed_at: Option<chrono::DateTime<chrono::Utc>>,+ /// When the user last interacted with the channel+ pub interacted_at: Option<chrono::DateTime<chrono::Utc>>,+ /// Frecency score for sorting+ pub frecency_score: Option<f64>,+}+impl CommsServiceClient {// External routes - require JWT authentication and perform permission checks+ /// Get all channels the user has access to using external authenticated endpoint+ #[tracing::instrument(skip(self, jwt_token), err)]+ pub async fn get_channels_external(+ &self,+ jwt_token: &str,+ ) -> Result<Vec<ApiChannelWithLatest>, ClientError> {+ let url = format!("{}/channels", self.url);+ let response = self+ .client+ .get(&url)+ .header("Authorization", format!("Bearer {}", jwt_token))+ .send()+ .await+ .map_client_error()+ .await?;++ let result = response+ .json::<Vec<ApiChannelWithLatest>>()+ .await+ .map_err(|e| {+ ClientError::Generic(anyhow::anyhow!(+ "unable to parse response from get_channels_external: {}",+ e.to_string()+ ))+ })?;++ Ok(result)+ }+/// Get channel metadata using external authenticated endpoint- #[tracing::instrument(skip(self, jwt_token))]+ #[tracing::instrument(skip(self, jwt_token), err)]pub async fn get_channel_metadata_external(&self,channel_id: &Uuid,@@ -51,7 +114,7 @@ impl CommsServiceClient {}/// Get channel transcript using external authenticated endpoint- #[tracing::instrument(skip(self, jwt_token))]+ #[tracing::instrument(skip(self, jwt_token), err)]pub async fn get_channel_transcript_external(&self,channel_id: &Uuid,diff --git a/rust/cloud-storage/document_cognition_service/schemas/tools.json b/rust/cloud-storage/document_cognition_service/schemas/tools.jsonindex 036529fdfe..7194ae476b 100644--- a/rust/cloud-storage/document_cognition_service/schemas/tools.json+++ b/rust/cloud-storage/document_cognition_service/schemas/tools.json@@ -1,5 +1,77 @@{"schemas": [+ {+ "name": "ListChannels",+ "inputSchema": {+ "additionalProperties": false,+ "description": "List all chat channels the user has access to. Returns channel names, IDs, and types. Use this tool to discover available channels for reading messages or participating in conversations.",+ "properties": {+ "unused": {+ "additionalProperties": false,+ "default": null,+ "type": "null"+ }+ },+ "required": [+ "unused"+ ],+ "title": "ListChannels",+ "type": "object"+ },+ "outputSchema": {+ "description": "Response from listing channels",+ "properties": {+ "channels": {+ "description": "The list of channels the user has access to",+ "items": {+ "description": "A channel item returned by the list channels tool",+ "properties": {+ "channelType": {+ "description": "The type of channel (public, private, organization, or direct_message)",+ "enum": [+ "public",+ "organization",+ "private",+ "direct_message"+ ],+ "type": "string"+ },+ "id": {+ "description": "The channel's unique identifier",+ "format": "uuid",+ "type": "string"+ },+ "name": {+ "description": "The channel's display name (may be None for direct messages)",+ "type": [+ "string",+ "null"+ ]+ }+ },+ "required": [+ "id",+ "channelType"+ ],+ "type": "object"+ },+ "type": "array"+ },+ "total": {+ "description": "Total number of channels returned",+ "format": "uint",+ "minimum": 0,+ "type": "integer"+ }+ },+ "required": [+ "channels",+ "total"+ ],+ "title": "ListChannelsResponse",+ "type": "object"+ }+ },{"name": "ContentSearch","inputSchema": {@@ -966,512 +1038,192 @@}},{- "name": "MarkdownRewrite",+ "name": "ListEmails","inputSchema": {"additionalProperties": false,- "description": "Instruct an agent to edit a markdown file identified by an id.\n This tool should be used when the user include a markdown file in context and requests a revision or edit to that file",+ "description": "List 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": {- "instructions": {+ "cursor": {"additionalProperties": false,- "description": "Instructions for the revision agent to follow to edit the markdown. These instructions will be provided by the user.",- "type": "string"+ "default": 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"+ ]},- "markdown_file_id": {+ "limit": {"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": "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": {+ "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,- "description": "The type of content to read. Choose based on the type of content you want to retrieve.",+ "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": [- "document",- "channel",- "channel-message",- "chat-thread",- "chat-message",- "email-thread",- "email-message",- "project"+ "viewed_at",+ "updated_at",+ "created_at",+ "viewed_updated"],"type": "string"},- "ids": {+ "view": {"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"+ "default": {+ "standardLabel": null,+ "userLabel": null},- "type": "array"- },- "messagesSince": {- "additionalProperties": false,- "description": "A local datetime of the earliest message to include in a channel transcript ex: 2025-11-25 12:00:09 EST, only applicable to channels",- "format": "date-time",- "type": [- "string",- "null"- ]+ "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": [- "contentType",- "ids",- "messagesSince"+ "cursor",+ "limit",+ "sortMethod",+ "view"],- "title": "Read",+ "title": "ListEmails","type": "object"},"outputSchema": {"properties": {- "content": {- "oneOf": [- {- "properties": {- "documents": {- "items": {- "properties": {- "formattedDocument": {- "type": "string"- }+ "items": {+ "items": {+ "properties": {+ "attachments": {+ "items": {+ "properties": {+ "contentId": {+ "type": [+ "string",+ "null"+ ]},- "required": [- "formattedDocument"- ],- "type": "object"- },- "type": "array"- },- "type": {- "const": "documents",- "type": "string"- }- },- "required": [- "type",- "documents"- ],- "type": "object"- },- {- "properties": {- "channel_id": {- "type": "string"- },- "channel_name": {- "type": [- "string",- "null"- ]- },- "transcript": {- "type": "string"- },- "type": {- "const": "channel",- "type": "string"- }- },- "required": [- "type",- "channel_id",- "transcript"- ],- "type": "object"- },- {- "properties": {- "conversation": {- "items": {- "properties": {- "chat_id": {- "type": "string"- },- "messages": {- "items": {- "properties": {- "attachmentIds": {- "items": {- "type": "string"- },- "type": "array"- },- "content": {- "type": "string"- },- "date": {- "format": "date-time",- "type": "string"- }- },- "required": [- "content",- "date",- "attachmentIds"- ],- "type": "object"- },- "type": "array"- },- "title": {- "type": "string"- }+ "createdAt": {+ "format": "int64",+ "type": "integer"},- "required": [- "chat_id",- "title",- "messages"- ],- "type": "object"+ "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"+ ]+ }},- "type": "array"+ "required": [+ "id",+ "messageId",+ "createdAt"+ ],+ "type": "object"},- "type": {- "const": "chat",- "type": "string"- }+ "type": "array"},- "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"- ]- }+ "contacts": {+ "items": {+ "properties": {+ "emailAddress": {+ "type": [+ "string",+ "null"+ ]},- "required": [- "messageId",- "sender",- "recipients",- "cc",- "bcc",- "content"- ],- "type": "object"+ "id": {+ "format": "uuid",+ "type": "string"+ },+ "linkId": {+ "format": "uuid",+ "type": "string"+ },+ "name": {+ "type": [+ "string",+ "null"+ ]+ },+ "sfsPhotoUrl": {+ "type": [+ "string",+ "null"+ ]+ }},- "type": "array"- },- "subject": {- "type": [- "string",- "null"- ]- },- "thread_id": {- "type": "string"+ "required": [+ "id",+ "linkId"+ ],+ "type": "object"},- "type": {- "const": "email",- "type": "string"- }+ "type": "array"},- "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": "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"- ]- },- "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"- ]- }- },- "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"- ]- }- },- "required": [- "id",- "linkId"- ],- "type": "object"- },- "type": "array"- },- "createdAt": {- "format": "int64",- "type": "integer"+ "createdAt": {+ "format": "int64",+ "type": "integer"},"frecencyScore": {"format": "double",@@ -1532,170 +1284,432 @@"providerLabelId": {"type": "string"},- "type": {- "enum": [- "System",- "User"- ],- "type": "string"- }+ "type": {+ "enum": [+ "System",+ "User"+ ],+ "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"+ }+ },+ "required": [+ "dbId",+ "messageId",+ "itemId",+ "itemType"+ ],+ "type": "object"+ },+ "type": "array"+ },+ "metadata": {+ "properties": {+ "calendar_invite": {+ "description": "if any email contains a calendar invite",+ "type": "boolean"+ },+ "generic_sender": {+ "description": "if any sender in the thread is a generic email",+ "type": "boolean"+ },+ "known_sender": {+ "description": "if user has previously emailed any sender in the thread",+ "type": "boolean"+ },+ "tabular": {+ "description": "if any email contains a <table> html tag",+ "type": "boolean"+ }+ },+ "required": [+ "known_sender",+ "tabular",+ "calendar_invite",+ "generic_sender"+ ],+ "type": "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": "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"+ },+ "messagesSince": {+ "additionalProperties": false,+ "description": "A local datetime of the earliest message to include in a channel transcript ex: 2025-11-25 12:00:09 EST, only applicable to channels",+ "format": "date-time",+ "type": [+ "string",+ "null"+ ]+ }+ },+ "required": [+ "contentType",+ "ids",+ "messagesSince"+ ],+ "title": "Read",+ "type": "object"+ },+ "outputSchema": {+ "properties": {+ "content": {+ "oneOf": [+ {+ "properties": {+ "documents": {+ "items": {+ "properties": {+ "formattedDocument": {+ "type": "string"+ }+ },+ "required": [+ "formattedDocument"+ ],+ "type": "object"+ },+ "type": "array"+ },+ "type": {+ "const": "documents",+ "type": "string"+ }+ },+ "required": [+ "type",+ "documents"+ ],+ "type": "object"+ },+ {+ "properties": {+ "channel_id": {+ "type": "string"+ },+ "channel_name": {+ "type": [+ "string",+ "null"+ ]+ },+ "transcript": {+ "type": "string"+ },+ "type": {+ "const": "channel",+ "type": "string"+ }+ },+ "required": [+ "type",+ "channel_id",+ "transcript"+ ],+ "type": "object"+ },+ {+ "properties": {+ "conversation": {+ "items": {+ "properties": {+ "chat_id": {+ "type": "string"+ },+ "messages": {+ "items": {+ "properties": {+ "attachmentIds": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "content": {+ "type": "string"+ },+ "date": {+ "format": "date-time",+ "type": "string"+ }+ },+ "required": [+ "content",+ "date",+ "attachmentIds"+ ],+ "type": "object"+ },+ "type": "array"+ },+ "title": {+ "type": "string"+ }+ },+ "required": [+ "chat_id",+ "title",+ "messages"+ ],+ "type": "object"+ },+ "type": "array"+ },+ "type": {+ "const": "chat",+ "type": "string"+ }+ },+ "required": [+ "type",+ "conversation"+ ],+ "type": "object"+ },+ {+ "properties": {+ "messages": {+ "items": {+ "properties": {+ "bcc": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "cc": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "content": {+ "type": "string"+ },+ "messageId": {+ "type": "string"+ },+ "recipients": {+ "items": {+ "type": "string"+ },+ "type": "array"+ },+ "sender": {+ "type": "string"+ },+ "sentAt": {+ "format": "date-time",+ "type": [+ "string",+ "null"+ ]+ }+ },+ "required": [+ "messageId",+ "sender",+ "recipients",+ "cc",+ "bcc",+ "content"+ ],+ "type": "object"},- "required": [- "id",- "linkId",- "providerLabelId",- "name",- "createdAt",- "messageListVisibility",- "labelListVisibility",- "type"- ],- "type": "object"+ "type": "array"},- "type": "array"- },- "macroAttachments": {- "items": {- "properties": {- "dbId": {- "format": "uuid",- "type": "string"- },- "itemId": {- "format": "uuid",- "type": "string"- },- "itemType": {- "type": "string"- },- "messageId": {- "format": "uuid",- "type": "string"- }- },- "required": [- "dbId",- "messageId",- "itemId",- "itemType"- ],- "type": "object"+ "subject": {+ "type": [+ "string",+ "null"+ ]},- "type": "array"- },- "metadata": {- "properties": {- "calendar_invite": {- "description": "if any email contains a calendar invite",- "type": "boolean"- },- "generic_sender": {- "description": "if any sender in the thread is a generic email",- "type": "boolean"- },- "known_sender": {- "description": "if user has previously emailed any sender in the thread",- "type": "boolean"- },- "tabular": {- "description": "if any email contains a <table> html tag",- "type": "boolean"- }+ "thread_id": {+ "type": "string"},- "required": [- "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"+ "type": {+ "const": "email",+ "type": "string"+ }},- "viewedAt": {- "format": "int64",- "type": [- "integer",- "null"- ]- }+ "required": [+ "type",+ "thread_id",+ "messages"+ ],+ "type": "object"},- "required": [- "id",- "ownerId",- "inboxVisible",- "isRead",- "isDraft",- "isImportant",- "sortTs",- "createdAt",- "updatedAt",- "attachments",- "macroAttachments",- "contacts",- "labels",- "metadata"- ],- "type": "object"- },- "type": "array"- },- "next_cursor": {- "type": [- "string",- "null"+ {+ "properties": {+ "formatted_preview": {+ "type": "string"+ },+ "type": {+ "const": "itemPreviews",+ "type": "string"+ }+ },+ "required": [+ "type",+ "formatted_preview"+ ],+ "type": "object"+ }]}},"required": [- "items"+ "content"],- "title": "ApiPaginatedThreadCursor",+ "title": "ReadResponse","type": "object"}},@@ -2823,6 +2837,64 @@"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": "web_search","inputSchema": {diff --git a/rust/cloud-storage/model/src/comms/mod.rs b/rust/cloud-storage/model/src/comms/mod.rsindex 7324c8b0c8..2aff5fd7b8 100644--- a/rust/cloud-storage/model/src/comms/mod.rs+++ b/rust/cloud-storage/model/src/comms/mod.rs@@ -89,6 +89,7 @@ pub struct ChannelParticipant {Serialize,Deserialize,sqlx::Type,+ schemars::JsonSchema,)]#[strum(serialize_all = "snake_case")]#[serde(rename_all = "snake_case")]diff --git a/rust/cloud-storage/scribe/src/channel/client.rs b/rust/cloud-storage/scribe/src/channel/client.rsindex 26beaef5d8..6ed1fadc03 100644--- a/rust/cloud-storage/scribe/src/channel/client.rs+++ b/rust/cloud-storage/scribe/src/channel/client.rs@@ -2,6 +2,7 @@ use ai_format::insight_context_log::InsightContextLog;use ai_format::util::Indent;use anyhow::Error;use comms_service_client::CommsServiceClient;+use comms_service_client::channels::ApiChannelWithLatest;use models_comms::channel::ChannelMetadata;use std::fmt::Debug;use std::sync::Arc;@@ -16,6 +17,18 @@ impl ChannelClient {pub fn new(client: Arc<CommsServiceClient>) -> Self {Self { inner: client }}++ /// List all channels the user has access to+ #[tracing::instrument(skip(self, jwt_token), err)]+ pub async fn list_channels(&self, jwt_token: &str) -> Result<Vec<ApiChannelWithLatest>, Error> {+ let channels = self+ .inner+ .get_channels_external(jwt_token)+ .await+ .map_err(Error::from)?;+ Ok(channels)+ }+/// Get channel metadata (name and type) by channel ID/// Uses external authenticated endpoint if jwt_token is provided, otherwise uses internal endpoint#[tracing::instrument(skip(self, jwt_token), err)]