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): properties tools (#2143)
Eric Hayesb5762697d373
diff --git a/js/app/packages/core/component/AI/component/tool/Properties.tsx b/js/app/packages/core/component/AI/component/tool/Properties.tsxnew file mode 100644index 0000000000..dd00d343e3--- /dev/null+++ b/js/app/packages/core/component/AI/component/tool/Properties.tsx@@ -0,0 +1,37 @@+import Sliders from '@phosphor-icons/core/regular/sliders.svg';+import PencilSimple from '@phosphor-icons/core/regular/pencil-simple.svg';+import { BaseTool } from './BaseTool';+import { createToolRenderer } from './ToolRenderer';++const getHandler = createToolRenderer({+ name: 'GetEntityProperties',+ renderCall: (ctx) => (+ <BaseTool icon={Sliders} renderContext={ctx.renderContext} type="call">+ Get properties for{' '}+ <span class="text-accent">{ctx.tool.data.entity_type}</span>+ </BaseTool>+ ),+ renderResponse: (ctx) => (+ <BaseTool renderContext={ctx.renderContext} type="response">+ {ctx.tool.data.summary}+ </BaseTool>+ ),+});++const setHandler = createToolRenderer({+ name: 'SetEntityProperty',+ renderCall: (ctx) => (+ <BaseTool icon={PencilSimple} renderContext={ctx.renderContext} type="call">+ Update property on{' '}+ <span class="text-accent">{ctx.tool.data.entity_type}</span>+ </BaseTool>+ ),+ renderResponse: (ctx) => (+ <BaseTool renderContext={ctx.renderContext} type="response">+ {ctx.tool.data.message}+ </BaseTool>+ ),+});++export const getEntityPropertiesHandler = getHandler;+export const setEntityPropertyHandler = setHandler;diff --git a/js/app/packages/core/component/AI/component/tool/handler.tsx b/js/app/packages/core/component/AI/component/tool/handler.tsxindex dfde4096b5..3b48f4888c 100644--- a/js/app/packages/core/component/AI/component/tool/handler.tsx+++ b/js/app/packages/core/component/AI/component/tool/handler.tsx@@ -12,6 +12,10 @@ import { Dynamic } from 'solid-js/web';import { bashCodeExecutionHandler } from './BashCodeExecution';import { createDocumentHandler } from './CreateDocument';import { listEntitiesHandler } from './ListEntities';+import {+ getEntityPropertiesHandler,+ setEntityPropertyHandler,+} from './Properties';import { readThreadHandler } from './ReadThread';import { readContentHandler } from './ReadContent';import { readMetadataHandler } from './ReadMetadata';@@ -22,6 +26,7 @@ import { webFetchHandler } from './WebFetch';import { webSearchHandler } from './WebSearch';const toolHandlers: ToolHandlerMap<RenderContext> = {+ GetEntityProperties: getEntityPropertiesHandler,ListEntities: listEntitiesHandler,bash_code_execution: bashCodeExecutionHandler,ContentSearch: contentSearchHandler,@@ -30,6 +35,7 @@ const toolHandlers: ToolHandlerMap<RenderContext> = {ReadThread: readThreadHandler,ReadContent: readContentHandler,ReadMetadata: readMetadataHandler,+ SetEntityProperty: setEntityPropertyHandler,text_editor_code_execution: textEditorCodeExecutionHandler,web_fetch: webFetchHandler,web_search: webSearchHandler,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 5e4023ce26..2562c9ed32 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@@ -334,6 +334,41 @@ export const CreateDocumentResponse = z.object({documentId: z.string().uuid(),});+export const GetEntityProperties = z+ .object({+ entity_id: z.string(),+ entity_type: z.enum([+ 'document',+ 'task',+ 'project',+ 'chat',+ 'thread',+ 'channel',+ ]),+ })+ .strict();++export const GetEntityPropertiesResponse = z.object({+ properties: z.array(+ z.object({+ currentValue: z.any().optional(),+ dataType: z.string(),+ displayName: z.string(),+ isMultiSelect: z.boolean(),+ isSystem: z.boolean(),+ options: z.array(+ z.object({+ displayOrder: z.number().int(),+ displayValue: z.string(),+ id: z.string().uuid(),+ })+ ),+ propertyDefinitionId: z.string().uuid(),+ })+ ),+ summary: z.string(),+});+export const ListEntities = z.object({includeTypes: z.union([@@ -555,6 +590,70 @@ export const ReadResponse = z.object({}),});+export const SetEntityProperty = z+ .object({+ boolean_value: z.union([z.boolean(), z.null()]).default(null),+ date_value: z+ .union([z.string().datetime({ offset: true }), z.null()])+ .default(null),+ entity_id: z.string(),+ entity_ref: z.union([+ z+ .object({+ entityId: z.string(),+ entityType: z.enum([+ 'document',+ 'task',+ 'project',+ 'chat',+ 'thread',+ 'channel',+ ]),+ })+ .strict(),+ z.null(),+ ]),+ entity_refs: z.union([+ z.array(+ z+ .object({+ entityId: z.string(),+ entityType: z.enum([+ 'document',+ 'task',+ 'project',+ 'chat',+ 'thread',+ 'channel',+ ]),+ })+ .strict()+ ),+ z.null(),+ ]),+ entity_type: z.enum([+ 'document',+ 'task',+ 'project',+ 'chat',+ 'thread',+ 'channel',+ ]),+ link_url: z.union([z.string(), z.null()]).default(null),+ link_urls: z.union([z.array(z.string()), z.null()]).default(null),+ number_value: z.union([z.number(), z.null()]).default(null),+ option_id: z.union([z.string().uuid(), z.null()]).default(null),+ option_ids: z.union([z.array(z.string().uuid()), z.null()]).default(null),+ property_definition_id: z.string().uuid(),+ string_value: z.union([z.string(), z.null()]).default(null),+ })+ .strict();++export const SetEntityPropertyResponse = z.object({+ message: z.string(),+ success: z.boolean(),+});+export const TextEditorCodeExecutionToolCall = z.object({command: z.string(),file_text: z.union([z.string(), z.null()]).optional(),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 f82e9c6a6b..aba994b096 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@@ -21,6 +21,10 @@ type ToolParserMap = {call: types.CreateDocument;response: types.CreateDocumentResponse;};+ GetEntityProperties: {+ call: types.GetEntityProperties;+ response: types.GetEntityPropertiesResponse;+ };ListEntities: {call: types.ListEntities;response: types.ListEntitiesResponse;@@ -32,6 +36,10 @@ type ToolParserMap = {response: types.ReadMetadataResponse;};ReadThread: { call: types.ReadThread; response: types.ReadResponse };+ SetEntityProperty: {+ call: types.SetEntityProperty;+ response: types.SetEntityPropertyResponse;+ };text_editor_code_execution: {call: types.TextEditorCodeExecutionToolCall;response: types.TextEditorCodeExecutionResponse;@@ -56,6 +64,10 @@ const toolParserMap = {call: schemas.CreateDocument,response: schemas.CreateDocumentResponse,},+ GetEntityProperties: {+ call: schemas.GetEntityProperties,+ response: schemas.GetEntityPropertiesResponse,+ },ListEntities: {call: schemas.ListEntities,response: schemas.ListEntitiesResponse,@@ -73,6 +85,10 @@ const toolParserMap = {response: schemas.ReadMetadataResponse,},ReadThread: { call: schemas.ReadThread, response: schemas.ReadResponse },+ SetEntityProperty: {+ call: schemas.SetEntityProperty,+ response: schemas.SetEntityPropertyResponse,+ },text_editor_code_execution: {call: schemas.TextEditorCodeExecutionToolCall,response: schemas.TextEditorCodeExecutionResponse,@@ -108,6 +124,10 @@ type ToolDataMap = {call: types.CreateDocument;response: types.CreateDocumentResponse;};+ GetEntityProperties: {+ call: types.GetEntityProperties;+ response: types.GetEntityPropertiesResponse;+ };ListEntities: {call: types.ListEntities;response: types.ListEntitiesResponse;@@ -119,6 +139,10 @@ type ToolDataMap = {response: types.ReadMetadataResponse;};ReadThread: { call: types.ReadThread; response: types.ReadResponse };+ SetEntityProperty: {+ call: types.SetEntityProperty;+ response: types.SetEntityPropertyResponse;+ };text_editor_code_execution: {call: types.TextEditorCodeExecutionToolCall;response: types.TextEditorCodeExecutionResponse;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 d2620a7166..c6464fc4b0 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@@ -622,6 +622,92 @@ export interface CreateDocumentResponse {documentId: 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.+ */++/**+ * Get all properties attached to an entity (document, task, project, etc.). Returns property definitions with their current values and available options for select-type properties. Use this to discover custom properties on an entity. For tasks, system properties (Assignees, Status, Priority, Due Date, etc.) are always present — you can update them directly with SetEntityProperty using well-known IDs without calling this first.+ */+export interface GetEntityProperties {+ /**+ * The ID of the entity to get properties for.+ */+ entity_id: string;+ /**+ * The type of entity.+ */+ entity_type: 'document' | 'task' | 'project' | 'chat' | 'thread' | 'channel';+}++/* 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 the GetEntityProperties tool.+ */+export interface GetEntityPropertiesResponse {+ /**+ * The properties attached to the entity.+ */+ properties: {+ /**+ * The current value, if set.+ */+ currentValue?: {+ [k: string]: unknown;+ };+ /**+ * The data type (boolean, date, number, string, select_number, select_string, entity, link).+ */+ dataType: string;+ /**+ * Human-readable name of the property.+ */+ displayName: string;+ /**+ * Whether this property supports multiple values.+ */+ isMultiSelect: boolean;+ /**+ * Whether this is a system-defined property.+ */+ isSystem: boolean;+ /**+ * Available options for select-type properties.+ */+ options: {+ /**+ * Display order.+ */+ displayOrder: number;+ /**+ * The display value of this option.+ */+ displayValue: string;+ /**+ * The option ID to use when setting select values.+ */+ id: string;+ }[];+ /**+ * The property definition ID. Use this when calling SetEntityProperty.+ */+ propertyDefinitionId: string;+ }[];+ /**+ * Human-readable summary.+ */+ summary: string;+}+/* eslint-disable *//*** This file was automatically generated by json-schema-to-typescript.@@ -950,6 +1036,111 @@ 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.+ */++/**+ * Set or update a property value on an entity (document, task, project, etc.). Provide the property_definition_id and exactly one value field matching the property's data type.+ *+ * Tasks always have these system properties (use these property_definition_id values directly):+ * - Assignees (00000001-0000-0000-0000-000000000001): entity type, multi-select. Use entity_refs with entity_type='user' and entity_id='macro|[email protected]'.+ * - Status (00000001-0000-0000-0000-000000000002): select_string, single. Options: Not Started (00000001-0000-0000-0002-000000000001), In Progress (...0002), In Review (...0003), Completed (...0004), Canceled (...0005).+ * - Priority (00000001-0000-0000-0000-000000000003): select_string, single. Options: Low (...0001), Medium (...0002), High (...0003), Critical (...0004). Option IDs: 00000001-0000-0000-0003-0000000000XX.+ * - Due Date (00000001-0000-0000-0000-000000000004): date, single. Use date_value with ISO 8601.+ * - Parent Task (00000001-0000-0000-0000-000000000005): entity, single. Use entity_ref with entity_type='task'.+ * - Subtasks (00000001-0000-0000-0000-000000000006): entity, multi. Use entity_refs with entity_type='task'.+ * - Story Points (00000001-0000-0000-0000-000000000009): number, single. Use number_value.+ *+ * For non-system or custom properties, call GetEntityProperties first to discover property_definition_id values and options.+ */+export interface SetEntityProperty {+ /**+ * For boolean properties.+ */+ boolean_value: boolean | null;+ /**+ * For date properties (ISO 8601 date-time).+ */+ date_value: string | null;+ /**+ * The ID of the entity to update.+ */+ entity_id: string;+ /**+ * For single entity reference properties.+ */+ entity_ref: {+ entityId: string;+ entityType: 'document' | 'task' | 'project' | 'chat' | 'thread' | 'channel';+ } | null;+ /**+ * For multi entity reference properties.+ */+ entity_refs:+ | {+ entityId: string;+ entityType:+ | 'document'+ | 'task'+ | 'project'+ | 'chat'+ | 'thread'+ | 'channel';+ }[]+ | null;+ /**+ * The type of entity.+ */+ entity_type: 'document' | 'task' | 'project' | 'chat' | 'thread' | 'channel';+ /**+ * For single link properties.+ */+ link_url: string | null;+ /**+ * For multi link properties.+ */+ link_urls: string[] | null;+ /**+ * For number properties.+ */+ number_value: number | null;+ /**+ * For single-select properties. The option UUID from available options.+ */+ option_id: string | null;+ /**+ * For multi-select properties. The option UUIDs from available options.+ */+ option_ids: string[] | null;+ /**+ * The property definition ID. Get this from GetEntityProperties results.+ */+ property_definition_id: string;+ /**+ * For string properties.+ */+ string_value: string | 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 the SetEntityProperty tool.+ */+export interface SetEntityPropertyResponse {+ message: string;+ success: boolean;+}+/* 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 de8175ac1c..afb174773c 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -108,12 +108,15 @@ dependencies = ["lazy_static","macro_db_client","model",+ "model_notifications","models_dcs","models_email","models_pagination","models_permissions","models_properties","models_search",+ "notification",+ "properties","rand 0.9.0","schemars","scribe",@@ -2922,6 +2925,7 @@ dependencies = ["models_opensearch","models_permissions","notification",+ "properties","redis","regex","reqwest",@@ -6103,6 +6107,7 @@ dependencies = ["macro_user_id","macro_uuid","model_user",+ "properties","scribe","search_service_client","serde",@@ -7603,7 +7608,10 @@ dependencies = [name = "properties"version = "0.1.0"dependencies = [+ "ai","anyhow",+ "async-trait",+ "chrono","email_db_client","futures","macro_db_client",@@ -7617,6 +7625,7 @@ dependencies = ["models_permissions","models_properties","notification",+ "schemars","serde","serde_json","sqlx",diff --git a/rust/cloud-storage/ai_tools/Cargo.toml b/rust/cloud-storage/ai_tools/Cargo.tomlindex f17efd763a..5b1dc22c39 100644--- a/rust/cloud-storage/ai_tools/Cargo.toml+++ b/rust/cloud-storage/ai_tools/Cargo.toml@@ -27,10 +27,12 @@ item_filters = { path = "../item_filters" }lazy_static.workspace = truemacro_db_client = { path = "../macro_db_client" }model = { path = "../model" }+model_notifications = { path = "../model_notifications" }models_dcs = { path = "../models_dcs" }models_email = { path = "../models_email" }models_pagination = { path = "../models_pagination" }models_permissions = { path = "../models_permissions" }+notification = { path = "../notification" }models_properties = { path = "../models_properties" }models_search = { path = "../models_search" }rand.workspace = true@@ -45,6 +47,7 @@ scribe = { path = "../scribe", features = [search_service_client = { path = "../search_service_client" }serde.workspace = trueserde_json.workspace = true+properties = { path = "../properties", features = ["ai_tools"] }soup = { path = "../soup", features = ["ai_tools", "outbound"] }sqlx.workspace = truestrum.workspace = truediff --git a/rust/cloud-storage/ai_tools/src/lib.rs b/rust/cloud-storage/ai_tools/src/lib.rsindex ea5fc73bd8..048f4f9ff5 100644--- a/rust/cloud-storage/ai_tools/src/lib.rs+++ b/rust/cloud-storage/ai_tools/src/lib.rs@@ -15,6 +15,7 @@ use code_execution::{anthropic_bash_code_execution_tool, anthropic_text_editor_code_execution_tool,};use documents::inbound::toolset::document_toolset;+use properties::inbound::toolset::properties_toolset;use search::web::anthropic_web_search::anthropic_web_search_tool;use soup::inbound::toolset::{ListEntities, SoupToolContext};use std::sync::Arc;@@ -48,7 +49,9 @@ pub fn all_tools() -> ToolSetWithPrompt {.add_tool::<read::ReadThread, Arc<ToolScribe>>().expect("read thread tool").add_subtoolset::<ToolDocumentToolContext>(document_toolset())- .expect("failed to add document toolset");+ .expect("failed to add document toolset")+ .add_subtoolset::<ToolPropertiesToolContext>(properties_toolset())+ .expect("failed to add properties toolset");let prompt = prompts::TOOLS_PROMPT;let toolset = Arc::new(toolset);ToolSetWithPrompt { toolset, prompt }diff --git a/rust/cloud-storage/ai_tools/src/tool_context.rs b/rust/cloud-storage/ai_tools/src/tool_context.rsindex 2bc53272e6..78f52029f9 100644--- a/rust/cloud-storage/ai_tools/src/tool_context.rs+++ b/rust/cloud-storage/ai_tools/src/tool_context.rs@@ -12,6 +12,7 @@ use documents::{use email::{domain::service::EmailServiceImpl, outbound::EmailPgRepo};use entity_access::{domain::service::EntityAccessServiceImpl, outbound::PgAccessRepository};use frecency::{domain::services::FrecencyQueryServiceImpl, outbound::postgres::FrecencyPgStorage};+use properties::inbound::toolset::PropertiesToolContext;use scribe::{ScribeClient, channel::ChannelClient, dcs::DcsClient, document::DocumentClient,email::EmailClient, static_file::StaticFileClient,@@ -95,6 +96,35 @@ pub type ToolDocumentToolContext =pub type ToolSoupService =SoupImpl<PgSoupRepo, ToolFrecencyService, ToolEmailService, ToolCommsService>;+/// No-op notification service for properties (tools don't send assignment notifications)+#[derive(Clone)]+pub struct NoOpNotificationService;++impl properties::NotificationService for NoOpNotificationService {+ type Err = anyhow::Error;++ async fn send_notification<'a>(+ &self,+ _message: notification::domain::models::SendNotificationRequest<+ 'a,+ model_notifications::TaskAssignedMetadata,+ notification::domain::models::apple::PushNotificationData,+ >,+ ) -> Result<uuid::Uuid, Self::Err> {+ Ok(uuid::Uuid::nil())+ }+}++/// Type alias for the properties service implementation used by AI tools+pub type ToolPropertiesService = properties::PropertiesServiceImpl<+ properties::PropertiesPgRepo,+ properties::PermissionServiceImpl,+ NoOpNotificationService,+>;++/// Type alias for the properties tool context+pub type ToolPropertiesToolContext = PropertiesToolContext<ToolPropertiesService>;+/// The full service context containing all API clients./// Individual tools should extract only the clients they need via `FromRef`.#[derive(Clone, FromRef)]@@ -104,6 +134,7 @@ pub struct ToolServiceContext {pub scribe: Arc<ToolScribe>,pub soup_service: Arc<ToolSoupService>,pub document_tool_context: ToolDocumentToolContext,+ pub properties_tool_context: ToolPropertiesToolContext,}impl FromRef<ToolServiceContext> for ai_toolset::NoContext {diff --git a/rust/cloud-storage/document_cognition_service/Cargo.toml b/rust/cloud-storage/document_cognition_service/Cargo.tomlindex 7c5749c824..c925e9c7e5 100644--- a/rust/cloud-storage/document_cognition_service/Cargo.toml+++ b/rust/cloud-storage/document_cognition_service/Cargo.toml@@ -80,6 +80,7 @@ macro_entrypoint = { path = "../macro_entrypoint" }macro_env = { path = "../macro_env" }macro_env_var = { path = "../macro_env_var" }notification = { path = "../notification" }+properties = { path = "../properties", features = ["ai_tools"] }macro_middleware = { path = "../macro_middleware", default-features = false, features = ["auth","cloud_storage",diff --git a/rust/cloud-storage/document_cognition_service/src/api/chats/tool/post.rs b/rust/cloud-storage/document_cognition_service/src/api/chats/tool/post.rsindex c775ecd62a..d0663adf2b 100644--- a/rust/cloud-storage/document_cognition_service/src/api/chats/tool/post.rs+++ b/rust/cloud-storage/document_cognition_service/src/api/chats/tool/post.rs@@ -162,6 +162,7 @@ pub async fn handler(scribe: state.scribe.clone(),soup_service: state.soup_service.clone(),document_tool_context: state.document_tool_context.clone(),+ properties_tool_context: state.properties_tool_context.clone(),};#[expect(deprecated)]diff --git a/rust/cloud-storage/document_cognition_service/src/api/context/mod.rs b/rust/cloud-storage/document_cognition_service/src/api/context/mod.rsindex 941645a608..bae25d2ac6 100644--- a/rust/cloud-storage/document_cognition_service/src/api/context/mod.rs+++ b/rust/cloud-storage/document_cognition_service/src/api/context/mod.rs@@ -1,5 +1,5 @@use crate::config::Config;-use ai_tools::{ToolDocumentToolContext, ToolSoupService};+use ai_tools::{ToolDocumentToolContext, ToolPropertiesToolContext, ToolSoupService};use axum::extract::FromRef;use connection_gateway::service::connection::ConnectionRepo;use document_storage_service_client::DocumentStorageServiceClient;@@ -48,6 +48,7 @@ pub struct ApiContext {pub stream_repo: Arc<dyn StreamRepo>,pub document_tool_context: ToolDocumentToolContext,pub memory_service: Arc<DcsMemoryService>,+ pub properties_tool_context: ToolPropertiesToolContext,}pub static GLOBAL_CONTEXT: OnceLock<ApiContext> = OnceLock::new();diff --git a/rust/cloud-storage/document_cognition_service/src/api/context/test.rs b/rust/cloud-storage/document_cognition_service/src/api/context/test.rsindex 2315e22f63..466f3bdf06 100644--- a/rust/cloud-storage/document_cognition_service/src/api/context/test.rs+++ b/rust/cloud-storage/document_cognition_service/src/api/context/test.rs@@ -252,12 +252,22 @@ pub async fn test_api_context(pool: sqlx::Pool<sqlx::Postgres>) -> std::sync::Arlet search_service_client = Arc::new(search_service_client);let scribe = Arc::new(content_client);+ // Build properties tool context+ let properties_service = properties::PropertiesServiceImpl::new(+ properties::PropertiesPgRepo::new(pool.clone()),+ Some(properties::PermissionServiceImpl::new(pool.clone())),+ Some(ai_tools::NoOpNotificationService),+ );+ let properties_tool_context =+ properties::inbound::toolset::PropertiesToolContext::new(properties_service);+let memory_tool_context = ai_tools::ToolServiceContext {search_service_client: search_service_client.clone(),email_service_client: email_service_client_external.clone(),scribe: scribe.clone(),soup_service: soup_service.clone(),document_tool_context: document_tool_context.clone(),+ properties_tool_context: properties_tool_context.clone(),};let memory_repo = memory::outbound::pg_memory_repo::PgMemoryRepo::new(pool.clone());let memory_service = Arc::new(memory::domain::service::MemoryServiceImpl::new(@@ -284,6 +294,7 @@ pub async fn test_api_context(pool: sqlx::Pool<sqlx::Postgres>) -> std::sync::Arstream_repo: MockStreamRepo::new(),document_tool_context,memory_service,+ properties_tool_context,};Arc::new(api_context)}diff --git a/rust/cloud-storage/document_cognition_service/src/api/stream/chat_message.rs b/rust/cloud-storage/document_cognition_service/src/api/stream/chat_message.rsindex e153e551d9..4a0e910ef9 100644--- a/rust/cloud-storage/document_cognition_service/src/api/stream/chat_message.rs+++ b/rust/cloud-storage/document_cognition_service/src/api/stream/chat_message.rs@@ -363,6 +363,7 @@ fn stream_and_save_message(scribe: ctx.scribe.clone(),soup_service: ctx.soup_service.clone(),document_tool_context: ctx.document_tool_context.clone(),+ properties_tool_context: ctx.properties_tool_context.clone(),};#[expect(deprecated)]diff --git a/rust/cloud-storage/document_cognition_service/src/bin/mcp_server.rs b/rust/cloud-storage/document_cognition_service/src/bin/mcp_server.rsindex b7e2353c89..8921d5f126 100644--- a/rust/cloud-storage/document_cognition_service/src/bin/mcp_server.rs+++ b/rust/cloud-storage/document_cognition_service/src/bin/mcp_server.rs@@ -4,7 +4,9 @@//! tools that are available in the DCS chat/stream API, with OAuth 2.1//! authentication backed by FusionAuth.-use ai_tools::{NoOpConnectionService, NoOpTaskProperties, ToolServiceContext};+use ai_tools::{+ NoOpConnectionService, NoOpNotificationService, NoOpTaskProperties, ToolServiceContext,+};use anyhow::Context;use comms::domain::service::ChannelServiceImpl;use comms::outbound::postgres::comms_repo::PgCommsRepo;@@ -234,6 +236,15 @@ async fn main() -> anyhow::Result<()> {lexical_client_for_tools,);+ // Build properties tool context+ let properties_service = properties::PropertiesServiceImpl::new(+ properties::PropertiesPgRepo::new(db.clone()),+ Some(properties::PermissionServiceImpl::new(db.clone())),+ Some(NoOpNotificationService),+ );+ let properties_tool_context =+ properties::inbound::toolset::PropertiesToolContext::new(properties_service);+// Build the ToolServiceContextlet tool_context = ToolServiceContext {email_service_client: Arc::new(EmailServiceClientExternal::new(@@ -260,6 +271,7 @@ async fn main() -> anyhow::Result<()> {),soup_service,document_tool_context,+ properties_tool_context,};tracing::info!("initialized tool context");diff --git a/rust/cloud-storage/document_cognition_service/src/main.rs b/rust/cloud-storage/document_cognition_service/src/main.rsindex 79b4d11fe3..9d98e2b08d 100644--- a/rust/cloud-storage/document_cognition_service/src/main.rs+++ b/rust/cloud-storage/document_cognition_service/src/main.rs@@ -1,6 +1,6 @@#![recursion_limit = "256"]use crate::api::context::ApiContext;-use ai_tools::{NoOpConnectionService, NoOpTaskProperties};+use ai_tools::{NoOpConnectionService, NoOpNotificationService, NoOpTaskProperties};use anyhow::Context;use comms::domain::service::ChannelServiceImpl;use comms::outbound::postgres::comms_repo::PgCommsRepo;@@ -269,6 +269,17 @@ async fn main() -> anyhow::Result<()> {);let search_service_client = Arc::new(search_service_client);+ // Build properties tool context for AI tools+ let properties_service = properties::PropertiesServiceImpl::new(+ properties::PropertiesPgRepo::new(db.clone()),+ Some(properties::PermissionServiceImpl::new(db.clone())),+ Some(NoOpNotificationService),+ );+ let properties_tool_context =+ properties::inbound::toolset::PropertiesToolContext::new(properties_service);++ tracing::info!("initialized properties tool context");+// Build memory servicelet memory_tool_context = ai_tools::ToolServiceContext {search_service_client: search_service_client.clone(),@@ -276,6 +287,7 @@ async fn main() -> anyhow::Result<()> {scribe: scribe.clone(),soup_service: soup_service.clone(),document_tool_context: document_tool_context.clone(),+ properties_tool_context: properties_tool_context.clone(),};let memory_repo = memory::outbound::pg_memory_repo::PgMemoryRepo::new(db.clone());let memory_service = Arc::new(memory::domain::service::MemoryServiceImpl::new(@@ -304,6 +316,7 @@ async fn main() -> anyhow::Result<()> {stream_repo,document_tool_context,memory_service,+ properties_tool_context,}).await.context("failed to setup and serve api")?;diff --git a/rust/cloud-storage/macro_db_client/.sqlx/query-cf71680da3444f573f4cddf66b6269bfe31aeee4bbec34b7e6067a855e28f2b7.json b/rust/cloud-storage/macro_db_client/.sqlx/query-cf71680da3444f573f4cddf66b6269bfe31aeee4bbec34b7e6067a855e28f2b7.jsonnew file mode 100644index 0000000000..9dc9838dc0--- /dev/null+++ b/rust/cloud-storage/macro_db_client/.sqlx/query-cf71680da3444f573f4cddf66b6269bfe31aeee4bbec34b7e6067a855e28f2b7.json@@ -0,0 +1,15 @@+{+ "db_name": "PostgreSQL",+ "query": "\n UPDATE entity_properties\n SET values = $2\n WHERE entity_id = $1;\n ",+ "describe": {+ "columns": [],+ "parameters": {+ "Left": [+ "Text",+ "Jsonb"+ ]+ },+ "nullable": []+ },+ "hash": "cf71680da3444f573f4cddf66b6269bfe31aeee4bbec34b7e6067a855e28f2b7"+}diff --git a/rust/cloud-storage/memory/Cargo.toml b/rust/cloud-storage/memory/Cargo.tomlindex ddc2ca24cf..4fc483b8b4 100644--- a/rust/cloud-storage/memory/Cargo.toml+++ b/rust/cloud-storage/memory/Cargo.toml@@ -41,6 +41,7 @@ document_cognition_service_client = { path = "../document_cognition_service_cliestatic_file_service_client = { path = "../static_file_service_client" }sync_service_client = { path = "../sync_service_client" }soup = { path = "../soup", features = ["all"] }+properties = { path = "../properties" }macro_aws_config = { path = "../macro_aws_config" }[dev-dependencies]diff --git a/rust/cloud-storage/memory/src/context.rs b/rust/cloud-storage/memory/src/context.rsindex 85d7e90e31..3348dd68cd 100644--- a/rust/cloud-storage/memory/src/context.rs+++ b/rust/cloud-storage/memory/src/context.rs@@ -1,4 +1,6 @@-use ai_tools::{NoOpConnectionService, NoOpTaskProperties, ToolServiceContext};+use ai_tools::{+ NoOpConnectionService, NoOpNotificationService, NoOpTaskProperties, ToolServiceContext,+};use comms::domain::service::ChannelServiceImpl;use comms::outbound::postgres::comms_repo::PgCommsRepo;use comms::outbound::postgres::user_repo::PgUserRepo;@@ -143,11 +145,21 @@ pub async fn build_tool_service_context(pool: sqlx::PgPool) -> anyhow::Result<Tolet document_tool_context =DocumentToolContext::new(document_service, entity_access_service, lexical_client);+ // Properties tool context+ let properties_service = properties::PropertiesServiceImpl::new(+ properties::PropertiesPgRepo::new(pool.clone()),+ Some(properties::PermissionServiceImpl::new(pool.clone())),+ Some(NoOpNotificationService),+ );+ let properties_tool_context =+ properties::inbound::toolset::PropertiesToolContext::new(properties_service);+Ok(ToolServiceContext {search_service_client: search_client,email_service_client: email_ext_client,scribe,soup_service,document_tool_context,+ properties_tool_context,})}diff --git a/rust/cloud-storage/properties/.sqlx/query-4eef29ad204776f70531f685f709f4e18f2b4f992d73ad2b608b77869a7856a9.json b/rust/cloud-storage/properties/.sqlx/query-4eef29ad204776f70531f685f709f4e18f2b4f992d73ad2b608b77869a7856a9.jsonnew file mode 100644index 0000000000..0d82c0646c--- /dev/null+++ b/rust/cloud-storage/properties/.sqlx/query-4eef29ad204776f70531f685f709f4e18f2b4f992d73ad2b608b77869a7856a9.json@@ -0,0 +1,46 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT\n id,\n property_definition_id,\n display_order,\n string_value,\n number_value\n FROM property_options\n WHERE property_definition_id = ANY($1)\n ORDER BY display_order\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "property_definition_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 2,+ "name": "display_order",+ "type_info": "Int4"+ },+ {+ "ordinal": 3,+ "name": "string_value",+ "type_info": "Text"+ },+ {+ "ordinal": 4,+ "name": "number_value",+ "type_info": "Float8"+ }+ ],+ "parameters": {+ "Left": [+ "UuidArray"+ ]+ },+ "nullable": [+ false,+ false,+ false,+ true,+ true+ ]+ },+ "hash": "4eef29ad204776f70531f685f709f4e18f2b4f992d73ad2b608b77869a7856a9"+}diff --git a/rust/cloud-storage/properties/.sqlx/query-8d5ffbdd5be9b1031c7da47bc2d4bcbee35802a575387ef081a09031b42f7de9.json b/rust/cloud-storage/properties/.sqlx/query-8d5ffbdd5be9b1031c7da47bc2d4bcbee35802a575387ef081a09031b42f7de9.jsonnew file mode 100644index 0000000000..4860272b0d--- /dev/null+++ b/rust/cloud-storage/properties/.sqlx/query-8d5ffbdd5be9b1031c7da47bc2d4bcbee35802a575387ef081a09031b42f7de9.json@@ -0,0 +1,85 @@+{+ "db_name": "PostgreSQL",+ "query": "\n SELECT\n ep.property_definition_id,\n pd.display_name,\n pd.data_type as \"data_type: DataType\",\n pd.is_multi_select,\n pd.is_system,\n ep.values as \"values: serde_json::Value\"\n FROM entity_properties ep\n INNER JOIN property_definitions pd ON pd.id = ep.property_definition_id\n WHERE ep.entity_id = $1\n AND ep.entity_type = $2\n ORDER BY LOWER(pd.display_name)\n ",+ "describe": {+ "columns": [+ {+ "ordinal": 0,+ "name": "property_definition_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 1,+ "name": "display_name",+ "type_info": "Text"+ },+ {+ "ordinal": 2,+ "name": "data_type: DataType",+ "type_info": {+ "Custom": {+ "name": "property_data_type",+ "kind": {+ "Enum": [+ "BOOLEAN",+ "DATE",+ "NUMBER",+ "STRING",+ "SELECT_NUMBER",+ "SELECT_STRING",+ "ENTITY",+ "LINK"+ ]+ }+ }+ }+ },+ {+ "ordinal": 3,+ "name": "is_multi_select",+ "type_info": "Bool"+ },+ {+ "ordinal": 4,+ "name": "is_system",+ "type_info": "Bool"+ },+ {+ "ordinal": 5,+ "name": "values: serde_json::Value",+ "type_info": "Jsonb"+ }+ ],+ "parameters": {+ "Left": [+ "Text",+ {+ "Custom": {+ "name": "property_entity_type",+ "kind": {+ "Enum": [+ "CHANNEL",+ "CHAT",+ "DOCUMENT",+ "PROJECT",+ "THREAD",+ "USER",+ "COMPANY",+ "TASK"+ ]+ }+ }+ }+ ]+ },+ "nullable": [+ false,+ false,+ false,+ false,+ false,+ true+ ]+ },+ "hash": "8d5ffbdd5be9b1031c7da47bc2d4bcbee35802a575387ef081a09031b42f7de9"+}diff --git a/rust/cloud-storage/properties/Cargo.toml b/rust/cloud-storage/properties/Cargo.tomlindex db9072670f..ed401b1505 100644--- a/rust/cloud-storage/properties/Cargo.toml+++ b/rust/cloud-storage/properties/Cargo.toml@@ -4,8 +4,19 @@ name = "properties"publish = falseversion = "0.1.0"+[features]+ai_tools = [+ "dep:ai",+ "dep:async-trait",+ "dep:chrono",+ "dep:schemars",+]+[dependencies]+ai = { path = "../ai", optional = true }anyhow = { workspace = true }+async-trait = { workspace = true, optional = true }+chrono = { workspace = true, optional = true }futures = { workspace = true }email_db_client = { path = "../email_db_client" }macro_db_client = { path = "../macro_db_client" }@@ -17,6 +28,7 @@ model_notifications = { path = "../model_notifications" }model-entity = { path = "../model-entity" }models_permissions = { path = "../models_permissions" }models_properties = { path = "../models_properties" }+schemars = { workspace = true, optional = true }serde = { workspace = true }serde_json = { workspace = true }sqlx = { workspace = true }@@ -26,8 +38,10 @@ tracing = { workspace = true }uuid = { workspace = true }[dev-dependencies]+ai = { path = "../ai" }mockall = { workspace = true }macro_db_migrator = { path = "../macro_db_migrator" }+serde_json = { workspace = true }tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }[package.metadata.sqlx]diff --git a/rust/cloud-storage/properties/src/domain.rs b/rust/cloud-storage/properties/src/domain.rsindex 9094ac7e03..e8b9ee5d3d 100644--- a/rust/cloud-storage/properties/src/domain.rs+++ b/rust/cloud-storage/properties/src/domain.rs@@ -1,4 +1,5 @@pub mod error;+pub mod model;pub mod ports;pub mod service;pub mod service_impl;diff --git a/rust/cloud-storage/properties/src/domain/model.rs b/rust/cloud-storage/properties/src/domain/model.rsnew file mode 100644index 0000000000..341d05ceb8--- /dev/null+++ b/rust/cloud-storage/properties/src/domain/model.rs@@ -0,0 +1,36 @@+//! Domain models for properties.++use models_properties::DataType;+use models_properties::service::property_option::PropertyOptionValue;+use models_properties::service::property_value::PropertyValue;+use uuid::Uuid;++/// Summary of a property attached to an entity, including its definition and current value.+#[derive(Debug, Clone)]+pub struct EntityPropertyInfo {+ /// The property definition ID (used to set values via `set_entity_property`).+ pub property_definition_id: Uuid,+ /// Human-readable name of the property.+ pub display_name: String,+ /// The data type of the property.+ pub data_type: DataType,+ /// Whether the property supports multiple values.+ pub is_multi_select: bool,+ /// Whether this is a system-defined property.+ pub is_system: bool,+ /// The current value of the property, if set.+ pub value: Option<PropertyValue>,+ /// Available options for select-type properties.+ pub options: Vec<PropertyOptionInfo>,+}++/// A selectable option for select-type properties.+#[derive(Debug, Clone)]+pub struct PropertyOptionInfo {+ /// The option ID (used when setting select values).+ pub id: Uuid,+ /// Display order for UI rendering.+ pub display_order: i32,+ /// The option's value.+ pub value: PropertyOptionValue,+}diff --git a/rust/cloud-storage/properties/src/domain/ports.rs b/rust/cloud-storage/properties/src/domain/ports.rsindex 06bd57cc46..b184740c77 100644--- a/rust/cloud-storage/properties/src/domain/ports.rs+++ b/rust/cloud-storage/properties/src/domain/ports.rs@@ -11,6 +11,8 @@ use models_properties::service::property_value::PropertyValue;use notification::domain::models::SendNotificationRequest;use uuid::Uuid;+use super::model::EntityPropertyInfo;+/// Repository trait for property operations.////// This trait abstracts the database layer, allowing for different implementations@@ -90,6 +92,14 @@ pub trait PropertiesRepo: Send + Sync + 'static {property_definition_id: Uuid,) -> impl Future<Output = Result<Option<PropertyValue>, Self::Err>> + Send;+ /// Get all properties attached to an entity, with definitions, values, and options.+ /// Returns properties sorted by display name.+ fn get_entity_properties(+ &self,+ entity_id: &str,+ entity_type: EntityType,+ ) -> impl Future<Output = Result<Vec<EntityPropertyInfo>, Self::Err>> + Send;+/// Get the name of a document./// Returns `None` if the document doesn't exist or has no name./// Tasks are stored as documents, so this works for both documents and tasks.diff --git a/rust/cloud-storage/properties/src/domain/service.rs b/rust/cloud-storage/properties/src/domain/service.rsindex 092752b2bb..7b98a4e9a8 100644--- a/rust/cloud-storage/properties/src/domain/service.rs+++ b/rust/cloud-storage/properties/src/domain/service.rs@@ -7,6 +7,7 @@ use system_properties::SystemPropertyKey;use uuid::Uuid;use super::error::PropertiesErr;+use super::model::EntityPropertyInfo;/// Service trait for property operations.pub trait PropertiesService: Send + Sync + 'static {@@ -45,6 +46,13 @@ pub trait PropertiesService: Send + Sync + 'static {subtask_ids: Vec<Uuid>,) -> impl Future<Output = Result<(), PropertiesErr>> + Send;+ /// Get all properties attached to an entity, with definitions, values, and options.+ fn get_entity_properties(+ &self,+ entity_id: &str,+ entity_type: EntityType,+ ) -> impl Future<Output = Result<Vec<EntityPropertyInfo>, PropertiesErr>> + Send;+/// Get a property value for an entity by property definition ID./// Returns `None` if the property is not attached to the entity.fn get_property_value(diff --git a/rust/cloud-storage/properties/src/domain/service_impl/mod.rs b/rust/cloud-storage/properties/src/domain/service_impl/mod.rsindex d42d166975..f71d7737f3 100644--- a/rust/cloud-storage/properties/src/domain/service_impl/mod.rs+++ b/rust/cloud-storage/properties/src/domain/service_impl/mod.rs@@ -11,6 +11,7 @@ use system_properties::{StatusOption, SystemPropertyKey};use uuid::Uuid;use super::error::PropertiesErr;+use super::model::EntityPropertyInfo;use super::ports::{NotificationService, PermissionService, PropertiesRepo};use super::service::PropertiesService;@@ -143,6 +144,19 @@ whereOk(())}+ #[tracing::instrument(skip(self), fields(entity_id = %entity_id, entity_type = ?entity_type), err)]+ async fn get_entity_properties(+ &self,+ entity_id: &str,+ entity_type: EntityType,+ ) -> Result<Vec<EntityPropertyInfo>, PropertiesErr> {+ Ok(self+ .repository+ .get_entity_properties(entity_id, entity_type)+ .await+ .map_err(anyhow::Error::from)?)+ }+#[tracing::instrument(skip(self), fields(entity_id = %entity_id, entity_type = ?entity_type, property_definition_id = %property_definition_id))]async fn get_property_value(&self,diff --git a/rust/cloud-storage/properties/src/inbound.rs b/rust/cloud-storage/properties/src/inbound.rsnew file mode 100644index 0000000000..aafe2c65cb--- /dev/null+++ b/rust/cloud-storage/properties/src/inbound.rs@@ -0,0 +1,2 @@+#[cfg(feature = "ai_tools")]+pub mod toolset;diff --git a/rust/cloud-storage/properties/src/inbound/toolset/get_entity_properties.rs b/rust/cloud-storage/properties/src/inbound/toolset/get_entity_properties.rsnew file mode 100644index 0000000000..ab623f3f9b--- /dev/null+++ b/rust/cloud-storage/properties/src/inbound/toolset/get_entity_properties.rs@@ -0,0 +1,191 @@+//! GetEntityProperties tool for reading properties attached to an entity.++use crate::domain::model::{EntityPropertyInfo, PropertyOptionInfo};+use crate::domain::service::PropertiesService;+use ai::tool::{AsyncTool, RequestContext, ServiceContext, ToolCallError, ToolResult};+use async_trait::async_trait;+use models_properties::service::property_option::PropertyOptionValue;+use models_properties::service::property_value::PropertyValue;+use models_properties::{DataType, EntityType};+use schemars::JsonSchema;+use serde::{Deserialize, Serialize};+use uuid::Uuid;++use super::PropertiesToolContext;++#[derive(Debug, Clone, Copy, Deserialize, JsonSchema)]+#[serde(rename_all = "snake_case")]+pub enum ToolEntityType {+ Document,+ Task,+ Project,+ Chat,+ Thread,+ Channel,+}++impl From<ToolEntityType> for EntityType {+ fn from(t: ToolEntityType) -> Self {+ match t {+ ToolEntityType::Document => EntityType::Document,+ ToolEntityType::Task => EntityType::Task,+ ToolEntityType::Project => EntityType::Project,+ ToolEntityType::Chat => EntityType::Chat,+ ToolEntityType::Thread => EntityType::Thread,+ ToolEntityType::Channel => EntityType::Channel,+ }+ }+}++#[derive(Debug, Deserialize, JsonSchema)]+#[schemars(+ title = "GetEntityProperties",+ description = "Get all properties attached to an entity (document, task, project, etc.). Returns property definitions with their current values and available options for select-type properties. Use this to discover custom properties on an entity. For tasks, system properties (Assignees, Status, Priority, Due Date, etc.) are always present — you can update them directly with SetEntityProperty using well-known IDs without calling this first."+)]+pub struct GetEntityProperties {+ #[schemars(description = "The ID of the entity to get properties for.")]+ pub entity_id: String,++ #[schemars(description = "The type of entity.")]+ pub entity_type: ToolEntityType,+}++/// A property option in the tool response.+#[derive(Debug, Serialize, JsonSchema)]+#[serde(rename_all = "camelCase")]+pub struct ToolPropertyOption {+ /// The option ID to use when setting select values.+ pub id: Uuid,+ /// Display order.+ pub display_order: i32,+ /// The display value of this option.+ pub display_value: String,+}++/// A single property in the tool response.+#[derive(Debug, Serialize, JsonSchema)]+#[serde(rename_all = "camelCase")]+pub struct ToolPropertyItem {+ /// The property definition ID. Use this when calling SetEntityProperty.+ pub property_definition_id: Uuid,+ /// Human-readable name of the property.+ pub display_name: String,+ /// The data type (boolean, date, number, string, select_number, select_string, entity, link).+ pub data_type: String,+ /// Whether this property supports multiple values.+ pub is_multi_select: bool,+ /// Whether this is a system-defined property.+ pub is_system: bool,+ /// The current value, if set.+ pub current_value: Option<serde_json::Value>,+ /// Available options for select-type properties.+ #[serde(skip_serializing_if = "Vec::is_empty")]+ pub options: Vec<ToolPropertyOption>,+}++/// Response from the GetEntityProperties tool.+#[derive(Debug, Serialize, JsonSchema)]+#[serde(rename_all = "camelCase")]+pub struct GetEntityPropertiesResponse {+ /// The properties attached to the entity.+ pub properties: Vec<ToolPropertyItem>,+ /// Human-readable summary.+ pub summary: String,+}++#[async_trait]+impl<T> AsyncTool<PropertiesToolContext<T>> for GetEntityProperties+where+ T: PropertiesService,+{+ type Output = GetEntityPropertiesResponse;++ #[tracing::instrument(skip_all, fields(user_id=?request_context.user_id, entity_id=%self.entity_id), err)]+ async fn call(+ &self,+ service_context: ServiceContext<PropertiesToolContext<T>>,+ request_context: RequestContext,+ ) -> ToolResult<Self::Output> {+ tracing::info!(params=?self, "Get entity properties");+ let _ = &request_context;++ let entity_type = EntityType::from(self.entity_type);++ let props = service_context+ .service+ .get_entity_properties(&self.entity_id, entity_type)+ .await+ .map_err(|e| ToolCallError {+ description: format!("Failed to get entity properties: {e}"),+ internal_error: e.into(),+ })?;++ let properties: Vec<ToolPropertyItem> = props.into_iter().map(to_tool_property).collect();++ let summary = if properties.is_empty() {+ "No properties attached to this entity.".to_string()+ } else {+ let set_count = properties+ .iter()+ .filter(|p| p.current_value.is_some())+ .count();+ format!(+ "Found {} propert{} ({} with values set).",+ properties.len(),+ if properties.len() == 1 { "y" } else { "ies" },+ set_count,+ )+ };++ Ok(GetEntityPropertiesResponse {+ properties,+ summary,+ })+ }+}++fn to_tool_property(info: EntityPropertyInfo) -> ToolPropertyItem {+ let data_type = match info.data_type {+ DataType::Boolean => "boolean",+ DataType::Date => "date",+ DataType::Number => "number",+ DataType::String => "string",+ DataType::SelectNumber => "select_number",+ DataType::SelectString => "select_string",+ DataType::Entity => "entity",+ DataType::Link => "link",+ }+ .to_string();++ let current_value = info.value.map(|v| property_value_to_json(&v));++ let options = info.options.into_iter().map(to_tool_option).collect();++ ToolPropertyItem {+ property_definition_id: info.property_definition_id,+ display_name: info.display_name,+ data_type,+ is_multi_select: info.is_multi_select,+ is_system: info.is_system,+ current_value,+ options,+ }+}++fn property_value_to_json(value: &PropertyValue) -> serde_json::Value {+ // Serialize the PropertyValue directly - it has good serde representation+ serde_json::to_value(value).unwrap_or(serde_json::Value::Null)+}++fn to_tool_option(opt: PropertyOptionInfo) -> ToolPropertyOption {+ let display_value = match &opt.value {+ PropertyOptionValue::String(s) => s.clone(),+ PropertyOptionValue::Number(n) => n.to_string(),+ };++ ToolPropertyOption {+ id: opt.id,+ display_order: opt.display_order,+ display_value,+ }+}diff --git a/rust/cloud-storage/properties/src/inbound/toolset/mod.rs b/rust/cloud-storage/properties/src/inbound/toolset/mod.rsnew file mode 100644index 0000000000..de999bd2f1--- /dev/null+++ b/rust/cloud-storage/properties/src/inbound/toolset/mod.rs@@ -0,0 +1,49 @@+//! Toolset inbound adapter for the Properties service.++mod get_entity_properties;+mod set_entity_property;++#[cfg(test)]+mod test;++use crate::domain::service::PropertiesService;+use ai::tool::AsyncToolSet;+use std::sync::Arc;++pub use get_entity_properties::{GetEntityProperties, GetEntityPropertiesResponse};+pub use set_entity_property::{SetEntityProperty, SetEntityPropertyResponse};++/// Service context for properties AI tools.+pub struct PropertiesToolContext<T: PropertiesService> {+ /// The properties service instance.+ pub service: Arc<T>,+}++impl<T: PropertiesService> Clone for PropertiesToolContext<T> {+ fn clone(&self) -> Self {+ Self {+ service: self.service.clone(),+ }+ }+}++impl<T: PropertiesService> PropertiesToolContext<T> {+ /// Create a new properties tool context.+ pub fn new(service: T) -> Self {+ Self {+ service: Arc::new(service),+ }+ }+}++/// Create a properties toolset.+pub fn properties_toolset<T>() -> AsyncToolSet<PropertiesToolContext<T>>+where+ T: PropertiesService,+{+ AsyncToolSet::new()+ .add_tool::<GetEntityProperties, PropertiesToolContext<T>>()+ .expect("failed to add GetEntityProperties tool")+ .add_tool::<SetEntityProperty, PropertiesToolContext<T>>()+ .expect("failed to add SetEntityProperty tool")+}diff --git a/rust/cloud-storage/properties/src/inbound/toolset/set_entity_property.rs b/rust/cloud-storage/properties/src/inbound/toolset/set_entity_property.rsnew file mode 100644index 0000000000..8a9e1b5e6c--- /dev/null+++ b/rust/cloud-storage/properties/src/inbound/toolset/set_entity_property.rs@@ -0,0 +1,218 @@+//! SetEntityProperty tool for updating property values on entities.++use crate::domain::service::PropertiesService;+use ai::tool::{AsyncTool, RequestContext, ServiceContext, ToolCallError, ToolResult};+use async_trait::async_trait;+use chrono::{DateTime, Utc};+use models_properties::EntityType;+use models_properties::api::requests::SetPropertyValue;+use models_properties::shared::EntityReference;+use schemars::JsonSchema;+use serde::{Deserialize, Serialize};+use uuid::Uuid;++use super::PropertiesToolContext;+use super::get_entity_properties::ToolEntityType;++#[derive(Debug, Clone, Deserialize, JsonSchema)]+#[serde(rename_all = "camelCase")]+pub struct ToolEntityRef {+ pub entity_type: ToolEntityType,+ pub entity_id: String,+}++/// How to determine which value field is active, based on the property data type from+/// GetEntityProperties. The AI must set the matching field:+/// - boolean → boolean_value+/// - date → date_value+/// - number → number_value+/// - string → string_value+/// - select_string/select_number (single) → option_id+/// - select_string/select_number (multi) → option_ids+/// - entity (single) → entity_ref+/// - entity (multi) → entity_refs+/// - link (single) → link_url+/// - link (multi) → link_urls+#[derive(Debug, Deserialize, JsonSchema)]+#[schemars(+ title = "SetEntityProperty",+ description = "Set or update a property value on an entity (document, task, project, etc.). Provide the property_definition_id and exactly one value field matching the property's data type.++Tasks always have these system properties (use these property_definition_id values directly):+- Assignees (00000001-0000-0000-0000-000000000001): entity type, multi-select. Use entity_refs with entity_type='user' and entity_id='macro|[email protected]'.+- Status (00000001-0000-0000-0000-000000000002): select_string, single. Options: Not Started (00000001-0000-0000-0002-000000000001), In Progress (...0002), In Review (...0003), Completed (...0004), Canceled (...0005).+- Priority (00000001-0000-0000-0000-000000000003): select_string, single. Options: Low (...0001), Medium (...0002), High (...0003), Critical (...0004). Option IDs: 00000001-0000-0000-0003-0000000000XX.+- Due Date (00000001-0000-0000-0000-000000000004): date, single. Use date_value with ISO 8601.+- Parent Task (00000001-0000-0000-0000-000000000005): entity, single. Use entity_ref with entity_type='task'.+- Subtasks (00000001-0000-0000-0000-000000000006): entity, multi. Use entity_refs with entity_type='task'.+- Story Points (00000001-0000-0000-0000-000000000009): number, single. Use number_value.++For non-system or custom properties, call GetEntityProperties first to discover property_definition_id values and options."+)]+#[serde(rename_all = "snake_case")]+pub struct SetEntityProperty {+ #[schemars(description = "The ID of the entity to update.")]+ pub entity_id: String,++ #[schemars(description = "The type of entity.")]+ pub entity_type: ToolEntityType,++ #[schemars(+ description = "The property definition ID. Get this from GetEntityProperties results."+ )]+ pub property_definition_id: Uuid,++ #[schemars(description = "For boolean properties.")]+ #[serde(default)]+ pub boolean_value: Option<bool>,++ #[schemars(description = "For date properties (ISO 8601 date-time).")]+ #[serde(default)]+ pub date_value: Option<DateTime<Utc>>,++ #[schemars(description = "For number properties.")]+ #[serde(default)]+ pub number_value: Option<f64>,++ #[schemars(description = "For string properties.")]+ #[serde(default)]+ pub string_value: Option<String>,++ #[schemars(+ description = "For single-select properties. The option UUID from available options."+ )]+ #[serde(default)]+ pub option_id: Option<Uuid>,++ #[schemars(+ description = "For multi-select properties. The option UUIDs from available options."+ )]+ #[serde(default)]+ pub option_ids: Option<Vec<Uuid>>,++ #[schemars(description = "For single entity reference properties.")]+ #[serde(default)]+ pub entity_ref: Option<ToolEntityRef>,++ #[schemars(description = "For multi entity reference properties.")]+ #[serde(default)]+ pub entity_refs: Option<Vec<ToolEntityRef>>,++ #[schemars(description = "For single link properties.")]+ #[serde(default)]+ pub link_url: Option<String>,++ #[schemars(description = "For multi link properties.")]+ #[serde(default)]+ pub link_urls: Option<Vec<String>>,+}++impl SetEntityProperty {+ fn to_set_property_value(&self) -> Option<SetPropertyValue> {+ if let Some(v) = self.boolean_value {+ return Some(SetPropertyValue::Boolean { value: v });+ }+ if let Some(v) = self.date_value {+ return Some(SetPropertyValue::Date { value: v });+ }+ if let Some(v) = self.number_value {+ return Some(SetPropertyValue::Number { value: v });+ }+ if let Some(v) = &self.string_value {+ return Some(SetPropertyValue::String { value: v.clone() });+ }+ if let Some(v) = self.option_id {+ return Some(SetPropertyValue::SelectOption { option_id: v });+ }+ if let Some(v) = &self.option_ids {+ return Some(SetPropertyValue::MultiSelectOption {+ option_ids: v.clone(),+ });+ }+ if let Some(v) = &self.entity_ref {+ return Some(SetPropertyValue::EntityReference {+ reference: EntityReference {+ entity_type: EntityType::from(v.entity_type),+ entity_id: v.entity_id.clone(),+ specific_message_id: None,+ },+ });+ }+ if let Some(v) = &self.entity_refs {+ return Some(SetPropertyValue::MultiEntityReference {+ references: v+ .iter()+ .map(|r| EntityReference {+ entity_type: EntityType::from(r.entity_type),+ entity_id: r.entity_id.clone(),+ specific_message_id: None,+ })+ .collect(),+ });+ }+ if let Some(v) = &self.link_url {+ return Some(SetPropertyValue::Link { url: v.clone() });+ }+ if let Some(v) = &self.link_urls {+ return Some(SetPropertyValue::MultiLink { urls: v.clone() });+ }+ None+ }+}++/// Response from the SetEntityProperty tool.+#[derive(Debug, Serialize, JsonSchema)]+#[serde(rename_all = "camelCase")]+pub struct SetEntityPropertyResponse {+ pub success: bool,+ pub message: String,+}++#[async_trait]+impl<T> AsyncTool<PropertiesToolContext<T>> for SetEntityProperty+where+ T: PropertiesService,+{+ type Output = SetEntityPropertyResponse;++ #[tracing::instrument(+ skip_all,+ fields(+ user_id=?request_context.user_id,+ entity_id=%self.entity_id,+ property_definition_id=%self.property_definition_id+ ),+ err+ )]+ async fn call(+ &self,+ service_context: ServiceContext<PropertiesToolContext<T>>,+ request_context: RequestContext,+ ) -> ToolResult<Self::Output> {+ tracing::info!("Set entity property");++ let entity_type = EntityType::from(self.entity_type);+ let set_value = self.to_set_property_value();+ let user_id: &str = request_context.user_id.0.as_ref();++ service_context+ .service+ .set_entity_property(+ user_id,+ &self.entity_id,+ entity_type,+ self.property_definition_id,+ set_value,+ )+ .await+ .map_err(|e| ToolCallError {+ description: format!("Failed to set property: {e}"),+ internal_error: e.into(),+ })?;++ Ok(SetEntityPropertyResponse {+ success: true,+ message: "Property updated successfully.".to_string(),+ })+ }+}diff --git a/rust/cloud-storage/properties/src/inbound/toolset/test.rs b/rust/cloud-storage/properties/src/inbound/toolset/test.rsnew file mode 100644index 0000000000..ed869fc839--- /dev/null+++ b/rust/cloud-storage/properties/src/inbound/toolset/test.rs@@ -0,0 +1,67 @@+use super::*;+use ai::generate_tool_input_schema;+use ai::tool::types::tool_object::validate_tool_schema;++#[test]+fn test_get_entity_properties_schema_validation() {+ let schema = generate_tool_input_schema!(GetEntityProperties);++ let result = validate_tool_schema(&schema);+ assert!(result.is_ok(), "{:?}", result);++ let (name, description) = result.unwrap();+ assert_eq!(name, "GetEntityProperties");+ assert!(+ description.contains("Get all properties"),+ "Description should contain expected text"+ );+}++#[test]+fn test_set_entity_property_schema_validation() {+ let schema = generate_tool_input_schema!(SetEntityProperty);++ let result = validate_tool_schema(&schema);+ assert!(result.is_ok(), "{:?}", result);++ let (name, description) = result.unwrap();+ assert_eq!(name, "SetEntityProperty");+ assert!(+ description.contains("Set or update a property"),+ "Description should contain expected text"+ );+}++// run `cargo test -p properties inbound::toolset::test::print_get_input_schema -- --nocapture --include-ignored`+#[test]+#[ignore = "prints the input schema"]+fn print_get_input_schema() {+ let schema = generate_tool_input_schema!(GetEntityProperties);+ println!("{}", serde_json::to_string_pretty(&schema).unwrap());+}++// run `cargo test -p properties inbound::toolset::test::print_set_input_schema -- --nocapture --include-ignored`+#[test]+#[ignore = "prints the input schema"]+fn print_set_input_schema() {+ let schema = generate_tool_input_schema!(SetEntityProperty);+ println!("{}", serde_json::to_string_pretty(&schema).unwrap());+}++// run `cargo test -p properties inbound::toolset::test::print_get_output_schema -- --nocapture --include-ignored`+#[test]+#[ignore = "prints the output schema"]+fn print_get_output_schema() {+ let generator = ai::tool::minimized_output_schema_generator();+ let schema = generator.into_root_schema_for::<GetEntityPropertiesResponse>();+ println!("{}", serde_json::to_string_pretty(&schema).unwrap());+}++// run `cargo test -p properties inbound::toolset::test::print_set_output_schema -- --nocapture --include-ignored`+#[test]+#[ignore = "prints the output schema"]+fn print_set_output_schema() {+ let generator = ai::tool::minimized_output_schema_generator();+ let schema = generator.into_root_schema_for::<SetEntityPropertyResponse>();+ println!("{}", serde_json::to_string_pretty(&schema).unwrap());+}diff --git a/rust/cloud-storage/properties/src/lib.rs b/rust/cloud-storage/properties/src/lib.rsindex 96b61e7ddd..899c3246b7 100644--- a/rust/cloud-storage/properties/src/lib.rs+++ b/rust/cloud-storage/properties/src/lib.rs@@ -11,9 +11,11 @@//! - `outbound` - Outbound adapters (e.g., PostgreSQL implementation)pub mod domain;+pub mod inbound;pub mod outbound;pub use domain::error::PropertiesErr;+pub use domain::model::{EntityPropertyInfo, PropertyOptionInfo};pub use domain::ports::{NotificationService, PermissionService, PropertiesRepo};pub use domain::service::PropertiesService;pub use domain::service_impl::PropertiesServiceImpl;diff --git a/rust/cloud-storage/properties/src/outbound.rs b/rust/cloud-storage/properties/src/outbound.rsindex 24006b3c45..ef738b536c 100644--- a/rust/cloud-storage/properties/src/outbound.rs+++ b/rust/cloud-storage/properties/src/outbound.rs@@ -1,3 +1,4 @@+pub mod entity_properties_get_query;pub mod entity_property_queries;pub mod notification_service;pub mod permission_service;diff --git a/rust/cloud-storage/properties/src/outbound/entity_properties_get_query.rs b/rust/cloud-storage/properties/src/outbound/entity_properties_get_query.rsnew file mode 100644index 0000000000..1887fcf936--- /dev/null+++ b/rust/cloud-storage/properties/src/outbound/entity_properties_get_query.rs@@ -0,0 +1,141 @@+//! Query to get all properties attached to an entity.++use models_properties::service::property_option::PropertyOptionValue;+use models_properties::service::property_value::PropertyValue;+use models_properties::{DataType, EntityType};+use sqlx::{Pool, Postgres};+use uuid::Uuid;++use crate::domain::model::{EntityPropertyInfo, PropertyOptionInfo};++/// Database row from the joined query.+struct PropertyRow {+ property_definition_id: Uuid,+ display_name: String,+ data_type: DataType,+ is_multi_select: bool,+ is_system: bool,+ values: Option<serde_json::Value>,+}++/// Database row for property options.+struct OptionRow {+ id: Uuid,+ property_definition_id: Uuid,+ display_order: i32,+ string_value: Option<String>,+ number_value: Option<f64>,+}++/// Get all properties attached to an entity, with their definitions, values, and options.+/// Results are sorted by display_name (case-insensitive).+#[tracing::instrument(skip(pool))]+pub async fn get_entity_properties(+ pool: &Pool<Postgres>,+ entity_id: &str,+ entity_type: EntityType,+) -> anyhow::Result<Vec<EntityPropertyInfo>> {+ // Fetch all entity properties with their definitions+ let rows = sqlx::query_as!(+ PropertyRow,+ r#"+ SELECT+ ep.property_definition_id,+ pd.display_name,+ pd.data_type as "data_type: DataType",+ pd.is_multi_select,+ pd.is_system,+ ep.values as "values: serde_json::Value"+ FROM entity_properties ep+ INNER JOIN property_definitions pd ON pd.id = ep.property_definition_id+ WHERE ep.entity_id = $1+ AND ep.entity_type = $2+ ORDER BY LOWER(pd.display_name)+ "#,+ entity_id,+ entity_type as EntityType,+ )+ .fetch_all(pool)+ .await?;++ if rows.is_empty() {+ return Ok(Vec::new());+ }++ // Collect all property definition IDs that are select types to fetch options+ let select_prop_ids: Vec<Uuid> = rows+ .iter()+ .filter(|r| matches!(r.data_type, DataType::SelectString | DataType::SelectNumber))+ .map(|r| r.property_definition_id)+ .collect();++ // Fetch options for all select-type properties in one query+ let option_rows = if select_prop_ids.is_empty() {+ Vec::new()+ } else {+ sqlx::query_as!(+ OptionRow,+ r#"+ SELECT+ id,+ property_definition_id,+ display_order,+ string_value,+ number_value+ FROM property_options+ WHERE property_definition_id = ANY($1)+ ORDER BY display_order+ "#,+ &select_prop_ids,+ )+ .fetch_all(pool)+ .await?+ };++ // Group options by property_definition_id+ let mut options_map: std::collections::HashMap<Uuid, Vec<PropertyOptionInfo>> =+ std::collections::HashMap::new();+ for opt in option_rows {+ let value = if let Some(s) = opt.string_value {+ PropertyOptionValue::String(s)+ } else if let Some(n) = opt.number_value {+ PropertyOptionValue::Number(n)+ } else {+ continue;+ };+ options_map+ .entry(opt.property_definition_id)+ .or_default()+ .push(PropertyOptionInfo {+ id: opt.id,+ display_order: opt.display_order,+ value,+ });+ }++ // Build result+ let mut result = Vec::with_capacity(rows.len());+ for row in rows {+ let value = match row.values {+ None => None,+ Some(v) if v.is_null() => None,+ Some(v) => Some(serde_json::from_value::<PropertyValue>(v)?),+ };++ let options = options_map+ .remove(&row.property_definition_id)+ .unwrap_or_default();++ result.push(EntityPropertyInfo {+ property_definition_id: row.property_definition_id,+ display_name: row.display_name,+ data_type: row.data_type,+ is_multi_select: row.is_multi_select,+ is_system: row.is_system,+ value,+ options,+ });+ }++ Ok(result)+}diff --git a/rust/cloud-storage/properties/src/outbound/properties_pg_repo.rs b/rust/cloud-storage/properties/src/outbound/properties_pg_repo.rsindex 2626bd11ac..57f36d4c8d 100644--- a/rust/cloud-storage/properties/src/outbound/properties_pg_repo.rs+++ b/rust/cloud-storage/properties/src/outbound/properties_pg_repo.rs@@ -5,7 +5,11 @@ use models_properties::service::property_value::PropertyValue;use sqlx::{Pool, Postgres};use uuid::Uuid;-use super::{entity_property_queries, property_definition_queries, task_property_queries};+use super::{+ entity_properties_get_query, entity_property_queries, property_definition_queries,+ task_property_queries,+};+use crate::domain::model::EntityPropertyInfo;use crate::domain::ports::PropertiesRepo;use models_properties::service::property_definition::PropertyDefinition;@@ -98,6 +102,15 @@ impl PropertiesRepo for PropertiesPgRepo {task_property_queries::link_subtasks(&self.pool, task_id, subtask_ids).await}+ #[tracing::instrument(skip(self), err)]+ async fn get_entity_properties(+ &self,+ entity_id: &str,+ entity_type: EntityType,+ ) -> Result<Vec<EntityPropertyInfo>, Self::Err> {+ entity_properties_get_query::get_entity_properties(&self.pool, entity_id, entity_type).await+ }+#[tracing::instrument(skip(self))]async fn get_entity_property_value(&self,