import { z } from 'zod';
import type { RegistryApiClient } from '../client/api.js';
export const replyInputSchema = z.object({
threadId: z.string().uuid().describe('Thread ID to reply to'),
body: z.string().describe('Reply message body'),
metadata: z.record(z.unknown()).optional().describe('Additional metadata'),
});
export type ReplyInput = z.infer<typeof replyInputSchema>;
export interface ReplyResult {
success: boolean;
messageId?: string;
threadId?: string;
error?: string;
}
/**
* Reply to an existing message thread.
*
* This is a convenience method for continuing a conversation.
* The reply will be sent to the original sender.
*/
export async function reply(
input: ReplyInput,
client: RegistryApiClient
): Promise<ReplyResult> {
try {
const response = await client.replyToThread(input.threadId, input.body, input.metadata);
return {
success: true,
messageId: response.message_id,
threadId: response.thread_id,
};
} catch (error) {
return {
success: false,
error: error instanceof Error ? error.message : 'Failed to send reply',
};
}
}
export const replyTool = {
name: 'agents_registry_reply',
description: 'Reply to an existing message thread. The reply will be sent to the original sender.',
inputSchema: {
type: 'object' as const,
properties: {
threadId: {
type: 'string',
description: 'The thread ID to reply to (from a received message)',
},
body: {
type: 'string',
description: 'Reply message body',
},
metadata: {
type: 'object',
description: 'Additional metadata to attach to the reply (optional)',
},
},
required: ['threadId', 'body'],
},
};