copilotAgent.ts ×6

Frontier kind: Code frontier

unlabeled · c_023990b714cc

15 tests · 53453 LOC · 300 files · introduces 0 tests · 51 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
6 ranges51 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5451 ranges53453 lines · 300 files · Browse complete extent
All tests (intent)
15 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: 51 introduced LOC across 6 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/agentHost/node/copilot/copilotAgent.ts 51 introduced LOC · 6 ranges

Open complete file

1880 */
1881 private async _materializeProvisional(sessionId: string, resolvedWorkingDirectory?: URI): Promise<CopilotAgentSession> {
1882 > const provisional = this._provisionalSessions.get(sessionId); copilotAgent.ts
1883 > if (!provisional) {
1884 throw new Error(`Cannot materialize unknown provisional session: ${sessionId}`);
1885 }
1886 > const client = await this._ensureClient(); copilotAgent.ts
1887 > const sessionUri = provisional.sessionUri;
1888 >
1889 > // The host hands us the resolved working directory (an isolated worktree for
1890 > // worktree isolation) on the first send; use it so the SDK subprocess spawns
1891 > // in the worktree. Falls back to the folder / scratch dir captured at create
1892 > // time for folder / workspace-less sessions.
1893 > const workingDirectory = resolvedWorkingDirectory ?? provisional.workingDirectory;
1894 > // The customization anchor follows the working directory: once a worktree
1895 > // is created the agent must discover skills/instructions/agents from the
1896 > // worktree (not the user-picked folder) so the model reads and edits files
1897 > // in the worktree it actually runs in.
1898 > const customizationDirectory = workingDirectory ?? provisional.workingDirectory;
1899 > // Always create an ActiveClient so the snapshot includes host +
1900 > // session-discovered customizations, even when no client has
1901 > // registered an active-client handle yet.
1902 > const activeClient = this._getOrCreateActiveClient(sessionUri, customizationDirectory);
1903 > // Re-anchor in case the provisional active client was already bound to the
1904 > // user-picked folder before the worktree existed.
1905 > activeClient.pluginController.reanchor(customizationDirectory);
1906 > const snapshot = await activeClient.snapshot();
1907 > const shellManager = this._instantiationService.createInstance(ShellManager, sessionUri, workingDirectory);
1908 >
1909 > let agentSession: CopilotAgentSession | undefined;
1910 > let agent: AgentSelection | undefined;
1911 > try {
1912 > const resolvedAgent = await this._resolveAgentWhenMaterializing(provisional, snapshot, workingDirectory);
1913 > agent = resolvedAgent?.agent;
1914 > const launchPlan: CopilotSessionLaunchPlan = {
1915 > kind: 'create',
1916 > client,
1917 > sessionId,
1918 > workingDirectory,
1919 > resolvedAgentName: resolvedAgent?.name,
1920 > snapshot,
1921 > activeClientToolSet: activeClient.toolSet,
1922 > shellManager,
1923 > githubToken: this._githubToken,
1924 > model: provisional.model,
1925 > longContextWindow: this._longContextWindowFor(provisional.model?.id),
1926 > freeLongContext: this._isFreeLongContext(provisional.model?.id),
1927 > workspaceless: provisional.workspaceless,
1928 > };
1929 > agentSession = this._createAgentSession(launchPlan, customizationDirectory, activeClient);
1930 > await agentSession.initializeSession();
1931 this._registerInitializedSession(sessionId, agentSession);
1932 > } catch (error) { copilotAgent.ts
1933 agentSession?.dispose();
1934 throw error;
1935 }
1936
1937 > const project = await projectFromCopilotContext({ cwd: workingDirectory?.fsPath }, this._gitService); copilotAgent.ts
1938
1939 this._provisionalSessions.delete(sessionId);
1956 this._onDidMaterializeSession.fire({ session: sessionUri, workingDirectory, project });
1957 return agentSession;
1958 > } copilotAgent.ts
1959
1960 private async _resolveAgentWhenMaterializing(provisional: IProvisionalSession, snapshot: IActiveClientSnapshot, workingDirectory: URI | undefined): Promise<{ agent: AgentSelection; name: string } | undefined> {
2088 let entry: CopilotAgentSession | undefined;
2089 if (this._provisionalSessions.has(context.sessionId)) {
2090 > entry = await this._materializeProvisional(context.sessionId, workingDirectory); copilotAgent.ts
2091 } else {
2092 entry = this._getChatContext(chat).target;