Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 29 additions & 31 deletions ts/packages/copilot-plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# TypeAgent Plugin for GitHub Copilot CLI

This plugin integrates TypeAgent with the modified `copilot-dev` CLI, enabling action requests (calendar, email, music, browser automation, etc.) to be routed to TypeAgent before the Copilot LLM.
This plugin integrates TypeAgent with GitHub Copilot CLI, enabling action requests (calendar, email, music, browser automation, etc.) to be routed to TypeAgent before the Copilot LLM.

## How It Works

```
User Input → copilot-dev
User Input → copilot
userPromptSubmitted hook (hook-router.js)
Expand All @@ -17,29 +17,29 @@ Action request?
└── mcp mode → Inject directive, LLM calls typeagent-processCommand tool
```

The `copilot-dev` CLI has been modified (in `D:\repos\copilot-agent-runtime`) to support `handled`, `responseContent`, and `handledBy` fields in hook output — allowing the hook to skip the agentic loop entirely when TypeAgent handles a request.
The hook output fields `handled`, `responseContent`, and `handledBy` are supported in current Copilot CLI behavior, allowing the hook to skip the agentic loop entirely when TypeAgent handles a request. For local runtime debugging against the runtime repo, use `pnpm copilot:dev`.

---

## Prerequisites

### 1. Node.js 24+
### 1. Node.js and pnpm

The modified `copilot-dev` requires Node.js 24+ for `node:sqlite`.
For this workspace, use Node.js 22+ and pnpm 10+ (from `ts/package.json` engines).

