mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-07-11 18:29:20 +00:00
* feat(protocol): extract shared protocol package from agent-core - add `@moonshot-ai/protocol` package with REST/WS schemas, envelopes, error codes, event types, and display schemas\n- migrate agent-core `events.ts` and `display/schemas.ts` to re-export from protocol - add centralized `onUnexpectedError` handler for safe emitter listener callbacks - reject forkSession when source session has an active running turn - add protocol schema tests and unexpectedError handler tests
34 lines
1 KiB
TypeScript
34 lines
1 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
export const toolSourceSchema = z.enum(['builtin', 'skill', 'mcp']);
|
|
export type ToolSource = z.infer<typeof toolSourceSchema>;
|
|
|
|
export const toolDescriptorSchema = z.object({
|
|
name: z.string().min(1),
|
|
description: z.string(),
|
|
input_schema: z.unknown(),
|
|
source: toolSourceSchema,
|
|
mcp_server_id: z.string().min(1).optional(),
|
|
});
|
|
export type ToolDescriptor = z.infer<typeof toolDescriptorSchema>;
|
|
|
|
export const mcpServerStatusSchema = z.enum([
|
|
'connected',
|
|
'connecting',
|
|
'disconnected',
|
|
'error',
|
|
]);
|
|
export type McpServerStatus = z.infer<typeof mcpServerStatusSchema>;
|
|
|
|
export const mcpServerTransportSchema = z.enum(['stdio', 'http', 'sse']);
|
|
export type McpServerTransport = z.infer<typeof mcpServerTransportSchema>;
|
|
|
|
export const mcpServerSchema = z.object({
|
|
id: z.string().min(1),
|
|
name: z.string().min(1),
|
|
transport: mcpServerTransportSchema,
|
|
status: mcpServerStatusSchema,
|
|
last_error: z.string().optional(),
|
|
tool_count: z.number().int().nonnegative(),
|
|
});
|
|
export type McpServer = z.infer<typeof mcpServerSchema>;
|