chatAgents.ts ×12

Frontier kind: Code frontier

unlabeled · c_95150ac548d8

73 tests · 31380 LOC · 153 files · introduces 0 tests · 47 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges47 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3037 ranges31380 lines · 153 files · Browse complete extent
All tests (intent)
73 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 47 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/chat/common/participants/chatAgents.ts 47 introduced LOC · 12 ranges

Open complete file

320
321 registerAgent(id: string, data: IChatAgentData): IDisposable {
322 > const existingAgent = this.getAgent(id); chatAgents.ts
323 > if (existingAgent) {
324 throw new Error(`Agent already registered: ${JSON.stringify(id)}`);
325 }
327 > const that = this;
328 > const commands = data.slashCommands;
329 > data = {
330 > ...data,
331 > get slashCommands() {
332 return commands.filter(c => !c.when || that.contextKeyService.contextMatchesRules(ContextKeyExpr.deserialize(c.when)));
333 }
334 > }; chatAgents.ts
335 > const entry = { data };
336 > this._agents.set(id, entry);
337 > this._updateAgentsContextKeys();
338 > this._updateContextKeys();
339 > this._onDidChangeAgents.fire(undefined);
340 >
341 > return toDisposable(() => {
342 > this._agents.delete(id);
343 > this._updateAgentsContextKeys();
344 > this._updateContextKeys();
345 > this._onDidChangeAgents.fire(undefined);
346 > });
347 > }
348
349 private _updateAgentsContextKeys(): void {
350 > // Update the set of context keys used by all agents chatAgents.ts
351 > this._agentsContextKeys.clear();
352 > for (const agent of this._agents.values()) {
353 > if (agent.data.when) {
354 const expr = ContextKeyExpr.deserialize(agent.data.when);
355 for (const key of expr?.keys() || []) {
357 }
358 }
359 > } chatAgents.ts
360 > }
361
362 private _updateContextKeys(): void {
363 > let extensionAgentRegistered = false; chatAgents.ts
364 > let defaultAgentRegistered = false;
365 > let toolsAgentRegistered = false;
366 > for (const agent of this.getAgents()) {
367 if (agent.isDefault) {
368 if (!agent.isCore) {
377 }
378 }
379 > this._defaultAgentRegistered.set(defaultAgentRegistered); chatAgents.ts
380 > this._extensionAgentRegistered.set(extensionAgentRegistered);
381 > if (toolsAgentRegistered !== this._hasToolsAgent) {
382 this._hasToolsAgent = toolsAgentRegistered;
383 this._onDidChangeAgents.fire(this.getDefaultAgent(ChatAgentLocation.Chat, ChatModeKind.Agent));
384 }
385 > } chatAgents.ts
386
387 registerAgentImplementation(id: string, agentImpl: IChatAgentImplementation): IDisposable {
474
475 getAgent(id: string, includeDisabled = false): IChatAgentData | undefined {
476 > if (!this._agentIsEnabled(id) && !includeDisabled) { chatAgents.ts
477 return;
478 }
480 > return this._agents.get(id)?.data;
481 > }
482
483 private _agentIsEnabled(idOrAgent: string | IChatAgentEntry): boolean {
484 > const entry = typeof idOrAgent === 'string' ? this._agents.get(idOrAgent) : idOrAgent; chatAgents.ts
485 > return !entry?.data.when || this.contextKeyService.contextMatchesRules(ContextKeyExpr.deserialize(entry.data.when));
486 > }
487
488 getAgentByFullyQualifiedId(id: string): IChatAgentData | undefined {
499 */
500 getAgents(): IChatAgentData[] {
501 > return Array.from(this._agents.values()) chatAgents.ts
502 > .map(entry => entry.data)
503 > .filter(a => this._agentIsEnabled(a.id));
504 > }
505
506 getActivatedAgents(): IChatAgent[] {