fix: address Hermes adapter review feedback

This commit is contained in:
HenkDz 2026-03-28 11:35:58 +01:00
parent 1583a2d65a
commit 582f4ceaf4
5 changed files with 12 additions and 8 deletions

View file

@ -227,7 +227,7 @@ export function listServerAdapters(): ServerAdapterModule[] {
export async function detectAdapterModel( export async function detectAdapterModel(
type: string, type: string,
): Promise<{ model: string | null; provider: string | null; source: string | null } | null> { ): Promise<{ model: string; provider: string; source: string } | null> {
const adapter = adaptersByType.get(type); const adapter = adaptersByType.get(type);
if (!adapter?.detectModel) return null; if (!adapter?.detectModel) return null;
const detected = await adapter.detectModel(); const detected = await adapter.detectModel();

View file

@ -677,7 +677,7 @@ export function agentRoutes(db: Db) {
const type = req.params.type as string; const type = req.params.type as string;
const detected = await detectAdapterModel(type); const detected = await detectAdapterModel(type);
res.json(detected ?? { model: null, provider: null, source: null }); res.json(detected);
}); });
router.post( router.post(

View file

@ -28,9 +28,9 @@ export interface AdapterModel {
} }
export interface DetectedAdapterModel { export interface DetectedAdapterModel {
model: string | null; model: string;
provider: string | null; provider: string;
source: string | null; source: string;
} }
export interface ClaudeLoginResult { export interface ClaudeLoginResult {
@ -166,7 +166,7 @@ export const agentsApi = {
`/companies/${encodeURIComponent(companyId)}/adapters/${encodeURIComponent(type)}/models`, `/companies/${encodeURIComponent(companyId)}/adapters/${encodeURIComponent(type)}/models`,
), ),
detectModel: (companyId: string, type: string) => detectModel: (companyId: string, type: string) =>
api.get<DetectedAdapterModel>( api.get<DetectedAdapterModel | null>(
`/companies/${encodeURIComponent(companyId)}/adapters/${encodeURIComponent(type)}/detect-model`, `/companies/${encodeURIComponent(companyId)}/adapters/${encodeURIComponent(type)}/detect-model`,
), ),
testEnvironment: ( testEnvironment: (

View file

@ -757,6 +757,7 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
return result.data?.model ?? null; return result.data?.model ?? null;
} }
: undefined} : undefined}
detectModelLabel={adapterType === "hermes_local" ? "Detect from Hermes config" : undefined}
/> />
{fetchedModelsError && ( {fetchedModelsError && (
<p className="text-xs text-destructive"> <p className="text-xs text-destructive">
@ -1341,6 +1342,7 @@ function ModelDropdown({
creatable, creatable,
detectedModel, detectedModel,
onDetectModel, onDetectModel,
detectModelLabel,
}: { }: {
models: AdapterModel[]; models: AdapterModel[];
value: string; value: string;
@ -1353,6 +1355,7 @@ function ModelDropdown({
creatable?: boolean; creatable?: boolean;
detectedModel?: string | null; detectedModel?: string | null;
onDetectModel?: () => Promise<string | null>; onDetectModel?: () => Promise<string | null>;
detectModelLabel?: string;
}) { }) {
const [modelSearch, setModelSearch] = useState(""); const [modelSearch, setModelSearch] = useState("");
const [detectingModel, setDetectingModel] = useState(false); const [detectingModel, setDetectingModel] = useState(false);
@ -1440,6 +1443,7 @@ function ModelDropdown({
placeholder={creatable ? "Search models... (type to create)" : "Search models..."} placeholder={creatable ? "Search models... (type to create)" : "Search models..."}
value={modelSearch} value={modelSearch}
onChange={(e) => setModelSearch(e.target.value)} onChange={(e) => setModelSearch(e.target.value)}
autoFocus
/> />
{modelSearch && ( {modelSearch && (
<button <button
@ -1467,7 +1471,7 @@ function ModelDropdown({
<path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /> <path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
<path d="M3 3v5h5" /> <path d="M3 3v5h5" />
</svg> </svg>
{detectingModel ? "Detecting..." : "Detect from Hermes config"} {detectingModel ? "Detecting..." : (detectModelLabel ?? "Detect from config")}
</button> </button>
)} )}
{value && !models.some((m) => m.id === value) && ( {value && !models.some((m) => m.id === value) && (

View file

@ -1086,7 +1086,7 @@ function LatestRunCard({ runs, agentId }: { runs: HeartbeatRun[]; agentId: strin
.replace(/^#{1,6}\s+/gm, "") .replace(/^#{1,6}\s+/gm, "")
.split("\n") .split("\n")
.map((l) => l.trim()) .map((l) => l.trim())
.filter((l) => l.length > 0 && !l.startsWith("---") && !l.startsWith("|") && !l.startsWith("```")); .filter((l) => l.length > 0 && !l.startsWith("---") && !l.startsWith("|") && !l.startsWith("```") && !/^[-*>]/.test(l) && !/^\d+\./.test(l));
const excerpt: string[] = []; const excerpt: string[] = [];
let chars = 0; let chars = 0;
for (const line of lines) { for (const line of lines) {