Files
ChatLab/electron/main/ai/tools/utils/schemas.ts
digua f7c427df50 refactor(tools): modularize tool system with AgentTool + TypeBox + i18n
- Delete monolithic registry.ts (−1185 lines)
- Add tools/definitions/ with 12 individual tool files + index.ts,
  each using AgentTool interface and TypeBox schemas
- Add tools/utils/ with shared helpers (format.ts, schemas.ts, time-params.ts)
- Rewrite tools/index.ts to provide getAllTools() factory
- Clean up tools/types.ts, keep only ToolContext and OwnerInfo
- Use i18n keys for tool descriptions, preserve Chinese as comments
2026-02-26 21:05:39 +08:00

24 lines
1.2 KiB
TypeScript

/**
* 共享 TypeBox Schema 片段
* 多个工具复用的时间参数 schema
*/
import { Type } from '@mariozechner/pi-ai'
export const timeParamProperties = {
year: Type.Optional(Type.Number({ description: 'ai.tools._shared.params.year' })),
month: Type.Optional(Type.Number({ description: 'ai.tools._shared.params.month' })),
day: Type.Optional(Type.Number({ description: 'ai.tools._shared.params.day' })),
hour: Type.Optional(Type.Number({ description: 'ai.tools._shared.params.hour' })),
start_time: Type.Optional(Type.String({ description: 'ai.tools._shared.params.start_time' })),
end_time: Type.Optional(Type.String({ description: 'ai.tools._shared.params.end_time' })),
}
export const timeParamPropertiesNoHour = {
year: Type.Optional(Type.Number({ description: 'ai.tools._shared.params.year' })),
month: Type.Optional(Type.Number({ description: 'ai.tools._shared.params.month' })),
day: Type.Optional(Type.Number({ description: 'ai.tools._shared.params.day' })),
start_time: Type.Optional(Type.String({ description: 'ai.tools._shared.params.start_time' })),
end_time: Type.Optional(Type.String({ description: 'ai.tools._shared.params.end_time' })),
}