(agentId: string)
| 193 | |
| 194 | // Get a single agent by ID |
| 195 | export async function getAgent(agentId: string): Promise<CompleteAgent | null> { |
| 196 | const db = await openDB(); |
| 197 | |
| 198 | // Get the agent metadata |
| 199 | const agentMetadata = await new Promise<any>((resolve, reject) => { |
| 200 | const tx = db.transaction(AGENT_STORE, 'readonly'); |
| 201 | const store = tx.objectStore(AGENT_STORE); |
| 202 | const request = store.get(agentId); |
| 203 | |
| 204 | request.onsuccess = () => resolve(request.result || null); |
| 205 | request.onerror = () => reject(request.error); |
| 206 | }); |
| 207 | |
| 208 | if (!agentMetadata) { |
| 209 | return null; |
| 210 | } |
| 211 | |
| 212 | // Get the agent config |
| 213 | const config = await getAgentConfig(agentId); |
| 214 | |
| 215 | // Combine into a CompleteAgent |
| 216 | return { |
| 217 | ...agentMetadata, |
| 218 | ...(config || { |
| 219 | model_name: '', |
| 220 | system_prompt: '', |
| 221 | loop_interval_seconds: 1.0 |
| 222 | }) |
| 223 | }; |
| 224 | } |
| 225 | |
| 226 | // Get agent configuration (for internal use) |
| 227 | async function getAgentConfig(agentId: string): Promise<{ |
no test coverage detected