claudeAgent.ts ×10

Frontier kind: Code frontier

unlabeled · c_289e3fed7c2d

11 tests · 56864 LOC · 346 files · introduces 0 tests · 65 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
10 ranges65 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5725 ranges56864 lines · 346 files · Browse complete extent
All tests (intent)
11 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: 65 introduced LOC across 10 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/claude/claudeAgent.ts 65 introduced LOC · 10 ranges

Open complete file

1428 return undefined;
1429 }
1430 > const { sessionId } = await this._sdkService.forkSession(sourceSdkId, { upToMessageId }); claudeAgent.ts
1431 > const anchorIndex = messages.findIndex(message => message.uuid === upToMessageId);
1432 > const inheritedTurnCount = mapSessionMessagesToTurns(messages.slice(0, anchorIndex + 1), fork.source, this._logService).length;
1433 > return { sessionId, inheritedTurnCount };
1434 }
1435
1487 */
1488 private _ensureSessionEntry(session: URI): Promise<ClaudeSessionEntry> {
1489 > const sessionId = AgentSession.id(session); claudeAgent.ts
1490 > return this._sessionSequencer.queue(sessionId, async () => {
1491 > const existing = this._sessions.get(sessionId);
1492 > if (existing) {
1493 return existing;
1494 }
1509 );
1510 return this._seedSessionEntry(sessionId, session, mainSession);
1511 > }); claudeAgent.ts
1512 > }
1513
1514 /**
1521 */
1522 private async _materializeChatLocked(session: URI, chat: URI): Promise<ClaudeAgentSession> {
1523 > const chatKey = chat.toString(); claudeAgent.ts
1524 > const entry = await this._ensureSessionEntry(session);
1525 > const existing = entry.getPeerChat(chatKey);
1526 > if (existing?.isPipelineReady) {
1527 return existing;
1528 }
1529 > const chatSession = existing ?? await this._buildProvisionalChat(session, chat, entry); claudeAgent.ts
1530 > // Resume when the SDK already has a transcript for this chat
1531 > // (forked or restored); otherwise materialize a fresh one.
1532 > const sdkInfo = await this._sdkService.getSessionInfo(chatSession.sessionId);
1533 > const transport = this._ensureAuthenticated();
1534 > const canUseTool = this._makeCanUseTool(chatSession.sessionId);
1535 > const onElicitation = this._makeOnElicitation(chatSession.sessionId);
1536 > try {
1537 > await chatSession.materialize({ transport, canUseTool, onElicitation, isResume: !!sdkInfo, serverToolHost: this._serverToolHost });
1538 > } catch (err) {
1539 entry.disposePeerChat(chatKey);
1540 throw err;
1541 }
1542 > return chatSession; claudeAgent.ts
1543 > }
1544
1545 /**
1551 */
1552 private async _buildProvisionalChat(session: URI, chat: URI, entry: ClaudeSessionEntry): Promise<ClaudeAgentSession> {
1553 > const info = this._resolveChatBacking(chat); claudeAgent.ts
1554 > if (!info) {
1555 throw new Error(`[Claude] no backing chat for chat ${chat.toString()}`);
1556 }
1557 > const parentSession = await this._resolveParentSession(session, AgentSession.id(session)); claudeAgent.ts
1558 > let overlay: IClaudeSessionOverlay = {};
1559 > try {
1560 > overlay = await this._metadataStore.read(chat);
1561 > } catch (err) {
1562 this._logService.warn(`[Claude] chat overlay read failed for ${chat.toString()}; continuing with defaults`, err);
1563 }
1564 > const permissionMode = readClaudePermissionMode(this._configurationService, chat) ?? overlay.permissionMode ?? parentSession.permissionMode; claudeAgent.ts
1565 > // Overlay takes precedence over the backing: `changeModel` always writes
1566 > // the overlay first (via `setModel` or `_metadataStore.write`) and then
1567 > // the backing. If the backing update is lost, the overlay already holds
1568 > // the newest model; preferring it here ensures a model change is never
1569 > // silently reverted after a restart.
1570 > const model = overlay.model ?? info.model;
1571 > const chatSession = ClaudeAgentSession.createProvisional(
1572 > info.sdkSessionId,
1573 > session,
1574 > chat,
1575 > parentSession.workingDirectory,
1576 > parentSession.project,
1577 > model,
1578 > overlay.agent ?? parentSession.agent,
1579 > undefined,
1580 > new PendingRequestRegistry<CallToolResult>(),
1581 > permissionMode,
1582 > this._metadataStore,
1583 > this._instantiationService,
1584 > );
1585 > entry.registerPeerChat(chat.toString(), this._wireEntry(chatSession));
1586 > return chatSession;
1587 > }
1588
1589 /**
1924 // session under it.
1925 if (context.isPeerChat) {
1926 > return this._sessionSequencer.queue(context.chatKey, async () => { claudeAgent.ts
1927 > const chatSession = await this._materializeChatLocked(context.session, chat);
1928 > const sideChat = this._resolveChatBacking(chat)?.sideChat;
1929 > const turns = sideChat ? await this._reconstructTurns(chatSession.sessionId, chat, chatSession) : [];
1930 > const sdkPrompt = prepareSideChatPrompt(prompt, turns, sideChat);
1931 > await chatSession.send(this._buildSdkPrompt(chatSession.sessionId, sdkPrompt, attachments, effectiveTurnId), effectiveTurnId);
1932 > });
1933 > }
1934
1935 // Plan section 3.8. The sequencer scope holds across BOTH materialize