Commit Graph

14 Commits

Author SHA1 Message Date
Connor Peet
3e15c2da57 agentHost: hello world from server
Exposes --agent-host-port/--agent-host-path to specify an additional
port for them to listen on. This runs as a separate process mirroring
the architecture from main.

Does a 'hello world', I need to keep testing it some more. I honestly
don't know a lot about the import changes Opus is doing here. Without
them, there is an error:

```
import { CopilotClient } from "@github/copilot-sdk";
         ^^^^^^^^^^^^^
SyntaxError: The requested module '@github/copilot-sdk' does not provide an export named 'CopilotClient'
```

This was Copilot's explanation for why they're needed here but not in Electron:

>The agent host process itself didn't change — the issue is the **module resolution environment** differs between Electron and the server.
>
>**Electron (desktop):** `ElectronAgentHostStarter` spawns a utility process that inherits the main process's module resolution. It resolves packages from the **root** node_modules, where `@github/copilot-sdk`, `ws`, etc. are all installed. Everything just works.
>
>**Server:** `NodeAgentHostStarter` spawns a child via `bootstrap-fork.js`, which registers a custom ESM resolver hook (bootstrap-import.ts) that **redirects** all module lookups to node_modules instead of root node_modules. That's the `[bootstrap-import] Initialized node_modules redirector for: ...\remote\node_modules` log line. The remote folder has its own package.json with a curated set of server-specific dependencies.
>
>The problems were:
>1. **Missing deps** — `@github/copilot-sdk`, `@github/copilot`, and `ws` weren't in package.json because the agent host had never run in the server context before
>2. **Resolver bugs** — bootstrap-import.ts was written when all remote deps were CJS. It hardcoded `format: 'commonjs'`, didn't handle `exports` maps, didn't handle `.mjs` files, and didn't resolve subpath imports like `vscode-jsonrpc/node`. These are pre-existing limitations that never mattered until now because no server component previously depended on ESM-only npm packages.
>
>So in short: the agent host code is identical — it's the server's module resolution plumbing that needed updating to support the ESM packages the agent host depends on.

cc @bpasero as the expert in this area
2026-03-12 09:00:40 -07:00
Benjamin Pasero
7e8c7bef61 debt - reduce explicit any usage (#269814) 2025-10-06 15:19:56 +00:00
Benjamin Pasero
70a7ef1bc9 debt - start to reduce explicit any in my code (#269479) 2025-10-03 15:23:14 +00:00
Matt Bierner
360c9fd134 Add lint rule for as any and bulk ignore all existing breaks
For #269213

This adds a new eslint rule for `as any` and `<any>({... })`. We'd like to remove almost all of these, however right now the first goal is to prevent them in new code. That's why with this first PR I simply add `eslint-disable` comments for all breaks

Trying to get this change in soon after branching off for release to hopefully minimize disruption during debt week work
2025-10-02 23:38:33 -07:00
Benjamin Pasero
04f0bcbd15 debt - some node.js module import 💄 (#264158) 2025-09-01 01:09:43 +09:00
Benjamin Pasero
2b6887705f Adopt import.meta.dirname and import.meta.filename (fix #259658) (#259845) 2025-08-05 10:11:44 -07:00
Connor Peet
cccd0a35c6 eng: cherry-pick 1.97.1 fixes (#240409) 2025-02-11 19:47:56 +01:00
Benjamin Pasero
e7abf7becb esm - inline main entry points (#230135) 2024-09-30 20:22:47 +02:00
Benjamin Pasero
a5979c9b3c esm - more cleanup and polish (#230109) 2024-09-30 12:11:56 +02:00
Benjamin Pasero
84c18c543e esm - more cleanup of rules and files (#230083) 2024-09-30 11:20:59 +02:00
Benjamin Pasero
f9910cd22e esm - try to fix build (#229972) 2024-09-27 17:04:43 +02:00
Benjamin Pasero
96cf88a8fe esm - convert window related helpers to TS (#229961) 2024-09-27 15:39:15 +02:00
Benjamin Pasero
293e725467 esm - some 💄 2024-09-27 11:36:53 +02:00
Benjamin Pasero
f6bfbf0d93 esm - convert bootstrap files to TS (part 3) 2024-09-27 08:06:10 +02:00