**On Windows** — install via [nvm-windows](https://github.com/coreybutler/nvm-windows) or the [Node.js installer](https://nodejs.org/):

```powershell
nvm install 24
nvm use 24
node --version # should show v24.x.x
nvm install 22
nvm use 22
node --version # should show v22.x.x or later
```

**In WSL** — via nvm:

```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
nvm install 24 && nvm use 24
nvm install 22 && nvm use 22
```

### 2. TypeAgent Server Running
Expand All @@ -51,7 +51,7 @@ Start the TypeAgent agent-server from `D:\repos\TypeAgent\ts`:
```bash
# In WSL or Windows
cd D:\repos\TypeAgent\ts
pnpm run start:server
pnpm run start:agent-server
```

Or set `TYPEAGENT_PORT` and `TYPEAGENT_HOST` to override the connection.
Expand All @@ -63,23 +63,23 @@ Or set `TYPEAGENT_PORT` and `TYPEAGENT_HOST` to override the connection.
### Build the Plugin (WSL)

```bash
cd /mnt/d/repos/SecretAgents/ts
cd /mnt/d/repos/TypeAgent/ts
pnpm install # installs workspace deps, syncs TypeAgent credentials
pnpm run build # builds all packages including typeagent-plugin
pnpm run build # builds all packages including copilot-plugin
```

Or build just the plugin:

```bash
cd /mnt/d/repos/SecretAgents/ts/packages/typeagent-plugin
cd /mnt/d/repos/TypeAgent/ts/packages/copilot-plugin
pnpm run build
```

**Output:** `dist/hooks/hook-router.js` and other hook entry points.

### Build copilot-dev (WSL, for Windows testing)
### Optional: Build Dev Runtime (copilot-agent-runtime)

The modified `copilot-dev` source is at `D:\repos\copilot-agent-runtime`.
This is only needed if you want to run against a local runtime checkout with `pnpm copilot:dev`.

**Build in WSL** (builds for all platforms — the Windows binary runs on Windows):

Expand All @@ -90,7 +90,7 @@ npm run build:mcp-client
npm run build
```

**Install globally on Windows** — open PowerShell/CMD in `D:\repos\copilot-agent-runtime`:
**Optional install globally on Windows** — open PowerShell/CMD in `D:\repos\copilot-agent-runtime`:

```powershell
npm install -g .
Expand All @@ -101,29 +101,29 @@ copilot-dev --version

## Testing on Windows

### Step 1: Verify copilot-dev is Installed
### Step 1: Verify Copilot CLI is Installed

```powershell
copilot-dev --version
copilot --version
```

Expected: `GitHub Copilot CLI 0.0.1.`
Expected: a valid GitHub Copilot CLI version.

### Step 2: Start TypeAgent Server

In a separate terminal (Windows or WSL):

```bash
cd D:\repos\TypeAgent\ts
pnpm run start:server
pnpm run start:agent-server
```

Wait until you see the server is ready on port 8999.

### Step 3: Launch copilot-dev with the Plugin
### Step 3: Launch Copilot with the Plugin

```powershell
copilot-dev --plugin-dir D:\repos\SecretAgents\ts\packages\typeagent-plugin
copilot --plugin-dir D:\repos\TypeAgent\ts\packages\copilot-plugin
```

The `--plugin-dir` flag loads the plugin from a local directory. On first launch it reads `plugin.json`, registers hooks from `hooks.json`, and exposes the MCP server from `.mcp.json`.
Expand Down Expand Up @@ -271,7 +271,7 @@ Or set permanently via environment variable before launching:

```powershell
$env:TYPEAGENT_MODE = "mcp"
copilot-dev --plugin-dir D:\repos\SecretAgents\ts\packages\typeagent-plugin
copilot --plugin-dir D:\repos\TypeAgent\ts\packages\copilot-plugin
```

---
Expand Down Expand Up @@ -339,24 +339,21 @@ Hooks write diagnostics to stderr (not visible in normal CLI output). To see the

```powershell
# Windows: run hook directly for testing
echo '{"sessionId":"test","timestamp":1234,"cwd":"C:\\temp","prompt":"list my playlists"}' | node D:\repos\SecretAgents\ts\packages\typeagent-plugin\dist\hooks\hook-router.js
echo '{"sessionId":"test","timestamp":1234,"cwd":"C:\\temp","prompt":"list my playlists"}' | node D:\repos\TypeAgent\ts\packages\copilot-plugin\dist\hooks\hook-router.js
```

### Test Hooks Directly (WSL)

The `package.json` includes test scripts that simulate hook invocation:

```bash
cd /mnt/d/repos/SecretAgents/ts/packages/typeagent-plugin
cd /mnt/d/repos/TypeAgent/ts/packages/copilot-plugin

# Test direct mode routing (TypeAgent server must be running)
pnpm run test:direct

# Test MCP redirect mode (no server needed — just checks prompt injection)
pnpm run test:mcp-redirect

# Test question fall-through
pnpm run test:question
```

### Check TypeAgent Connection
Expand All @@ -372,17 +369,18 @@ Expected output shows server URL and current mode. If TypeAgent is not running,

| Issue | Cause | Fix |
| ------------------------------ | ----------------------------- | -------------------------------------------------------------- |
| `copilot-dev` not found | Not installed globally | Run `npm install -g .` from `D:\repos\copilot-agent-runtime` |
| `copilot` not found | Copilot CLI not installed | Install GitHub Copilot CLI and verify with `copilot --version` |
| Action not routed to TypeAgent | Prompt detected as a question | Rephrase: use imperative ("schedule...", "send...", "play...") |
| TypeAgent connection refused | Server not running | Start TypeAgent server (`pnpm run start:server`) |
| TypeAgent connection refused | Server not running | Start TypeAgent server (`pnpm run start:agent-server`) |
| Hook timeout | TypeAgent slow to respond | Increase `timeout` in `hooks.json` or use MCP mode |
| SQLite experimental warning | Node 24 feature | Normal — can be suppressed with `--no-experimental-warnings` |

---

## Architecture Reference

The key modification to `copilot-dev` is in:
During development, the runtime implementation lived in `D:\repos\copilot-agent-runtime`.
The key runtime hook behavior change was in:

- **`src/core/hooks.ts`** — Added `handled`, `responseContent`, `handledBy` to `UserPromptSubmittedHookOutput`
- **`src/core/session.ts`** (~line 7473) — Added handler that checks hook output and emits an assistant message directly, bypassing `runAgenticLoop()`
Expand Down
119 changes: 80 additions & 39 deletions ts/tools/installers/wix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,71 @@ The pipeline handles this automatically via:

## Local Build & Test

### 1. Pull the Certificate from Key Vault
Use the local source build to validate WiX changes before pushing to CI. This is the recommended path for catching `LGHT`/`CANDLE` errors early — it runs the same WiX heat → candle → light pipeline that CI does, but stages the artifacts from your local repo build instead of downloading from the ADO feed. No Azure CLI login required.

### Option A: Build from local repo (recommended for WiX development)

#### 1. Build the workspace

```powershell
cd D:\repos\TypeAgent\ts
pnpm run build
```

#### 2. Stage agent-server

```powershell
# From D:\repos\TypeAgent\ts
node tools/scripts/deployAgentServer.mjs `
--out "$env:TEMP\typeagent-msi-stage\agent-server" `
--platform win32 --arch x64 `
--profile service
```

#### 3. Stage copilot-plugin

```powershell
cd ts/tools/scripts
$plugin = "packages/copilot-plugin"
$out = "$env:TEMP\typeagent-msi-stage\copilot-plugin"
New-Item -ItemType Directory -Force $out | Out-Null
Copy-Item -Recurse "$plugin/dist" "$out/dist"
Copy-Item "$plugin/hooks.json" "$out/hooks.json"
Copy-Item "$plugin/.mcp.json" "$out/.mcp.json"
Copy-Item "$plugin/plugin.json" "$out/plugin.json"
Copy-Item -Recurse "$plugin/agents" "$out/agents"
Copy-Item -Recurse "$plugin/skills" "$out/skills"
```

#### 4. Run the WiX build with local staged artifacts

```powershell
node tools/scripts/build-msi.mjs `
--skip-download `
--agent-dir "$env:TEMP\typeagent-msi-stage\agent-server" `
--plugin-dir "$env:TEMP\typeagent-msi-stage\copilot-plugin" `
--version 0.0.1-local `
--plugin-version 0.0.1-local `
--output "$env:TEMP\typeagent-msi-stage\out"
```

**Output:**

```
$env:TEMP\typeagent-msi-stage\out\TypeAgent-0.0.1-local-win32-x64.msi
```

This is the same code path CI uses. If WiX fails here it will fail in CI.

---

### Option B: Build from ADO feed artifact (requires az login)

Pull pre-published artifacts from the `typeagent` feed instead of staging locally.

#### 1. Pull the Certificate from Key Vault

```powershell
cd D:\repos\TypeAgent\ts\tools\scripts
node getCert.mjs pull
```

Expand All @@ -87,70 +148,50 @@ Status check:
node getCert.mjs status
```

### 2. Build the MSI
#### 2. Build the MSI

```powershell
cd ts/tools/scripts

# Build for win32-x64 (default)
node build-msi.mjs --rid win32-x64 --version 0.0.1-test --output ./msi-out
cd D:\repos\TypeAgent\ts\tools\scripts

# Or specify latest published version
node build-msi.mjs --rid win32-x64 --version latest --output ./msi-out
# Build for win32-x64
node build-msi.mjs --rid win32-x64 --version 0.0.1-<buildId> --output ./msi-out
```

**What it does:**

1. Downloads `agent-server.win32-x64` from the `typeagent` feed
2. Extracts to `./msi-out/artifact`
3. Compiles WiX definition (`.wxs` → `.wixobj`)
4. Links to create `TypeAgent-AgentServer-<version>-win32-x64.msi`
4. Links to create `TypeAgent-<version>-win32-x64.msi`

**Output:**

```
msi-out/
├── artifact/ # Downloaded and extracted agent-server
├── TypeAgent-AgentServer.wixobj # Compiled WiX
└── TypeAgent-AgentServer-0.0.1-test-win32-x64.msi
└── TypeAgent-0.0.1-<buildId>-win32-x64.msi
```

### 3. Sign the MSI
#### 3. Sign the MSI (optional for local testing)

```powershell
cd ts/tools/scripts

# Sign with the dev certificate
node sign-msi.mjs ../installers/wix/msi-out/TypeAgent-AgentServer-0.0.1-test-win32-x64.msi
```

**What it does:**

1. Invokes `getCert.mjs pull` (if not already done)
2. Signs the MSI with `signtool.exe` using the dev cert
3. Optionally timestamps the signature (via DigiCert timestamp server)
4. Verifies the signature

**Output:**

```
✅ MSI signed successfully
✔️ Signature verified successfully
cd D:\repos\TypeAgent\ts\tools\scripts
node sign-msi.mjs "$env:TEMP\typeagent-msi-stage\out\TypeAgent-0.0.1-local-win32-x64.msi"
```

### 4. Test Installation
Signing requires Key Vault access. For local WiX validation you can skip signing and test install directly.

On a clean Windows machine (or VM):
#### 4. Test installation

```powershell
# Interactive install (shows progress dialog)
msiexec /i TypeAgent-AgentServer-0.0.1-test-win32-x64.msi
# Interactive install
msiexec /i "$env:TEMP\typeagent-msi-stage\out\TypeAgent-0.0.1-local-win32-x64.msi"

# Unattended install (for scripted/Intune deployment)
msiexec /i TypeAgent-AgentServer-0.0.1-test-win32-x64.msi /quiet /norestart
# Unattended
msiexec /i "$env:TEMP\typeagent-msi-stage\out\TypeAgent-0.0.1-local-win32-x64.msi" /quiet /norestart

# Verify installation
Get-Item 'C:\Program Files\TypeAgent\agent-server\' -ErrorAction SilentlyContinue
# Verify
Get-Item "$env:LOCALAPPDATA\TypeAgent\agent-server" -ErrorAction SilentlyContinue
```

## Pipeline Usage
Expand Down
3 changes: 3 additions & 0 deletions ts/tools/scripts/build-msi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ runCommand(lightExe, [
`WixUIExtension`,
`-ext`,
`WixUtilExtension`,
// Per-user install under LocalAppData intentionally triggers ICE38 on
// file-keypath components harvested by heat; suppress that specific ICE.
`-sice:ICE38`,
`-cultures:en-us`,
`-o`,
msiOutputPath,
Expand Down
Loading