fix: resolve architecture disconnects and codebase weaknesses
- Standardize MessageRecord types — single source of truth from @bete/shared - Clean up config: remove unused GUILD_ID/TEXT_GUILD_ID/TEXT_CHANNEL_ID, fix WEBSERVER_PORT default (3001), remove default admin password - Move mascot_chat_messages table to Drizzle schema with proper migration - Remove runtime DDL (CREATE TABLE IF NOT EXISTS) from mascot-chat repository - Remove phantom analytics/ module from documentation - Add better-sqlite3 dependency to root devDependencies - Replace 'as any' casts with proper type assertions across AI moderation - Add error logging to silent catch blocks in LLM client - Apply Biome formatting and import organization Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
67d66bb5dd
commit
3614d32701
@@ -179,7 +179,12 @@ export function extractJson(content: string): unknown {
|
||||
if (parsed && typeof parsed === "object") {
|
||||
return parsed;
|
||||
}
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
log.debug(
|
||||
{ err: err instanceof Error ? err.message : String(err) },
|
||||
"Failed to parse JSON from code block — trying next block",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (let start = 0; start < content.length; start++) {
|
||||
@@ -224,7 +229,12 @@ export function extractJson(content: string): unknown {
|
||||
if (parsed && typeof parsed === "object") {
|
||||
return parsed;
|
||||
}
|
||||
} catch (_) {}
|
||||
} catch (err) {
|
||||
log.debug(
|
||||
{ err: err instanceof Error ? err.message : String(err) },
|
||||
"Failed to parse JSON candidate — trying next position",
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -266,7 +276,7 @@ export function parseModerationResponse(
|
||||
parsed = { results: [parsed] };
|
||||
} else {
|
||||
const arrayKey = Object.keys(parsed).find((key) => {
|
||||
const val = (parsed as any)[key];
|
||||
const val = parsed[key];
|
||||
return (
|
||||
Array.isArray(val) &&
|
||||
val.length > 0 &&
|
||||
@@ -274,12 +284,12 @@ export function parseModerationResponse(
|
||||
(item: unknown) =>
|
||||
typeof item === "object" &&
|
||||
item !== null &&
|
||||
"message_id" in (item as any),
|
||||
"message_id" in (item as Record<string, unknown>),
|
||||
)
|
||||
);
|
||||
});
|
||||
if (arrayKey) {
|
||||
parsed.results = (parsed as any)[arrayKey];
|
||||
parsed.results = parsed[arrayKey];
|
||||
} else {
|
||||
parsed = { results: [parsed] };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user