mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:10:44 +00:00
feat: add VS Code debug setup
This commit is contained in:
32
.vscode/launch.json
vendored
Normal file
32
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Rebuild and Debug Gateway",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "debug:rebuild",
|
||||
"program": "${workspaceFolder}/openclaw.mjs",
|
||||
"args": ["gateway", "run"],
|
||||
"console": "integratedTerminal",
|
||||
"skipFiles": ["<node_internals>/**", "node_modules/**"],
|
||||
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
|
||||
"sourceMaps": true,
|
||||
"smartStep": true,
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "Debug Gateway",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/openclaw.mjs",
|
||||
"args": ["gateway", "run"],
|
||||
"console": "integratedTerminal",
|
||||
"skipFiles": ["<node_internals>/**", "node_modules/**"],
|
||||
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
|
||||
"sourceMaps": true,
|
||||
"smartStep": true,
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
]
|
||||
}
|
||||
23
.vscode/tasks.json
vendored
Normal file
23
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"options": {
|
||||
"env": {
|
||||
"OUTPUT_SOURCE_MAPS": "1"
|
||||
}
|
||||
},
|
||||
"tasks": [
|
||||
{
|
||||
"label": "debug:rebuild",
|
||||
"type": "shell",
|
||||
"command": "pnpm clean:dist && pnpm build",
|
||||
"group": "none",
|
||||
"problemMatcher": [],
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "shared"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -83,6 +83,7 @@ Docs: https://docs.openclaw.ai
|
||||
- Dependencies: refresh runtime and provider packages including Pi 0.73.0, ACPX adapters, OpenAI, Anthropic, Slack, and TypeScript native preview, while keeping the Bedrock runtime installer override pinned below the Windows ARM Node 24 npm resolver failure.
|
||||
- Contributor PRs: require external pull requests to include after-fix real behavior proof from a real OpenClaw setup, with terminal screenshots, console output, redacted runtime logs, linked artifacts, and copied live output treated as valid evidence while unit tests, mocks, lint, typechecks, snapshots, and CI remain supplemental only.
|
||||
- Plugins/catalog: add an `@tencent-weixin/openclaw-weixin` external entry pinned to `2.4.1` so onboarding and `openclaw channels add` can install the Tencent Weixin (personal WeChat) channel by default. (#77269) Thanks @pumpkinxing1.
|
||||
- Developer tooling: add checked-in VS Code Gateway debugging configs and an opt-in `OUTPUT_SOURCE_MAPS=1` source-map build path for breakpoints in TypeScript source. (#45710) Thanks @SwissArmyBud.
|
||||
|
||||
### Fixes
|
||||
|
||||
|
||||
@@ -306,6 +306,38 @@ Default file:
|
||||
- Keep logs local and delete them after debugging.
|
||||
- If you share logs, scrub secrets and PII first.
|
||||
|
||||
## Debugging in VSCode
|
||||
|
||||
Source maps are required to enable debugging in VSCode-based IDEs because many of the generated files end up with hashed names as part of the build process. The included `launch.json` configurations target the Gateway service, but can be adapted quickly for other purposes:
|
||||
|
||||
1. **Rebuild and Debug Gateway** - Debugs the Gateway service after creating a new build
|
||||
2. **Debug Gateway** - Debugs the Gateway service of a pre-existing build
|
||||
|
||||
### Setup
|
||||
|
||||
The default **Rebuild and Debug Gateway** configuration is batteries-included, it will automatically delete the `/dist` folder and rebuild the project with debugging enabled:
|
||||
|
||||
1. Open the **Run and Debug** panel from the Activity Bar or press `Ctrl`+`Shift`+`D`
|
||||
2. In the IDE, ensure **Rebuild and Debug Gateway** is selected in the configuration dropdown and then press the **Start Debugging** button
|
||||
|
||||
Alternatively - if you prefer to manage the build and debug processes manually:
|
||||
|
||||
1. Open a terminal and enable source maps:
|
||||
- **Linux/macOS**: `export OUTPUT_SOURCE_MAPS=1`
|
||||
- **Windows (PowerShell)**: `$env:OUTPUT_SOURCE_MAPS="1"`
|
||||
- **Windows (CMD)**: `set OUTPUT_SOURCE_MAPS=1`
|
||||
2. In the same terminal, rebuild the project: `pnpm clean:dist && pnpm build`
|
||||
3. In the IDE, select the **Debug Gateway** option in the **Run and Debug** configuration dropdown and then press the **Start Debugging** button
|
||||
|
||||
You can now set breakpoints in your TypeScript source files (`src/` directory) and the debugger will correctly map breakpoints to the compiled JavaScript via source maps. You'll be able to inspect variables, step through code, and examine call stacks as expected.
|
||||
|
||||
### Notes
|
||||
|
||||
- If using the **"Rebuild and Debug Gateway"** option - each time the debugger is launched it will completely delete the `/dist` folder and run a full `pnpm build` with source maps enabled before starting the Gateway
|
||||
- If using the **"Debug Gateway"** option - debug sessions can be started and stopped at any time without affecting the `/dist` folder, but you must use a separate terminal process to both enable debugging and manage the build cycle
|
||||
- Modify the `launch.json` settings for `args` to debug other sections of the project
|
||||
- If you need to use the built OpenClaw CLI for other tasks (i.e. `dashboard --no-open` if your debug session spawns a new auth token), you can execute it in another terminal as `node ./openclaw.mjs` or create a shell alias like `alias openclaw-build="node $(pwd)/openclaw.mjs"`
|
||||
|
||||
## Related
|
||||
|
||||
- [Troubleshooting](/help/troubleshooting)
|
||||
|
||||
@@ -1330,6 +1330,7 @@
|
||||
"ci:full-release": "node scripts/full-release-validation-at-sha.mjs",
|
||||
"ci:timings": "node scripts/ci-run-timings.mjs --latest-main",
|
||||
"ci:timings:recent": "node scripts/ci-run-timings.mjs --recent 10",
|
||||
"clean:dist": "node -e \"require('fs').rmSync('dist', {recursive: true, force: true})\"",
|
||||
"codex-app-server:protocol:check": "node --import tsx scripts/check-codex-app-server-protocol.ts",
|
||||
"codex-app-server:protocol:sync": "node --import tsx scripts/sync-codex-app-server-protocol.ts",
|
||||
"config:channels:check": "node --import tsx scripts/generate-bundled-channel-config-metadata.ts --check",
|
||||
|
||||
@@ -32,6 +32,7 @@ type ExternalOptionFunction = (
|
||||
const env = {
|
||||
NODE_ENV: "production",
|
||||
};
|
||||
const OUTPUT_SOURCE_MAPS = process.env.OUTPUT_SOURCE_MAPS === "1";
|
||||
|
||||
const SUPPRESSED_EVAL_WARNING_PATHS = [
|
||||
"@protobufjs/inquire/index.js",
|
||||
@@ -122,6 +123,7 @@ function nodeBuildConfig(config: UserConfig): UserConfig {
|
||||
env,
|
||||
fixedExtension: false,
|
||||
platform: "node",
|
||||
sourcemap: OUTPUT_SOURCE_MAPS,
|
||||
inputOptions: buildInputOptions,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user