Commit Graph

55 Commits

Author SHA1 Message Date
Rob Lourens
513b43f0b7 Renaming agent host sessions (#306204)
* Renaming agent host sessions

Co-authored-by: Copilot <copilot@github.com>

* Update

* Resolve comments

Co-authored-by: Copilot <copilot@github.com>

* Clean up

Co-authored-by: Copilot <copilot@github.com>

* Fix

Co-authored-by: Copilot <copilot@github.com>

* fix

Co-authored-by: Copilot <copilot@github.com>

* fixes

Co-authored-by: Copilot <copilot@github.com>

* Update version

* Cleanup

Co-authored-by: Copilot <copilot@github.com>

---------

Co-authored-by: Copilot <copilot@github.com>
2026-03-31 07:46:14 +02:00
Rob Lourens
9a11a08c75 Fix remote agent host session issues in Sessions app (#306560)
- Handle message events in AgentEventMapper to emit markdown response
  parts for text that arrives without preceding delta events (e.g. after
  tool calls complete)
- Fix tool call confirmation flickering by guarding PendingConfirmation
  re-entry when the invocation is already waiting for confirmation
- Fix tool call duplication in server-initiated turns and reconnection
  by not removing finalized tool calls from the tracking map
- Add isComplete guard in finish() to avoid overwriting finalized tool
  call state
- Extract processState in _trackServerTurnProgress for immediate state
  reconciliation closing gaps between turn detection and listener
  registration
- Fix session disappearing from list after first message by adding
  pending session tracking and onDidReplaceSession in the remote
  sessions provider
- Wrap all tests using timeouts with runWithFakedTimers
2026-03-30 19:47:10 -07:00
Connor Peet
12f2ac1e27 agentHost: use memory db for sqlite tests to avoid locking weirdness (#306524) 2026-03-30 16:38:42 -07:00
Connor Peet
eca37987be agentHost: propagate steering for cli sessions (#306488)
* agentHost: propagate steering for cli sessions

Closes #305323

* comments
2026-03-30 22:38:09 +00:00
Peng Lyu
a4855ab045 agentHost: support --host and print resolved server urls (#306219) 2026-03-30 14:23:52 -07:00
Rob Lourens
94c7bf8213 Unify agentHost server-side dispatch: remove IProtocolSideEffectHandler (#306158)
* Unify agentHost server-side dispatch: remove IProtocolSideEffectHandler

Eliminate the IProtocolSideEffectHandler interface and make
ProtocolServerHandler talk to IAgentService directly. This removes
the duplicate adapter layer between the WebSocket protocol server
and the real service implementation.

Changes:
- ProtocolServerHandler now takes IAgentService + SessionStateManager +
  IProtocolServerConfig instead of IProtocolSideEffectHandler
- Deleted ~40-line inline adapter in agentHostMain.ts
- agentHostServerMain.ts now uses AgentService instead of manually
  wiring SessionStateManager + AgentSideEffects
- Removed implements IProtocolSideEffectHandler from AgentSideEffects
- Removed dead methods from AgentSideEffects that were only needed
  by the deleted interface (handleCreateSession, handleDisposeSession,
  handleListSessions, handleGetResourceMetadata, handleAuthenticate,
  getDefaultDirectory)
- Type conversions (URI<->string, IAgentSessionMetadata<->ISessionSummary)
  now happen at the protocol boundary in ProtocolServerHandler
- Fixed dispatchAction double-dispatch: WS path previously dispatched
  to stateManager AND called handleAction (which dispatched again)
- Extension methods (getResourceMetadata, authenticate, etc.) now call
  IAgentService directly instead of untyped fallbacks

(Written by Copilot)

* comments

Co-authored-by: Copilot <copilot@github.com>

* Simplify further

Co-authored-by: Copilot <copilot@github.com>

---------

Co-authored-by: Copilot <copilot@github.com>
2026-03-29 19:07:20 -07:00
Rob Lourens
0dad7e0453 Use URI for workingDirectory across agent host layer (#306117)
* Use URI for workingDirectory across agent host layer

- Change IAgentCreateSessionConfig.workingDirectory and
  IAgentSessionMetadata.workingDirectory from string to URI
- Convert file paths to URI at SDK boundary (CopilotAgent)
- Convert protocol strings to agenthost:// URIs at protocol client boundary
- Convert agenthost:// URIs back to file:// at protocol client on outgoing
- Update resolveWorkingDirectory callback to return URI
- Use extUriBiasedIgnorePathCase.isEqualOrParent for path containment
- Use generateUuid() instead of crypto.randomUUID()
- Add CopilotAgentSession tests and SessionWrapperFactory pattern
- Register all event subscription disposables properly

(Written by Copilot)

* Tweak

* Fix test
2026-03-29 21:56:06 +02:00
Rob Lourens
1ae3819053 test: skip flaky test for empty array input in getFileEdits (#306062) 2026-03-28 21:15:37 -07:00
Rob Lourens
73b0fb2937 Refactor CopilotAgent, break out CopilotAgentSession, add tests (#306046)
* Refactor CopilotAgent, break out CopilotAgentSession, add tests

Co-authored-by: Copilot <copilot@github.com>

* Cleanup a bit

Co-authored-by: Copilot <copilot@github.com>

---------

Co-authored-by: Copilot <copilot@github.com>
2026-03-28 19:41:37 -07:00
Connor Peet
20c06fd05f Merge remote-tracking branch 'origin/main' into connor4312/edit-metadata 2026-03-27 20:02:21 -07:00
Rob Lourens
5be9778feb agentHost: Apply default edit auto-approve patterns on AH side (#305859)
* agentHost: Apply default edit auto-approve patterns on AH side
Fix #305308

Co-authored-by: Copilot <copilot@github.com>

* Add integration test

Co-authored-by: Copilot <copilot@github.com>

* Fixes

---------

Co-authored-by: Copilot <copilot@github.com>
2026-03-27 23:59:18 +00:00
Connor Peet
bd2f91618e fix compile 2026-03-27 16:23:07 -07:00
Connor Peet
fa311ecf8f Merge pull request #305348 from microsoft/connor4312/edit-metadata
agentHost: add session-specific metadata
2026-03-27 11:44:24 -07:00
Connor Peet
3746fd5a92 fix 2026-03-27 09:45:04 -07:00
Connor Peet
676164bf15 fix 2026-03-27 09:36:05 -07:00
Connor Peet
cdd9c01e97 fix 2026-03-27 09:26:30 -07:00
Connor Peet
133627a223 fix tests 2026-03-27 08:59:30 -07:00
Rob Lourens
5d35a554d5 Add multi-client agent host integration tests (#304867)
Add 7 new tests covering multi-client scenarios:
- sessionAdded/sessionRemoved notifications broadcast to all clients
- Cross-client message dispatch (client B sends on client A's session)
- Full tool progress updates delivered to both subscribers
- Action scoping: unsubscribed client gets no actions but still gets notifications
- Late subscriber gets current state via snapshot
- Cross-client permission flow (client B confirms tool started by client A)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-26 19:15:44 -07:00
Connor Peet
da5fb11b3b agentHost: add session-specific metadata
Adds a SQLite DB for session-specific metadata. Stores edits in there.
It can _almost_ restore edits, but I still need to make undoStops be
similarly persisted. That is a project for later this evening.
2026-03-26 15:46:46 -07:00
Connor Peet
29d9808be8 agentHost: ui side for queued messages (#304954)
* agentHost: initial queuing/steering data flows

* agentHost: ui side for queued messages

Steering messages still don't quite work yet, I need to hook up some more stuff in the CLI for that I believe.

* comments

* rm dead code
2026-03-26 16:45:15 +00:00
Connor Peet
ff895d1fcd agentHost: sync fixed tool call ordering
Adopts https://github.com/microsoft/agent-host-protocol/pull/20
2026-03-24 16:44:03 -07:00
Rob Lourens
a2e920987e Fix loading sessions that were created by a previous remote agent host instance (#304344)
* Fix loading sessions that were created by a previous instance of the server

Co-authored-by: Copilot <copilot@github.com>

* Add handleRestoreSession to agentHostMain side effects

Wire up the handleRestoreSession method in the utility process
agent host entry point, delegating to AgentService which forwards
to AgentSideEffects. This was missing after the interface was
updated to require session restore support.

* Address Copilot review: wrap backend errors, use Cancelled for interrupted turns

- Wrap agent.listSessions() and agent.getSessionMessages() calls in
  try/catch so raw backend errors become ProtocolErrors instead of
  leaking stack traces to clients.
- Use TurnState.Cancelled instead of TurnState.Complete for
  interrupted/dangling turns during session restoration.
- Update test assertions to match new interrupted turn state.

(Written by Copilot)

---------

Co-authored-by: Copilot <copilot@github.com>
2026-03-24 04:41:48 +00:00
Connor Peet
161bd3677e Merge remote-tracking branch 'origin/main' into connor4312/agent-edits 2026-03-23 18:26:37 -07:00
Rob Lourens
a2d7169e3b Keep agent host alive while there are active websocket connections (#304271)
* Keep agent host alive while there are active websocket connections
Instead of shutting it down whenever there are no agents running

Co-authored-by: Copilot <copilot@github.com>

* Fix disposable handling

---------

Co-authored-by: Copilot <copilot@github.com>
2026-03-23 17:43:19 -07:00
Connor Peet
d5aa1c409e fix merge 2026-03-23 16:19:45 -07:00
Connor Peet
85e9d41a57 agentHost: ui side of edits 2026-03-23 15:15:03 -07:00
Connor Peet
2bdd783838 agentHost: data passing for edits 2026-03-22 11:28:38 -07:00
Connor Peet
3af163a8c8 comments 2026-03-18 14:54:30 -07:00
Connor Peet
da0cdcf861 Merge remote-tracking branch 'origin/main' into connor4312/ahp-auth 2026-03-18 14:30:16 -07:00
Connor Peet
c5fc3c07b3 tests 2026-03-18 14:29:03 -07:00
Connor Peet
e3547da62c cleanup old setAuthToken 2026-03-18 14:25:42 -07:00
Connor Peet
f3b0544950 agentHost: 9728-style protected resource auth
This commit implement RFC 9728/6750-inspired authentication for the
agent host. This is a working prototype, although before merging this
I'll pull this stuff up to the protocol itself rather than being
extension methods.
2026-03-18 14:15:29 -07:00
Connor Peet
60d6da9614 agentHost: upstream reducer logic from AHP
Goes with https://github.com/microsoft/agent-host-protocol/pull/11
2026-03-18 13:09:11 -07:00
Connor Peet
2cd7a84eef tests and build 2026-03-17 20:34:42 -07:00
Connor Peet
2418b24d9f agentHost: migrate to use protocol types
- Migrates to use AHP types that are synced via `npx tsx scripts/sync-agent-host-protocol.ts`
- One big churn was migrating out of URIs as rich objects in the protocol.
  We can't really shove our own `$mid`-type objects in there. I also explored doing a
  generated translation layer but I had trouble getting one I was happy with.
- This tightens up some type safety in general and fixes some areas where vscode had
  silently/sloppily diverged from the protocol types.
2026-03-17 20:10:45 -07:00
Connor Peet
9fbb42c1e8 fix tests 2026-03-17 11:14:07 -07:00
Connor Peet
f2f31ca7ea connection token support 2026-03-17 10:01:53 -07:00
Rob Lourens
f48e040708 fix build 2026-03-17 09:51:47 -07:00
Connor Peet
5d5d0763fb fix build 2026-03-16 19:05:09 -07:00
Rob Lourens
c5ea6d24f0 Fix tests 2026-03-16 17:07:09 -07:00
Connor Peet
ba585964a2 adopt tool call changes from 07a5206835 2026-03-14 15:43:16 -07:00
Rob Lourens
f24e3be59d Avoid timeouts in tests 2026-03-14 13:26:56 -07:00
Rob Lourens
97ef00da2a Align browseDirectory errors with filesystem semantics (Written by Copilot) 2026-03-14 12:41:47 -07:00
Rob Lourens
ce5e503640 Add directory listing to protocol, and folder picker for remote agent hosts (#301639)
* Add directory listing to protocol, and folder picker for remote agent hosts

* Protocol improvements

* Don't register agenthost URIs as workspace folders

* Update pickers after merge

* Resolve comments
2026-03-14 10:26:39 -07:00
Connor Peet
f8311c303d protocol parity
Goes with 009e4e93c3
2026-03-13 14:51:00 -07:00
Connor Peet
5983e795a0 make active sessions participant in remote-auto-shutdown 2026-03-13 12:43:26 -07:00
Connor Peet
247bd102ef parse error 2026-03-12 23:40:52 -07:00
Rob Lourens
87b808097d Merge remote-tracking branch 'origin/roblou/agent-host' into connor4312/agent-host-server 2026-03-12 21:19:14 -07:00
Rob Lourens
5c16c31f88 Connect to remote agent hosts via setting chat.remoteAgentHosts (#301224)
* Copy vscode's node.pty

* And ripgrep

* And thsi

* Connect to remote agent hosts via setting chat.remoteAgentHosts

* This

* Fix

* Cleanup

* Rearrange, add unit tests
2026-03-12 21:14:15 -07:00
Rob Lourens
594e560bf7 Remove outdated script 2026-03-12 19:39:54 -07:00