390
throw new Error(`Unknown agent: ${JSON.stringify(id)}`);
391
}
393
>
if (entry.impl) {
394
throw new Error(`Agent already has implementation: ${JSON.stringify(id)}`);
395
}
397
>
if (entry.data.isDefault) {
398
this._hasDefaultAgent.set(true);
399
}
401
>
entry.impl = agentImpl;
402
>
this._onDidChangeAgents.fire(new MergedChatAgent(entry.data, agentImpl));
403
>
404
>
return toDisposable(() => {
405
>
entry.impl = undefined;
406
>
this._onDidChangeAgents.fire(undefined);
407
>
408
>
if (entry.data.isDefault) {
409
this._hasDefaultAgent.set(Iterable.some(this._agents.values(), agent => agent.data.isDefault && !!agent.impl));
410
}
412
}
413