string('type')->description('主数据类型:bom | process | tooling,默认 bom。'); } public function handle(array $arguments): ToolResult { $type = (string) ($arguments['type'] ?? 'bom'); if (! in_array($type, ['bom', 'process', 'tooling'], true)) { $type = 'bom'; } $masters = $this->bomService->getMasters($type, 0); if (empty($masters)) { return ToolResult::text("无 {$type} 主数据。"); } $rows = []; foreach ($masters as $m) { $rows[] = [ 'id' => (int) $m['id'], 'type' => (string) ($m['type'] ?? 'bom'), 'bomNo' => (string) ($m['bomNo'] ?? ''), 'productName' => Str::sanitizeForLLM((string) ($m['productName'] ?? '')), 'version' => (string) ($m['version'] ?? ''), 'specification' => Str::sanitizeForLLM((string) ($m['specification'] ?? '')), ]; } return ToolResult::json(['type' => $type, 'count' => count($rows), 'items' => $rows]); } }