Skip to content

Commit c839f0a

Browse files
Add VS Code launch config for debugging sdk/runtime
1 parent 5b58582 commit c839f0a

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug Node.js SDK (chat sample)",
6+
"type": "node",
7+
"request": "launch",
8+
"runtimeArgs": ["--enable-source-maps", "--import", "tsx"],
9+
"program": "samples/chat.ts",
10+
"cwd": "${workspaceFolder}/nodejs",
11+
"env": {
12+
"COPILOT_CLI_PATH": "${workspaceFolder}/../copilot-agent-runtime/dist-cli/index.js"
13+
},
14+
"console": "integratedTerminal",
15+
"autoAttachChildProcesses": true,
16+
"sourceMaps": true,
17+
"resolveSourceMapLocations": [
18+
"${workspaceFolder}/**",
19+
"${workspaceFolder}/../copilot-agent-runtime/**"
20+
]
21+
}
22+
]
23+
}

nodejs/samples/chat.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import * as readline from "node:readline";
2-
import { CopilotClient, approveAll, type SessionEvent } from "@github/copilot-sdk";
2+
3+
// Normally these should be imported from @github/copilot-sdk, but within this repo
4+
// we import from source to enable debugging into the SDK code.
5+
import { CopilotClient, approveAll, type SessionEvent } from "../src/index.js";
36

47
async function main() {
58
const client = new CopilotClient();

nodejs/src/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,9 @@ export class CopilotClient {
309309
this.onGetTraceContext = options.onGetTraceContext;
310310

311311
this.options = {
312-
cliPath: options.cliUrl ? undefined : options.cliPath || getBundledCliPath(),
312+
cliPath: options.cliUrl
313+
? undefined
314+
: options.cliPath || process.env.COPILOT_CLI_PATH || getBundledCliPath(),
313315
cliArgs: options.cliArgs ?? [],
314316
cwd: options.cwd ?? process.cwd(),
315317
port: options.port || 0,

0 commit comments

Comments
 (0)