MCPcopy Create free account
hub / github.com/Roy3838/Observer / extractAgentReferencesWithPositions

Function extractAgentReferencesWithPositions

app/src/utils/agentParser.ts:191–219  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

189 * @returns Array of references with position info
190 */
191export function extractAgentReferencesWithPositions(text: string): Array<{
192 reference: AgentReference;
193 start: number;
194 end: number;
195 fullMatch: string;
196}> {
197 const regex = /@(\w+)(?:#(\d+))?/g;
198 const references: Array<{
199 reference: AgentReference;
200 start: number;
201 end: number;
202 fullMatch: string;
203 }> = [];
204 let match;
205
206 while ((match = regex.exec(text)) !== null) {
207 references.push({
208 reference: {
209 agentId: match[1],
210 runCount: match[2] ? parseInt(match[2]) : 3
211 },
212 start: match.index,
213 end: match.index + match[0].length,
214 fullMatch: match[0]
215 });
216 }
217
218 return references;
219}
220
221/**
222 * Removes @references from text, leaving clean user message

Callers 2

MessageContentFunction · 0.90

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected