MCPcopy Create free account
hub / github.com/FIND-Lab/AgentWard / extractJsonObject

Function extractJsonObject

layers/foundation-scan.ts:328–346  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

326}
327
328function extractJsonObject(text: string): Record<string, unknown> | null {
329 const trimmed = text.trim();
330 try {
331 return JSON.parse(trimmed) as Record<string, unknown>;
332 } catch {
333 // ignore
334 }
335
336 const first = trimmed.indexOf("{");
337 const last = trimmed.lastIndexOf("}");
338 if (first >= 0 && last > first) {
339 try {
340 return JSON.parse(trimmed.slice(first, last + 1)) as Record<string, unknown>;
341 } catch {
342 return null;
343 }
344 }
345 return null;
346}
347
348async function detectSkillMetadataRisk(
349 skill: Skill,

Callers 1

callSemanticDetectionApiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected