MCPcopy Create free account
hub / github.com/Qinbf/groundmap / recordSource

Function recordSource

tools/debug-console/lib/agent-loop.ts:88–114  ·  view source on GitHub ↗

从 tool result 提取路径加入注册表

(toolName: string, args: Record<string, unknown>, data?: unknown)

Source from the content-addressed store, hash-verified

86
87 /** 从 tool result 提取路径加入注册表 */
88 function recordSource(toolName: string, args: Record<string, unknown>, data?: unknown) {
89 const p =
90 typeof args.path === "string"
91 ? args.path
92 : typeof args.file_path === "string"
93 ? args.file_path
94 : null;
95 if (p) availableSources.add(p);
96 // backlinks / outlinks 的结果里也包含有效路径
97 if ((toolName === "backlinks" || toolName === "outlinks") && data) {
98 const field = toolName === "backlinks" ? "from_path" : "target";
99 let arr: unknown = data;
100 if (!Array.isArray(arr) && typeof arr === "object") {
101 const obj = arr as Record<string, unknown>;
102 if (Array.isArray(obj.hits)) arr = obj.hits;
103 else if (Array.isArray(obj.results)) arr = obj.results;
104 }
105 if (Array.isArray(arr)) {
106 for (const item of arr) {
107 if (item && typeof item === "object") {
108 const path = (item as Record<string, unknown>)[field];
109 if (typeof path === "string") availableSources.add(path);
110 }
111 }
112 }
113 }
114 }
115
116 /** ANSWER 后验:扫描所有引用,验证是否有效 */
117 async function* validateAnswerRefs(text: string): AsyncGenerator<AgentEvent> {

Callers 1

runAgentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected