* Get agent by identifier (URL or legacy slug format like "type/name") * Provides backward compatibility with old registry-based lookups
(identifier: string)
| 122 | * Provides backward compatibility with old registry-based lookups |
| 123 | */ |
| 124 | async getAgent(identifier: string): Promise<Agent | undefined> { |
| 125 | // If it looks like a URL, search by URL |
| 126 | if (identifier.startsWith("http://") || identifier.startsWith("https://")) { |
| 127 | return this.getAgentByUrl(identifier); |
| 128 | } |
| 129 | |
| 130 | // Otherwise treat as legacy slug format "type/name" or just name |
| 131 | // Search all agents and match by slug-like identifier |
| 132 | const agents = await this.listAgents(); |
| 133 | |
| 134 | for (const agent of agents) { |
| 135 | // Match by type/slugified-name pattern |
| 136 | const slugName = agent.name.toLowerCase().replace(/\s+/g, "-"); |
| 137 | const agentSlug = `${agent.type}/${slugName}`; |
| 138 | |
| 139 | if (agentSlug === identifier || slugName === identifier) { |
| 140 | return agent; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | return undefined; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Get all agents as a map keyed by URL |
no test coverage detected