Fix: Use Zod schemas for messaging tools
- Replace plain object inputSchema with Zod schemas - Fixes TypeScript compilation error - Use z.enum() for role validation - Use z.record(z.any()) for optional data object 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { ToolHandler } from '../base/ToolHandler';
|
import { ToolHandler } from '../base/ToolHandler';
|
||||||
import { NatsClient } from '../../nats/NatsClient';
|
import { NatsClient } from '../../nats/NatsClient';
|
||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
// Detect current developer role from workspace
|
// Detect current developer role from workspace
|
||||||
function detectRole(): string {
|
function detectRole(): string {
|
||||||
@@ -14,29 +15,12 @@ export class SendMessageTool extends ToolHandler {
|
|||||||
name = 'send_message';
|
name = 'send_message';
|
||||||
description = 'Send real-time message to another developer via NATS';
|
description = 'Send real-time message to another developer via NATS';
|
||||||
|
|
||||||
inputSchema = {
|
schema = z.object({
|
||||||
type: 'object' as const,
|
to: z.enum(['admin-dev', 'api-dev', 'web-dev']).describe('Recipient role'),
|
||||||
properties: {
|
subject: z.string().describe('Message subject/title'),
|
||||||
to: {
|
message: z.string().describe('Message content'),
|
||||||
type: 'string',
|
data: z.record(z.any()).optional().describe('Optional structured data'),
|
||||||
description: 'Recipient role: admin-dev, api-dev, or web-dev',
|
});
|
||||||
enum: ['admin-dev', 'api-dev', 'web-dev'],
|
|
||||||
},
|
|
||||||
subject: {
|
|
||||||
type: 'string',
|
|
||||||
description: 'Message subject/title',
|
|
||||||
},
|
|
||||||
message: {
|
|
||||||
type: 'string',
|
|
||||||
description: 'Message content',
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
type: 'object',
|
|
||||||
description: 'Optional structured data',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: ['to', 'subject', 'message'],
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor(private natsClient: NatsClient) {
|
constructor(private natsClient: NatsClient) {
|
||||||
super();
|
super();
|
||||||
@@ -72,17 +56,9 @@ export class ReceiveMessagesTool extends ToolHandler {
|
|||||||
name = 'receive_messages';
|
name = 'receive_messages';
|
||||||
description = 'Receive real-time messages from other developers via NATS';
|
description = 'Receive real-time messages from other developers via NATS';
|
||||||
|
|
||||||
inputSchema = {
|
schema = z.object({
|
||||||
type: 'object' as const,
|
limit: z.number().default(10).describe('Maximum number of messages to return'),
|
||||||
properties: {
|
});
|
||||||
limit: {
|
|
||||||
type: 'number',
|
|
||||||
description: 'Maximum number of messages to return (default: 10)',
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
required: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
private messages: any[] = [];
|
private messages: any[] = [];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user