withJson(CloudHostInventoryDiagnostics::page( $request->getAttribute('cloud_actor') ?? CloudAccess::actor(false), $request->getQueryParams() ))->withHeader('Cache-Control', 'private, no-store'); } public function detail($request, $response, $args) { return $response->withJson(CloudHostInventoryDiagnostics::detail( $request->getAttribute('cloud_actor') ?? CloudAccess::actor(false), (string) ($args['id'] ?? '') ))->withHeader('Cache-Control', 'private, no-store'); } public function engine($request, $response, $args) { $actor = $request->getAttribute('cloud_actor') ?? CloudAccess::actor(false); $attemptId = (string) ($args['id'] ?? ''); // This authorizes the read and binds its host to a persisted attempt. // Never accept an arbitrary host or call the capacity/network endpoints. $detail = CloudHostInventoryDiagnostics::detail($actor, $attemptId); try { $result = (new CloudEngineClient(null, 1.0))->inventoryDiagnostics( (int) $detail['attempt']['host_id'], $actor, $attemptId ); $available = ($result['diagnostics_available'] ?? true) === true; $result = ['available' => $available, 'attempt_id' => $attemptId, 'traces' => $result['traces'], 'message' => $available ? '仅查询引擎已记录的线索;不会发起盘点,也不会改变面板同步结果。' : '引擎诊断存储暂不可用;无法取得内部阶段线索,不代表宿主机离线。']; } catch (CloudInventoryRequestError $exception) { $result = ['available' => false, 'attempt_id' => $attemptId, 'traces' => [], 'error_code' => $exception->diagnosticCode, 'message' => '引擎线索暂不可读取或尚未记录;无法据此判断宿主机是否正常。']; } catch (CloudError $exception) { $result = ['available' => false, 'attempt_id' => $attemptId, 'traces' => [], 'error_code' => 'diagnostics_unavailable', 'message' => '引擎线索暂不可读取;请检查引擎版本、认证及连接配置。']; } return $response->withJson($result)->withHeader('Cache-Control', 'private, no-store'); } }