MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / parseAgentId

Function parseAgentId

common/src/util/agent-id-parsing.ts:7–80  ·  view source on GitHub ↗
(fullAgentId: string)

Source from the content-addressed store, hash-verified

5 * - agentId[@version] (no publisher)
6 */
7export function parseAgentId(fullAgentId: string): {
8 publisherId?: string
9 agentId?: string
10 version?: string
11 givenAgentId: string
12} {
13 // Check if it's in the publisher/agent-id[@version] format
14 const parts = fullAgentId.split('/')
15
16 if (parts.length === 2) {
17 // Full format: publisher/agentId[@version]
18 const [publisherId, agentNameWithVersion] = parts
19
20 if (!publisherId || !agentNameWithVersion) {
21 return {
22 publisherId: undefined,
23 agentId: undefined,
24 version: undefined,
25 givenAgentId: fullAgentId,
26 }
27 }
28
29 // Check for version suffix
30 const versionMatch = agentNameWithVersion.match(/^(.+)@(.+)$/)
31 if (versionMatch) {
32 const [, agentId, version] = versionMatch
33 return { publisherId, agentId, version, givenAgentId: fullAgentId }
34 }
35
36 return {
37 publisherId,
38 agentId: agentNameWithVersion,
39 givenAgentId: fullAgentId,
40 }
41 } else if (parts.length === 1) {
42 // Just agent name (for backward compatibility)
43 const agentNameWithVersion = parts[0]
44
45 if (!agentNameWithVersion) {
46 return {
47 publisherId: undefined,
48 agentId: undefined,
49 version: undefined,
50 givenAgentId: fullAgentId,
51 }
52 }
53
54 // Check for version suffix
55 const versionMatch = agentNameWithVersion.match(/^(.+)@(.+)$/)
56 if (versionMatch) {
57 const [, agentId, version] = versionMatch
58 return {
59 publisherId: undefined,
60 agentId,
61 version,
62 givenAgentId: fullAgentId,
63 }
64 }

Callers 8

getMatchingSpawnFunction · 0.90
validateSpawnableAgentsFunction · 0.90
isFreebuffRootAgentFunction · 0.90
isFreeAgentFunction · 0.90
parsePublishedAgentIdFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected