- Added optional parameters 'conversationId' and 'replyToConversationId' to the cross-team messaging tool for improved threading. - Updated the TeamMemberResolver to ignore tool-like cross-team inbox names, ensuring cleaner member resolution. - Enhanced TeamProvisioningService to handle explicit cross-team reply instructions and prevent relaying tool-like names. - Improved tests to validate new cross-team messaging features and recipient handling, ensuring robust functionality across services.
81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
import type { FastMCP } from 'fastmcp';
|
|
import { z } from 'zod';
|
|
|
|
import { getController } from '../controller';
|
|
import { jsonTextContent } from '../utils/format';
|
|
|
|
const toolContextSchema = {
|
|
teamName: z.string().min(1),
|
|
claudeDir: z.string().min(1).optional(),
|
|
};
|
|
|
|
export function registerCrossTeamTools(server: Pick<FastMCP, 'addTool'>) {
|
|
server.addTool({
|
|
name: 'cross_team_send',
|
|
description:
|
|
'Send a message to another team. The message is delivered to the target team lead inbox.',
|
|
parameters: z.object({
|
|
...toolContextSchema,
|
|
toTeam: z.string().min(1),
|
|
text: z.string().min(1),
|
|
fromMember: z.string().optional(),
|
|
summary: z.string().optional(),
|
|
conversationId: z.string().optional(),
|
|
replyToConversationId: z.string().optional(),
|
|
chainDepth: z.number().int().nonnegative().optional(),
|
|
}),
|
|
execute: async ({
|
|
teamName,
|
|
claudeDir,
|
|
toTeam,
|
|
text,
|
|
fromMember,
|
|
summary,
|
|
conversationId,
|
|
replyToConversationId,
|
|
chainDepth,
|
|
}) =>
|
|
await Promise.resolve(
|
|
jsonTextContent(
|
|
getController(teamName, claudeDir).crossTeam.sendCrossTeamMessage({
|
|
toTeam,
|
|
text,
|
|
...(fromMember ? { fromMember } : {}),
|
|
...(summary ? { summary } : {}),
|
|
...(conversationId ? { conversationId } : {}),
|
|
...(replyToConversationId ? { replyToConversationId } : {}),
|
|
...(chainDepth !== undefined ? { chainDepth } : {}),
|
|
})
|
|
)
|
|
),
|
|
});
|
|
|
|
server.addTool({
|
|
name: 'cross_team_list_targets',
|
|
description: 'List available teams that can receive cross-team messages.',
|
|
parameters: z.object({
|
|
...toolContextSchema,
|
|
excludeTeam: z.string().optional(),
|
|
}),
|
|
execute: async ({ teamName, claudeDir, excludeTeam }) =>
|
|
await Promise.resolve(
|
|
jsonTextContent(
|
|
getController(teamName, claudeDir).crossTeam.listCrossTeamTargets({
|
|
...(excludeTeam ? { excludeTeam } : {}),
|
|
})
|
|
)
|
|
),
|
|
});
|
|
|
|
server.addTool({
|
|
name: 'cross_team_get_outbox',
|
|
description: 'Get sent cross-team messages for the current team.',
|
|
parameters: z.object({
|
|
...toolContextSchema,
|
|
}),
|
|
execute: async ({ teamName, claudeDir }) =>
|
|
await Promise.resolve(
|
|
jsonTextContent(getController(teamName, claudeDir).crossTeam.getCrossTeamOutbox())
|
|
),
|
|
});
|
|
}
|