claudeSdkMessageRouter.ts ×4

Frontier kind: Code frontier

unlabeled · c_209004c4695b

221 tests · 27623 LOC · 125 files · introduces 0 tests · 46 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
4 ranges46 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2266 ranges27623 lines · 125 files · Browse complete extent
All tests (intent)
221 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: 46 introduced LOC across 4 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/claude/claudeSdkMessageRouter.ts 46 introduced LOC · 4 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- claudeSdkMessageRouter.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import type { SDKMessage } from '@anthropic-ai/claude-agent-sdk';
7 > import { Emitter, Event } from '../../../../base/common/event.js';
8 > import { Disposable, IReference } from '../../../../base/common/lifecycle.js';
9 > import { URI } from '../../../../base/common/uri.js';
10 > import { IInstantiationService } from '../../../instantiation/common/instantiation.js';
11 > import { ILogService } from '../../../log/common/log.js';
12 > import { AgentSignal } from '../../common/agentService.js';
13 > import { ISessionDatabase } from '../../common/sessionDataService.js';
14 > import { ClaudeFileEditObserver } from './claudeFileEditObserver.js';
15 > import { ClaudeMapperState, mapSDKMessageToAgentSignals } from './claudeMapSessionEvents.js';
16 > import type { SubagentRegistry } from './claudeSubagentRegistry.js';
17 >
18 > /**
19 > * Per-message router. Awaits file-edit observation for `type: 'user'`
20 > * messages so the cached edit lands before {@link mapSDKMessageToAgentSignals}
21 > * reads it via `state.takeFileEdit`, then fires mapped signals on
22 > * {@link onDidProduceSignal}. Mapper failures are logged but never thrown.
23 > *
24 > * Owns the per-session {@link ClaudeFileEditObserver} (Phase 8) and
25 > * {@link ClaudeMapperState} (Phase 7) — both are private to the
26 > * message-handling pipeline and have no other consumers. Phase 12
27 > * subagent correlation state lives on {@link IClaudeSubagentResolver}
28 > * (host-singleton, keyed by parent session URI), which the router
29 > * forwards into every mapper invocation.
30 > */
31 > export class ClaudeSdkMessageRouter extends Disposable {
32 >
33 > private readonly _onDidProduceSignal = this._register(new Emitter<AgentSignal>());
34 > readonly onDidProduceSignal: Event<AgentSignal> = this._onDidProduceSignal.event;
35 >
36 > private readonly _editObserver: ClaudeFileEditObserver;
37 > private readonly _mapperState = new ClaudeMapperState();
38 >
39 > private _clientToolOwner: ((toolName: string) => string | undefined) | undefined;
40 >
41 > constructor(
42 sessionUri: URI,
43 private readonly _chatChannelUri: URI,
54 );
55 }
57 > setClientToolOwner(clientToolOwner: ((toolName: string) => string | undefined) | undefined): void {
58 this._clientToolOwner = clientToolOwner;
59 }
61 > async handle(message: SDKMessage, turnId: string | undefined, turnDuration?: number): Promise<void> {
62 if (message.type === 'assistant') {
63 this._editObserver.observeAssistant(message);