Commit Graph

37 Commits

Author SHA1 Message Date
Connor Peet
b7462b4a00 Merge pull request #303597 from microsoft/connor4312/agent-host-server-fixups
agentHost: fixup build for server
2026-03-20 13:54:33 -07:00
Josh Spicer
2a5a1757fd build(next): include sessions built-in skills in desktop resources (#302297)
Enhance AI Customization: Add support for plugin skills in data source
2026-03-16 19:06:19 -07:00
Rob Lourens
98f15b55ea Implement agentHost process (#296627)
* agent host init

* Agent host: Copilot SDK integration with chat UI

* Agent host: direct MessagePort, logging, SDK wrapper, env fix

* Refactoring and cleanup

* Copilot-authored message: Agent-host tool rendering, protocol, and session fixes

Tool invocation rendering:
- Emit tool_start/tool_complete as ChatToolInvocation (not progressMessage)
- Shell tools (bash/powershell) render as terminal command blocks with
  IChatTerminalToolInvocationData, output, and exit codes
- Non-shell tools render via invocationMessage/pastTenseMessage (markdown)
- Filter out report_intent (hidden internal tool)

Agent-agnostic protocol:
- IPC events carry display-ready fields (displayName, invocationMessage,
  pastTenseMessage, toolInput, toolOutput, toolKind, language)
- All Copilot CLI-specific logic in copilotToolDisplay.ts with typed
  interfaces for known tools (CopilotToolName enum, parameter types)
- Renderer never references specific SDK tool names

Session fixes:
- Resumed sessions show tool invocations in history (getSessionMessages
  now returns tool events alongside messages)
- Fixed 'already has a pending request' on resumed sessions by
  conditionally providing interruptActiveResponseCallback
- Fixed event filtering for resumed sessions (sessionId override in
  _trackSession)

Documentation:
- Split parity.md into design.md (decisions) and backlog.md (tasks)
- Updated architecture.md, sessions.md with cross-references
- Added maintenance notes to all docs

* Copilot-authored message: Model picker, session class, DI and test cleanup

* Cleanups

* stuff

* add diagram

* Add claude agent

* Clean up

* Copy some build script changes from #295817

* Simplify

* Update docs

* Register agent-host via chatSessions contribution API, reduce peripheral diff

* Cleanup

* Don't ship stuff in stable

* Dynamic agent discovery via listAgents() IPC

Replace hardcoded per-provider contributions with a single
AgentHostContribution that discovers available agents from the
agent host process at startup. Each IAgent backend now exposes
an IAgentDescriptor with display metadata and auth requirements.

- Add IAgentDescriptor interface and listAgents() to IPC contract
- CopilotAgent/ClaudeAgent return descriptors via getDescriptor()
- Single AgentHostContribution discovers + registers dynamically
- Remove agentHostConstants.ts (no more hardcoded session types)
- AgentHostSessionListController/LMProvider take params instead
- Rename AgentSessionProviders.AgentHost -> AgentHostCopilot
- Update architecture.md, sessions.md, backlog.md

(Written by Copilot)

* Fix review findings: proxy, disposal, filtering, tests

- Add listAgents() forwarding to AgentHostServiceClient
- Guard async discovery against disposal race
- Add provider field to IAgentModelInfo for per-provider filtering
- Filter models and sessions by provider in LM provider and list
  controller
- Update tests for new dynamic API and agent-host-copilot scheme

(Written by Copilot)

* Use DI for AgentHostLanguageModelProvider

(Written by Copilot)

* Strip @img/sharp native binaries from builds

sharp is a transitive dependency of the Claude Agent SDK used for
image processing. Its native .node binaries cause dpkg-shlibdeps
errors during Debian packaging due to $ORIGIN RPATH references.
Strip all @img/sharp-* platform packages since the agent host
doesn't need image processing at runtime.

(Written by Copilot)

* Strip Claude SDK vendored ripgrep binaries

The Claude Agent SDK bundles ripgrep binaries for all platforms
under vendor/ripgrep/. Wrong-architecture binaries cause macOS
Mach-O verification to fail. Strip them entirely via .moduleignore
(VS Code has its own ripgrep) and add to verify-macho skip list.

(Written by Copilot)

* Add tests for AgentSession, AgentService dispatcher, and workbench agent host components

(Written by Copilot)

* Add trace logging, IPC output channel, tool permissions, and attachment context

- Add Agent Host IPC output channel (only registered at trace log level) that
  logs all IPC method calls, results, and progress events with full JSON payloads
- Add trace-level logging in AgentService dispatcher for all method calls
- Add trace-level logging in session handler for all progress events and session
  resolution
- Wire up onPermissionRequest handler on CopilotClient.createSession and
  resumeSession to auto-approve tool permission requests
- Add IAgentAttachment type to IPC contract and thread attachments from chat
  variables (file, directory, selection) through sendMessage to the Copilot SDK

(Written by Copilot)

* Add tests for attachment context conversion and threading

(Written by Copilot)

* Add gap analysis docs for Copilot and Claude SDK implementations

(Written by Copilot)

* Sanitize env vars for Copilot CLI subprocess

Strip VSCODE_*, ELECTRON_* (except ELECTRON_RUN_AS_NODE), NODE_OPTIONS, and
other debug-related env vars that can interfere with the Node.js process the
SDK spawns. Matches the env sanitization from the extension implementation.
Also set useStdio and autoStart for proper CLI communication.

(Written by Copilot)

* Add error, usage, and title_changed event types to IPC contract

Add IAgentErrorEvent, IAgentUsageEvent, and IAgentTitleChangedEvent to the
progress event union. Wire up session.error and assistant.usage events from
the Copilot SDK to fire as IPC events instead of only logging. Handle error
events in the renderer session handler by rendering the error message. Usage
and title_changed events are logged at trace level.

(Written by Copilot)

* Add abortSession IPC method for proper cancellation

Add abortSession(session) to the IPC contract, implemented across AgentService,
CopilotAgent (calls session.abort()), ClaudeAgent (no-op, uses AbortController),
and the renderer proxy. Wire up cancellation in the session handler to call
abortSession before finishing, so the SDK actually stops processing.

(Written by Copilot)

* Address reviewer feedback: error finishes request, Claude abort, tests

- Error events now call finish() so the request doesn't hang if the SDK
  doesn't send idle after an error
- ClaudeAgent.abortSession calls ClaudeSession.abort() which signals the
  AbortController and creates a new one for future turns
- Add test: cancellation calls abortSession on the agent host service
- Add test: error event renders message and finishes the request
- Remove stale TODO in interruptActiveResponseCallback
- Use timeout() helper instead of raw setTimeout in test
- Update gap docs to reflect completed work

(Written by Copilot)

* Add permission request IPC round-trip (Written by Copilot)

* Remove Claude agent from agent-host process

Strip the Claude Agent SDK integration from the agent-host utility process
to focus on the Copilot SDK path.

- Delete src/vs/platform/agent/node/claude/ (claudeAgent, claudeSession, claudeToolDisplay)
- Remove @anthropic-ai/claude-agent-sdk from package.json
- Remove AgentHostClaude enum member and all switch cases
- Remove Claude command registration in electron-browser chat.contribution
- Clean up build scripts (.moduleignore, verify-macho, gulpfile.vscode)
- Narrow AgentProvider type to just 'copilot'
- Update tests and documentation

(Written by Copilot)

* Wire up permission confirmation UI with ChatToolInvocation (Written by Copilot)

* Fix reviewer feedback: safe permission serialization, deny on abort/dispose (Written by Copilot)

* Forward reasoning events as thinking blocks (Written by Copilot)

* Pass workspace folder as workingDirectory to Copilot SDK (Written by Copilot)

* Store and pass workingDirectory on session resume, update gap docs (Written by Copilot)

* Fix permission rendering, session-scoped permissions, and test gaps (Written by Copilot)

* Auto-approve read permissions inside workspace folder (Written by Copilot)

* Move read auto-approve into CopilotAgent where permission policy belongs (Written by Copilot)

* Update gap docs (Written by Copilot)

* Use log language for IPC output channel, add trace prefix (Written by Copilot)

* Add tool rendering gaps to docs (Written by Copilot)

* Stringify URIs in IPC output channel for readability (Written by Copilot)

* Fix IPC output channel: use log languageId with non-log channel for proper append + syntax highlighting (Written by Copilot)

* Fix build errors: add URI import, fix test mock types (Written by Copilot)

* Don't localize agent host provider strings (Written by Copilot)

* Remove claude-agent-sdk from eslint allowed imports (Written by Copilot)

* fix test

* initial thoughts

* Rename folder to agentHost

* Fix paths

* Fixes

* Fixes for copilot

* Fix moduleignore

* first working protocol version

align more closely with protocol

json rpc and some gaps

* cleanup

* Fix copilot pty.node packaging

* Fix test

* prebuild packaging

* Agenthost server fixes

* Update monaco.d.ts

* Update docs

* Fixes

* Build fix

* Fix build issues

* reduce duplication in side effecting code

* fix model switching not working

* reduce mock duplication

* Build fixes

* Copy vscode's node.pty

* And ripgrep

* And thsi

* Ripgrep goes to non-SDK

* Skip copy for stable build

* Remove outdated script

* Build fixes for asar

* fix

* Add some logging

* Fix for windows

* Fix

* Logs

* build: add glob diagnostic for copyCopilotNativeDeps

* build: check both node_modules/ and .asar.unpacked/ for source binaries

* Fix

* Remove excalidraw

---------

Co-authored-by: Connor Peet <connor@peet.io>
Co-authored-by: Connor Peet <copeet@microsoft.com>
2026-03-16 15:33:31 -07:00
Anthony Kim
a0d3bb68f2 Fix PSReadline for screen reader (#298881)
* Fix PSReadline for screen reader, disable header

* Add psreadline to index.ts for build

* organize much better

* compile

* list out exact folder

* try if codesign is the problem

* Update comment to be more accurate

* Undo changes for noLogo
2026-03-10 19:35:11 -07:00
Johannes Rieken
cb61e0d5bd Fix source path duplication in NLS plugin source maps and add corresponding test (#300487) 2026-03-11 04:57:33 +11:00
Josh Spicer
abe7ae5449 fix: include sessions built-in prompts in esbuild resource patterns (#299848)
The new esbuild-based CI pipeline (core-ci) uses curated resource
patterns in build/next/index.ts to copy non-JS assets into the bundle
output. When built-in .prompt.md files were added for the sessions
window, they were included in the legacy pipeline's
vscodeResourceIncludes (build/gulpfile.vscode.ts) but not in the
desktopResourcePatterns used by the esbuild pipeline.

This caused the prompt files to be missing from release builds
(out-vscode-min), even though they worked correctly when running
from sources (where copyAllNonTsFiles copies everything).

Add 'vs/sessions/prompts/*.prompt.md' to desktopResourcePatterns
to match the existing entry in vscodeResourceIncludes.
2026-03-06 12:02:44 -08:00
Johannes
ccbe5ab074 Enhance source map handling in NLS plugin and related components
- Introduced adjustments for source maps in the NLS plugin to ensure accurate mapping after placeholder replacements.
- Implemented deferred processing for source maps to handle edits more effectively, preserving unmapped segments.
- Updated tests to validate column mappings and ensure correctness in both minified and non-minified builds.
- Improved documentation to reflect changes in source map generation and adjustments.
2026-03-03 08:51:36 +01:00
João Moreno
d2f1f7ce97 Inline Compile & CompileCLI stages into platform specific jobs (#296006)
* chore: ralph loop checkpoint - 2026-02-17 12:48

* fix shell script

* Inline compile stage into platform jobs

Remove the standalone Compile stage from the ADO pipeline. Each
platform job (Windows, Linux, macOS, Alpine, Web) now compiles
TypeScript itself instead of downloading a shared Compilation artifact.

- Add VSCODE_RUN_CHECKS parameter to Linux jobs for hygiene/lint/CG
- Add VSCODE_RUN_COMPILE_EXTRAS parameter to macOS jobs for telemetry
  extraction and sourcemap upload
- Remove VSCODE_COMPILE_ONLY parameter entirely
- Delete product-compile.yml (no longer referenced)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Always run telemetry extraction on macOS builds

The macOS Universal app merge requires both x64 and arm64 builds to have
identical file sets. Telemetry extraction was only running on arm64 (via
VSCODE_RUN_COMPILE_EXTRAS), causing the universal merge to fail due to
missing telemetry-core.json and telemetry-extensions.json in the x64 build.

Move telemetry extraction outside the VSCODE_RUN_COMPILE_EXTRAS gate so
it runs on all macOS builds. Sourcemap upload remains gated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Run telemetry extraction on all client builds

All client builds (Linux, Windows, macOS) need telemetry-core.json and
telemetry-extensions.json. Previously only macOS arm64 ran extract-telemetry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Only run telemetry extraction on Linux x64 (client build)

Linux arm64 and armhf are server-only builds, no need for telemetry files.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Remove .ralph scaffolding files

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix telemetry extraction on Windows with native PowerShell

The bash extract-telemetry.sh script fails on Windows because the Unix
bin shim gets interpreted as Node.js code. Use a native PowerShell
implementation that calls the extractor JS entry point directly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Handle missing telemetry files gracefully on Windows

The telemetry extractor may skip emitting declarations-resolved.json
when no events are found. Handle this case with a warning instead of
failing the build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Use deterministic build date from git commit timestamp

When each platform compiles independently, the build date embedded in
cli.js (via INSERT_PRODUCT_CONFIGURATION) differs between machines
because each uses new Date().toISOString(). This causes the macOS
Universal app merge to fail since cli.js SHA differs between x64/arm64.

Fix: use the git commit date (git log -1 --format=%cI HEAD) instead
of the current wall-clock time. This ensures all independent builds
on different machines produce identical timestamps.

Updated in:
- build/lib/date.ts: writeISODate() uses git commit date
- build/next/index.ts: bundle(), transpile, and readISODate fallback
  all use git commit date

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Remove redundant extensions-ci task from CI pipelines

core-ci (esbuild path) already includes cleanExtensionsBuildTask,
compileNonNativeExtensionsBuildTask, and compileExtensionMediaBuildTask.
Running extensions-ci in parallel caused a race condition where
core-ci's rimraf of .build/extensions clashed with extensions-ci
writing to the same directory.

Also removes dead code:
- extensions-ci and extensions-ci-pr task definitions (fully subsumed)
- core-ci-old task (useEsbuildTranspile is always true)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* remove VSCODE_RUN_COMPILE_EXTRAS

* address PR feedback regarding code duplication of `getGitCommitDate()` function by exporting a single helper function from `build/lib/date.ts` and importing it in `build/next/index.ts` to ensure consistent behavior and improve code maintainability.

* update readISODate function to return git commit date instead of current date

* add telemetry sorting script and integrate into build process for consistent output

* refactor telemetry extraction process: replace shell script with TypeScript implementation

* update skill

* update telemetry-extractor dependency to version 1.19.0

* fix build

* fix more duplicate telemetry definition issues

* cleanup

* refactor: consolidate validation checks into quality checks and remove obsolete tasks

* bust the cache

* undo cache bust

* fix expression

* fix

* fix: update Azure storage account name in quality checks

* fix: initialize stages set with 'Quality'

* fix: add VSCODE_BUILD_TYPE parameter with options for Product and CI builds

* fix: update Azure Pipeline CLI to use parameters instead of variables for queueing builds

* fix: update VSCODE_BUILD_TYPE parameter values for clarity

* fix: update default value for VSCODE_BUILD_TYPE parameter to 'Product'

* leaner

* even leaner

* only npm ci in build

* 💄

* run entire npm ci

* fix

* fix

* fix it

* Inline CompileCLI into platform stages

- Remove centralized CompileCLI stage
- Move CLI jobs into Windows, Linux, macOS stages as independent jobs
- CLI jobs now compile, publish unsigned mid-job, sign, and publish signed
- Platform compile jobs use deemon + waitForArtifacts for async CLI download
- Delete separate CLI sign jobs (now merged into CLI compile jobs)
- Remove CompileCLI from publish.ts stage tracking

* fix: macOS CLI signing - use proper directory structure for ESRP

* fix: add BUILDS_API_URL to Windows and Linux job templates

* fix: label Linux CLI jobs clearly

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: João Moreno <22350+joaomoreno@users.noreply.github.com>
2026-03-01 08:48:08 +01:00
Johannes Rieken
9c2922a85d feat: enhance source map handling in NLS and private field conversion (#296957)
* feat: enhance source map handling in NLS and private field conversion

- Implemented inline source maps in the NLS plugin to ensure accurate mapping from transformed source back to original.
- Modified `transformToPlaceholders` to return edits for source map adjustments.
- Added `adjustSourceMap` function to update source maps based on text edits in `convertPrivateFields`.
- Introduced tests for source map accuracy in both NLS and private field conversion scenarios.
- Updated documentation to reflect changes in source map handling and the rationale behind accepting column imprecision.

* address PR review: fix source name collision, guard unmapped segments, reorder mangle before NLS
2026-02-23 12:09:29 +00:00
Matt Bierner
bf3b738a9f Try to align scanBuiltinExtensions with new esbuild changes 2026-02-17 10:01:30 -08:00
Benjamin Pasero
b1009c98bb Sessions exploration (#294912) 2026-02-17 14:14:39 +00:00
Johannes Rieken
b82bde5026 Change sourcemap option from 'external' to 'linked' for better debugging support (#295569) 2026-02-16 12:55:58 +01:00
Johannes
814a9ce765 Refactor resource copying for transpile and bundle builds
- Implemented copyAllNonTsFiles() for transpile/dev builds to copy all non-TS files from src/ to output, aligning with previous gulp behavior.
- Retained copyResources() for production builds using curated resource patterns.
- Removed unnecessary devOnlyResourcePatterns and testFixturePatterns.
- Updated watch mode to accept any non-TS file changes.
2026-02-13 15:38:39 +01:00
Johannes
bccf22cb8d Exclude 2026-02-13 14:59:16 +01:00
Johannes
7c6cca7b14 Add native private field to property transform for esbuild bundles 2026-02-13 14:44:33 +01:00
Johannes Rieken
7687ea5f10 Add SVG resource patterns for transpile/dev builds (#295119) 2026-02-13 10:00:14 +00:00
Johannes Rieken
3a8ad661c4 Refactor transpileFile function to remove unused parameter and update sourcefile reference (#294867) 2026-02-12 11:53:38 +00:00
Johannes
7ae568ab1e refactor: streamline NLS messages writing in finalizeNLS function 2026-02-11 14:48:47 +01:00
Johannes
34ced5fa6e write 2026-02-11 10:21:02 +01:00
Johannes
e562211c1f fix: remove keyboardMapEntryPoints from desktop entry points and nls.messages.js generation 2026-02-10 17:30:14 +01:00
Johannes
3180e9482c fix: remove test file exclusion from watch stream 2026-02-10 17:06:49 +01:00
Johannes
edc58f9da1 delete: remove obsolete compare-builds script 2026-02-10 12:45:14 +01:00
Johannes
18456cc05f source maps: sourcesContent, CDN URL rewriting, replace @parcel/watcher 2026-02-10 11:10:12 +01:00
Johannes
9a9079bf26 esbuild: 2026-02-09 21:11:03 +01:00
Johannes
6d6e9a4f3e Refactor build process: remove unused entry points and update resource patterns for desktop build 2026-02-09 18:00:57 +01:00
Johannes
696c09b061 add 2026-02-09 10:53:56 +01:00
Johannes
878df8b755 Refactor build system to support esbuild with new transpile and typecheck tasks 2026-02-06 11:36:52 +01:00
Johannes
772a2d094e Refactor build system: replace createFileContentMapper with fileContentMapperPlugin for better integration with esbuild 2026-02-05 18:38:36 +01:00
Johannes
02e60e2be0 feat: add esbuild-based bundling tasks for standalone web target 2026-02-04 16:51:45 +01:00
Johannes
ca10b50e6b fix: update regex in replaceInOutput to handle both single and double quotes for NLS placeholders 2026-02-04 11:39:01 +01:00
Johannes
7cf0cec198 feat: enhance build process with product configuration and built-in extensions scanning 2026-02-04 09:42:00 +01:00
Johannes
ed6fcf28c2 feat: add esbuild transpile task with support for excluding test files and customizable output directory 2026-02-04 07:38:05 +01:00
Johannes
cacf5f84fc feat: enhance finalizeNLS to support writing to multiple output directories for backwards compatibility 2026-02-03 20:36:55 +01:00
Johannes
07e68d11dd fix: update date handling in jsonEditor for product.json and add build date file in bundle process 2026-02-03 18:18:05 +01:00
Johannes
286945b656 feat: enhance esbuild bundling with target support for desktop, server, and server-web 2026-02-03 12:18:39 +01:00
Johannes
73dcb4734d feat: implement esbuild-based bundling tasks and enhance NLS processing 2026-02-02 18:04:20 +01:00
Johannes
7642c07690 feat(nls): implement NLS plugin for esbuild with message extraction and processing 2026-01-30 18:31:27 +01:00