agentService.ts ×8

Frontier kind: Code frontier

unlabeled · c_0ad6ceef6b28

87 tests · 50457 LOC · 304 files · introduces 0 tests · 26 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges26 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5051 ranges50457 lines · 304 files · Browse complete extent
All tests (intent)
87 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: 26 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/agentService.ts 26 introduced LOC · 8 ranges

Open complete file

957
958 async createSession(config?: IAgentCreateSessionConfig): Promise<URI> {
959 > const providerId = config?.provider ?? this._defaultProvider; agentService.ts
960 > const provider = providerId ? this._providers.get(providerId) : undefined;
961 > if (!provider) {
962 throw new Error(`No agent provider registered for: ${providerId ?? '(none)'}`);
963 }
968 // "fork" is indistinguishable from a fresh session, so we drop the
969 // fork parameter and fall through to the regular create path.
970 > if (config?.fork) { agentService.ts
971 const sourceState = this._stateManager.getSessionState(config.fork.session.toString());
972 const sourceTurns = sourceState?.turns.slice(0, config.fork.turnIndex + 1) ?? [];
995 // seed below — keeping edit / fork / truncate addressable at the SDK
996 // boundary.
997 > if (config?.importConversation) { agentService.ts
998 const importedTurns = config.importConversation.turns.map(t => ({ ...t, id: generateUuid() }));
999 config = { ...config, importConversation: { ...config.importConversation, turns: importedTurns } };
1006 const initializeSideEffects = this._sideEffects.initialize();
1007 const sessionConfig = await this._resolveCreatedSessionConfig(provider, config);
1008 > const deferWorktreeCreation = sessionConfig?.values?.[SessionConfigKey.Isolation] === 'worktree' && !config?.fork && !config?.importConversation; agentService.ts
1009 >
1010 > this._logService.trace(`[AgentService] createSession: initializing auto-approver and creating session...`);
1011 > const [, created] = await Promise.all([
1012 > initializeSideEffects,
1013 > this._createProviderSession(provider, config, deferWorktreeCreation),
1014 > ]);
1015 const session = created.session;
1016 this._logService.trace(`[AgentService] createSession: initialization complete`);
1024 this._cancelPendingSessionRelease(session);
1025
1026 > this._logService.trace(`[AgentService] createSession: provider=${provider.id} model=${config?.model?.id ?? '(default)'}`); agentService.ts
1027 > this._sessionToProvider.set(session.toString(), provider.id);
1028 > // Record this session's opt-in so a cold SDK download triggered at
1029 > // materialization (first message) is surfaced as progress. The download
1030 > // is provider-global, so we only track interest here; emission is keyed
1031 > // by the download's own identity, not this token. Cleared on
1032 > // materialize/dispose.
1033 > if (config?.progressToken) {
1034 let sessions = this._downloadProgressInterest.get(provider.id);
1035 if (!sessions) {
1061 // When forking, populate the new session's protocol state with
1062 // the source session's turns so the client sees the forked history.
1063 > if (config?.fork) { agentService.ts
1064 const sourceState = this._stateManager.getSessionState(config.fork.session.toString());
1065 const sourceChatUri = buildDefaultChatUri(config.fork.session).toString();
1148 // to re-resolve. Mid-session changes are persisted by `AgentSideEffects`
1149 // when handling `SessionConfigChanged`.
1150 > if (sessionConfig?.values && Object.keys(sessionConfig.values).length > 0 && !created.provisional) { agentService.ts
1151 this._persistConfigValues(session, sessionConfig.values);
1152 }
1170 // Refresh the git state for the session.
1171 const workingDirectory = created.workingDirectory ?? config?.workingDirectory;
1172 > void this._gitStateService.refreshSessionGitState(session.toString(), workingDirectory); agentService.ts
1173 >
1174 > return session;
1175 > }
1176
1177 async createChat(session: URI, chat: URI, options?: IAgentCreateChatOptions): Promise<void> {