mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-19 16:14:45 +00:00
* refactor: remove stale file-backed shims * fix: harden sqlite state ci boundaries * refactor: store matrix idb snapshots in sqlite * fix: satisfy rebased CI guardrails * refactor: store current conversation bindings in sqlite table * refactor: store tui last sessions in sqlite table * refactor: reset sqlite schema history * refactor: drop unshipped sqlite table migration * refactor: remove plugin index file rollback * refactor: drop unshipped sqlite sidecar migrations * refactor: remove runtime commitments kv migration * refactor: preserve kysely sync result types * refactor: drop unshipped sqlite schema migration table * test: keep session usage coverage sqlite-backed * refactor: keep sqlite migration doctor-only * refactor: isolate device legacy imports * refactor: isolate push voicewake legacy imports * refactor: isolate remaining runtime legacy imports * refactor: tighten sqlite migration guardrails * test: cover sqlite persisted enum parsing * refactor: isolate legacy update and tui imports * refactor: tighten sqlite state ownership * refactor: move legacy imports behind doctor * refactor: remove legacy session row lookup * refactor: canonicalize memory transcript locators * refactor: drop transcript path scope fallbacks * refactor: drop runtime legacy session delivery pruning * refactor: store tts prefs only in sqlite * refactor: remove cron store path runtime * refactor: use cron sqlite store keys * refactor: rename telegram message cache scope * refactor: read memory dreaming status from sqlite * refactor: rename cron status store key * refactor: stop remembering transcript file paths * test: use sqlite locators in agent fixtures * refactor: remove file-shaped commitments and cron store surfaces * refactor: keep compaction transcript handles out of session rows * refactor: derive transcript handles from session identity * refactor: derive runtime transcript handles * refactor: remove gateway session locator reads * refactor: remove transcript locator from session rows * refactor: store raw stream diagnostics in sqlite * refactor: remove file-shaped transcript rotation * refactor: hide legacy trajectory paths from runtime * refactor: remove runtime transcript file bridges * refactor: repair database-first rebase fallout * refactor: align tests with database-first state * refactor: remove transcript file handoffs * refactor: sync post-compaction memory by transcript scope * refactor: run codex app-server sessions by id * refactor: bind codex runtime state by session id * refactor: pass memory transcripts by sqlite scope * refactor: remove transcript locator cleanup leftovers * test: remove stale transcript file fixtures * refactor: remove transcript locator test helper * test: make cron sqlite keys explicit * test: remove cron runtime store paths * test: remove stale session file fixtures * test: use sqlite cron keys in diagnostics * refactor: remove runtime delivery queue backfill * test: drop fake export session file mocks * refactor: rename acp session read failure flag * refactor: rename acp row session key * refactor: remove session store test seams * refactor: move legacy session parser tests to doctor * refactor: reindex managed memory in place * refactor: drop stale session store wording * refactor: rename session row helpers * refactor: rename sqlite session entry modules * refactor: remove transcript locator leftovers * refactor: trim file-era audit wording * refactor: clean managed media through sqlite * fix: prefer explicit agent for exports * fix: use prepared agent for session resets * fix: canonicalize legacy codex binding import * test: rename state cleanup helper * docs: align backup docs with sqlite state * refactor: drop legacy Pi usage auth fallback * refactor: move legacy auth profile imports to doctor * refactor: keep Pi model discovery auth in memory * refactor: remove MSTeams legacy learning key fallback * refactor: store model catalog config in sqlite * refactor: use sqlite model catalog at runtime * refactor: remove model json compatibility aliases * refactor: store auth profiles in sqlite * refactor: seed copied auth profiles in sqlite * refactor: make auth profile runtime sqlite-addressed * refactor: migrate hermes secrets into sqlite auth store * refactor: move plugin install config migration to doctor * refactor: rename plugin index audit checks * test: drop auth file assumptions * test: remove legacy transcript file assertions * refactor: drop legacy cli session aliases * refactor: store skill uploads in sqlite * refactor: keep subagent attachments in sqlite vfs * refactor: drop subagent attachment cleanup state * refactor: move legacy session aliases to doctor * refactor: require node 24 for sqlite state runtime * refactor: move provider caches into sqlite state * fix: harden virtual agent filesystem * refactor: enforce database-first runtime state * refactor: rename compaction transcript rotation setting * test: clean sqlite refactor test types * refactor: consolidate sqlite runtime state * refactor: model session conversations in sqlite * refactor: stop deriving cron delivery from session keys * refactor: stop classifying sessions from key shape * refactor: hydrate announce targets from typed delivery * refactor: route heartbeat delivery from typed sqlite context * refactor: tighten typed sqlite session routing * refactor: remove session origin routing shadow * refactor: drop session origin shadow fixtures * perf: query sqlite vfs paths by prefix * refactor: use typed conversation metadata for sessions * refactor: prefer typed session routing metadata * refactor: require typed session routing metadata * refactor: resolve group tool policy from typed sessions * refactor: delete dead session thread info bridge * Show Codex subscription reset times in channel errors (#80456) * feat(plugin-sdk): consolidate session workflow APIs * fix(agents): allow read-only agent mount reads * [codex] refresh plugin regression fixtures * fix(agents): restore compaction gateway logs * test: tighten gateway startup assertions * Redact persisted secret-shaped payloads [AI] (#79006) * test: tighten device pair notify assertions * test: tighten hermes secret assertions * test: assert matrix client error shapes * test: assert config compat warnings * fix(heartbeat): remap cron-run exec events to session keys (#80214) * fix(codex): route btw through native side threads * fix(auth): accept friendly OpenAI order for Codex profiles * fix(codex): rotate auth profiles inside harness * fix: keep browser status page probe within timeout * test: assert agents add outputs * test: pin cron read status * fix(agents): avoid Pi resource discovery stalls Co-authored-by: dataCenter430 <titan032000@gmail.com> * fix: retire timed-out codex app-server clients * test: tighten qa lab runtime assertions * test: check security fix outputs * test: verify extension runtime messages * feat(wake): expose typed sessionKey on wake protocol + system event CLI * fix(gateway): await session_end during shutdown drain and track channel + compaction lifecycle paths (#57790) * test: guard talk consult call helper * fix(codex): scale context engine projection (#80761) * fix(codex): scale context engine projection * fix: document Codex context projection scaling * fix: document Codex context projection scaling * fix: document Codex context projection scaling * fix: document Codex context projection scaling * chore: align Codex projection changelog * chore: realign Codex projection changelog * fix: isolate Codex projection patch --------- Co-authored-by: Eva (agent) <eva+agent-78055@100yen.org> Co-authored-by: Josh Lehman <josh@martian.engineering> * refactor: move agent runtime state toward piless * refactor: remove cron session reaper * refactor: move session management to sqlite * refactor: finish database-first state migration * chore: refresh generated sqlite db types * refactor: remove stale file-backed shims * test: harden kysely type coverage # Conflicts: # .agents/skills/kysely-database-access/SKILL.md # src/infra/kysely-sync.types.test.ts # src/proxy-capture/store.sqlite.test.ts # src/state/openclaw-agent-db.test.ts # src/state/openclaw-state-db.test.ts * refactor: remove cron store path runtime * refactor: keep compaction transcript handles out of session rows * refactor: derive embedded transcripts from sqlite identity * refactor: remove embedded transcript locator handoff * refactor: remove runtime transcript file bridges * refactor: remove transcript file handoffs * refactor: remove MSTeams legacy learning key fallback * refactor: store model catalog config in sqlite * refactor: use sqlite model catalog at runtime # Conflicts: # docs/cli/secrets.md # docs/gateway/authentication.md # docs/gateway/secrets.md * fix: keep oauth sibling sync sqlite-local # Conflicts: # src/commands/onboard-auth.test.ts * refactor: remove task session store maintenance # Conflicts: # src/commands/tasks.ts * refactor: keep diagnostics in state sqlite * refactor: enforce database-first runtime state * refactor: consolidate sqlite runtime state * Show Codex subscription reset times in channel errors (#80456) * fix(codex): refresh subscription limit resets * fix(codex): format reset times for channels * Update CHANGELOG with latest changes and fixes Updated CHANGELOG with recent fixes and improvements. * fix(codex): keep command load failures on codex surface * fix(codex): format account rate limits as rows * fix(codex): summarize account limits as usage status * fix(codex): simplify account limit status * test: tighten subagent announce queue assertion * test: tighten session delete lifecycle assertions * test: tighten cron ops assertions * fix: track cron execution milestones * test: tighten hermes secret assertions * test: assert matrix sync store payloads * test: assert config compat warnings * fix(codex): align btw side thread semantics * fix(codex): honor codex fallback blocking * fix(agents): avoid Pi resource discovery stalls * test: tighten codex event assertions * test: tighten cron assertions * Fix Codex app-server OAuth harness auth * refactor: move agent runtime state toward piless * refactor: move device and push state to sqlite * refactor: move runtime json state imports to doctor * refactor: finish database-first state migration * chore: refresh generated sqlite db types * refactor: clarify cron sqlite store keys * refactor: remove stale file-backed shims * refactor: bind codex runtime state by session id * test: expect sqlite trajectory branch export * refactor: rename session row helpers * fix: keep legacy device identity import in doctor * refactor: enforce database-first runtime state * refactor: consolidate sqlite runtime state * build: align pi contract wrappers * chore: repair database-first rebase * refactor: remove session file test contracts * test: update gateway session expectations * refactor: stop routing from session compatibility shadows * refactor: stop persisting session route shadows * refactor: use typed delivery context in clients * refactor: stop echoing session route shadows * refactor: repair embedded runner rebase imports # Conflicts: # src/agents/pi-embedded-runner/run/attempt.tool-call-argument-repair.ts * refactor: align pi contract imports * refactor: satisfy kysely sync helper guard * refactor: remove file transcript bridge remnants * refactor: remove session locator compatibility * refactor: remove session file test contracts * refactor: keep rebase database-first clean * refactor: remove session file assumptions from e2e * docs: clarify database-first goal state * test: remove legacy store markers from sqlite runtime tests * refactor: remove legacy store assumptions from runtime seams * refactor: align sqlite runtime helper seams * test: update memory recall sqlite audit mock * refactor: align database-first runtime type seams * test: clarify doctor cron legacy store names * fix: preserve sqlite session route projections * test: fix copilot token cache test syntax * docs: update database-first proof status * test: align database-first test fixtures * docs: update database-first proof status * refactor: clean extension database-first drift * test: align agent session route proof * test: clarify doctor legacy path fixtures * chore: clean database-first changed checks * chore: repair database-first rebase markers * build: allow baileys git subdependency * chore: repair exp-vfs rebase drift * chore: finish exp-vfs rebase cleanup * chore: satisfy rebase lint drift * chore: fix qqbot rebase type seam * chore: fix rebase drift leftovers * fix: keep auth profile oauth secrets out of sqlite * fix: repair rebase drift tests * test: stabilize pairing request ordering * test: use source manifests in plugin contract checks * fix: restore gateway session metadata after rebase * fix: repair database-first rebase drift * fix: clean up database-first rebase fallout * test: stabilize line quick reply receipt time * fix: repair extension rebase drift * test: keep transcript redaction tests sqlite-backed * fix: carry injected transcript redaction through sqlite * chore: clean database branch rebase residue * fix: repair database branch CI drift * fix: repair database branch CI guard drift * fix: stabilize oauth tls preflight test * test: align database branch fast guards * test: repair build artifact boundary guards * chore: clean changelog rebase markers --------- Co-authored-by: pashpashpash <nik@vault77.ai> Co-authored-by: Eva <eva@100yen.org> Co-authored-by: stainlu <stainlu@newtype-ai.org> Co-authored-by: Jason Zhou <jason.zhou.design@gmail.com> Co-authored-by: Ruben Cuevas <hi@rubencu.com> Co-authored-by: Pavan Kumar Gondhi <pavangondhi@gmail.com> Co-authored-by: Shakker <shakkerdroid@gmail.com> Co-authored-by: Kaspre <36520309+Kaspre@users.noreply.github.com> Co-authored-by: dataCenter430 <titan032000@gmail.com> Co-authored-by: Kaspre <kaspre@gmail.com> Co-authored-by: pandadev66 <nova.full.stack@outlook.com> Co-authored-by: Eva <admin@100yen.org> Co-authored-by: Eva (agent) <eva+agent-78055@100yen.org> Co-authored-by: Josh Lehman <josh@martian.engineering> Co-authored-by: jeffjhunter <support@aipersonamethod.com>
317 lines
11 KiB
Markdown
317 lines
11 KiB
Markdown
---
|
|
summary: "Debugging tools: watch mode, raw model streams, and tracing reasoning leakage"
|
|
read_when:
|
|
- You need to inspect raw model output for reasoning leakage
|
|
- You want to run the Gateway in watch mode while iterating
|
|
- You need a repeatable debugging workflow
|
|
title: "Debugging"
|
|
---
|
|
|
|
Debugging helpers for streaming output, especially when a provider mixes reasoning into normal text.
|
|
|
|
## Runtime debug overrides
|
|
|
|
Use `/debug` in chat to set **runtime-only** config overrides (memory, not disk).
|
|
`/debug` is disabled by default; enable with `commands.debug: true`.
|
|
This is handy when you need to toggle obscure settings without editing `openclaw.json`.
|
|
|
|
Examples:
|
|
|
|
```
|
|
/debug show
|
|
/debug set messages.responsePrefix="[openclaw]"
|
|
/debug unset messages.responsePrefix
|
|
/debug reset
|
|
```
|
|
|
|
`/debug reset` clears all overrides and returns to the on-disk config.
|
|
|
|
## Session trace output
|
|
|
|
Use `/trace` when you want to see plugin-owned trace/debug lines in one session
|
|
without turning on full verbose mode.
|
|
|
|
Examples:
|
|
|
|
```text
|
|
/trace
|
|
/trace on
|
|
/trace off
|
|
```
|
|
|
|
Use `/trace` for plugin diagnostics such as Active Memory debug summaries.
|
|
Keep using `/verbose` for normal verbose status/tool output, and keep using
|
|
`/debug` for runtime-only config overrides.
|
|
|
|
## Plugin lifecycle trace
|
|
|
|
Use `OPENCLAW_PLUGIN_LIFECYCLE_TRACE=1` when plugin lifecycle commands feel slow
|
|
and you need a built-in phase breakdown for plugin metadata, discovery, registry,
|
|
runtime mirror, config mutation, and refresh work. The trace is opt-in and writes
|
|
to stderr, so JSON command output remains parseable.
|
|
|
|
Example:
|
|
|
|
```bash
|
|
OPENCLAW_PLUGIN_LIFECYCLE_TRACE=1 openclaw plugins install tokenjuice --force
|
|
```
|
|
|
|
Example output:
|
|
|
|
```text
|
|
[plugins:lifecycle] phase="config read" ms=6.83 status=ok command="install"
|
|
[plugins:lifecycle] phase="slot selection" ms=94.31 status=ok command="install" pluginId="tokenjuice"
|
|
[plugins:lifecycle] phase="registry refresh" ms=51.56 status=ok command="install" reason="source-changed"
|
|
```
|
|
|
|
Use this for plugin lifecycle investigation before reaching for a CPU profiler.
|
|
If the command is running from a source checkout, prefer measuring the built
|
|
runtime with `node dist/entry.js ...` after `pnpm build`; `pnpm openclaw ...`
|
|
also measures source-runner overhead.
|
|
|
|
## CLI startup and command profiling
|
|
|
|
Use the checked-in startup benchmark when a command feels slow:
|
|
|
|
```bash
|
|
pnpm test:startup:bench:smoke
|
|
pnpm tsx scripts/bench-cli-startup.ts --preset real --case status --runs 3
|
|
pnpm tsx scripts/bench-cli-startup.ts --preset real --cpu-prof-dir .artifacts/cli-cpu
|
|
```
|
|
|
|
For one-off profiling through the normal source runner, set
|
|
`OPENCLAW_RUN_NODE_CPU_PROF_DIR`:
|
|
|
|
```bash
|
|
OPENCLAW_RUN_NODE_CPU_PROF_DIR=.artifacts/cli-cpu pnpm openclaw status
|
|
```
|
|
|
|
The source runner adds Node CPU profile flags and writes a `.cpuprofile` for the
|
|
command. Use this before adding temporary instrumentation to command code.
|
|
|
|
For startup stalls that look like synchronous filesystem or module-loader work,
|
|
add Node's sync I/O trace flag through the source runner:
|
|
|
|
```bash
|
|
OPENCLAW_TRACE_SYNC_IO=1 pnpm openclaw gateway --force
|
|
```
|
|
|
|
`pnpm gateway:watch` leaves this flag disabled by default for the watched
|
|
Gateway child. Set `OPENCLAW_TRACE_SYNC_IO=1` when you explicitly want Node
|
|
sync I/O trace output in watch mode.
|
|
|
|
## Gateway watch mode
|
|
|
|
For fast iteration, run the gateway under the file watcher:
|
|
|
|
```bash
|
|
pnpm gateway:watch
|
|
```
|
|
|
|
By default, this starts or restarts a tmux session named
|
|
`openclaw-gateway-watch-main` (or a profile/port-specific variant such as
|
|
`openclaw-gateway-watch-dev-19001`) and auto-attaches from interactive terminals.
|
|
Non-interactive shells, CI, and agent exec calls stay detached and print attach
|
|
instructions instead. Attach manually when needed:
|
|
|
|
```bash
|
|
tmux attach -t openclaw-gateway-watch-main
|
|
```
|
|
|
|
The tmux pane runs the raw watcher:
|
|
|
|
```bash
|
|
node scripts/watch-node.mjs gateway --force
|
|
```
|
|
|
|
Use foreground mode when tmux is not wanted:
|
|
|
|
```bash
|
|
pnpm gateway:watch:raw
|
|
# or
|
|
OPENCLAW_GATEWAY_WATCH_TMUX=0 pnpm gateway:watch
|
|
```
|
|
|
|
Disable auto-attach while keeping tmux management:
|
|
|
|
```bash
|
|
OPENCLAW_GATEWAY_WATCH_ATTACH=0 pnpm gateway:watch
|
|
```
|
|
|
|
Profile watched Gateway CPU time when debugging startup/runtime hotspots:
|
|
|
|
```bash
|
|
pnpm gateway:watch --benchmark
|
|
```
|
|
|
|
The watch wrapper consumes `--benchmark` before invoking the Gateway and writes
|
|
one V8 `.cpuprofile` per Gateway child exit under
|
|
`.artifacts/gateway-watch-profiles/`. Stop or restart the watched gateway to
|
|
flush the current profile, then open it with Chrome DevTools or Speedscope:
|
|
|
|
```bash
|
|
npx speedscope .artifacts/gateway-watch-profiles/*.cpuprofile
|
|
```
|
|
|
|
Use `--benchmark-dir <path>` when you want profiles somewhere else.
|
|
Use `--benchmark-no-force` when you want the benchmarked child to skip the
|
|
default `--force` port cleanup and fail fast if the Gateway port is already in
|
|
use.
|
|
Benchmark mode suppresses sync-I/O trace spam by default. Set
|
|
`OPENCLAW_TRACE_SYNC_IO=1` with `--benchmark` when you explicitly want both CPU
|
|
profiles and Node sync-I/O stack traces. In benchmark mode those trace blocks
|
|
are written to `gateway-watch-output.log` under the benchmark directory and
|
|
filtered from the terminal pane; normal Gateway logs remain visible.
|
|
|
|
The tmux wrapper carries common non-secret runtime selectors such as
|
|
`OPENCLAW_PROFILE`, `OPENCLAW_CONFIG_PATH`, `OPENCLAW_STATE_DIR`,
|
|
`OPENCLAW_GATEWAY_PORT`, and `OPENCLAW_SKIP_CHANNELS` into the pane. Put
|
|
provider credentials in your normal profile/config, or use raw foreground mode
|
|
for one-off ephemeral secrets.
|
|
If the watched Gateway exits during startup, the watcher runs
|
|
`openclaw doctor --fix --non-interactive` once and restarts the Gateway child.
|
|
Use `OPENCLAW_GATEWAY_WATCH_AUTO_DOCTOR=0` when you want the original startup
|
|
failure without the dev-only repair pass.
|
|
The managed tmux pane also defaults to colored Gateway logs for readability;
|
|
set `FORCE_COLOR=0` when starting `pnpm gateway:watch` to disable ANSI output.
|
|
|
|
The watcher restarts on build-relevant files under `src/`, extension source files,
|
|
extension `package.json` and `openclaw.plugin.json` metadata, `tsconfig.json`,
|
|
`package.json`, and `tsdown.config.ts`. Extension metadata changes restart the
|
|
gateway without forcing a `tsdown` rebuild; source and config changes still
|
|
rebuild `dist` first.
|
|
|
|
Add any gateway CLI flags after `gateway:watch` and they will be passed through on
|
|
each restart. Re-running the same watch command respawns the named tmux pane, and
|
|
the raw watcher still keeps its single-watcher lock so duplicate watcher parents
|
|
are replaced instead of piling up.
|
|
|
|
## Dev profile + dev gateway (--dev)
|
|
|
|
Use the dev profile to isolate state and spin up a safe, disposable setup for
|
|
debugging. There are **two** `--dev` flags:
|
|
|
|
- **Global `--dev` (profile):** isolates state under `~/.openclaw-dev` and
|
|
defaults the gateway port to `19001` (derived ports shift with it).
|
|
- **`gateway --dev`: tells the Gateway to auto-create a default config +
|
|
workspace** when missing (and skip BOOTSTRAP.md).
|
|
|
|
Recommended flow (dev profile + dev bootstrap):
|
|
|
|
```bash
|
|
pnpm gateway:dev
|
|
OPENCLAW_PROFILE=dev openclaw tui
|
|
```
|
|
|
|
If you don't have a global install yet, run the CLI via `pnpm openclaw ...`.
|
|
|
|
What this does:
|
|
|
|
1. **Profile isolation** (global `--dev`)
|
|
- `OPENCLAW_PROFILE=dev`
|
|
- `OPENCLAW_STATE_DIR=~/.openclaw-dev`
|
|
- `OPENCLAW_CONFIG_PATH=~/.openclaw-dev/openclaw.json`
|
|
- `OPENCLAW_GATEWAY_PORT=19001` (browser/canvas shift accordingly)
|
|
|
|
2. **Dev bootstrap** (`gateway --dev`)
|
|
- Writes a minimal config if missing (`gateway.mode=local`, bind loopback).
|
|
- Sets `agent.workspace` to the dev workspace.
|
|
- Sets `agent.skipBootstrap=true` (no BOOTSTRAP.md).
|
|
- Seeds the workspace files if missing:
|
|
`AGENTS.md`, `SOUL.md`, `TOOLS.md`, `IDENTITY.md`, `USER.md`, `HEARTBEAT.md`.
|
|
- Default identity: **C3-PO** (protocol droid).
|
|
- Skips channel providers in dev mode (`OPENCLAW_SKIP_CHANNELS=1`).
|
|
|
|
Reset flow (fresh start):
|
|
|
|
```bash
|
|
pnpm gateway:dev:reset
|
|
```
|
|
|
|
<Note>
|
|
`--dev` is a **global** profile flag and gets eaten by some runners. If you need to spell it out, use the env var form:
|
|
|
|
```bash
|
|
OPENCLAW_PROFILE=dev openclaw gateway --dev --reset
|
|
```
|
|
|
|
</Note>
|
|
|
|
`--reset` wipes config, credentials, sessions, and the dev workspace (using
|
|
`trash`, not `rm`), then recreates the default dev setup.
|
|
|
|
<Tip>
|
|
If a non-dev gateway is already running (launchd or systemd), stop it first:
|
|
|
|
```bash
|
|
openclaw gateway stop
|
|
```
|
|
|
|
</Tip>
|
|
|
|
## Raw stream logging (OpenClaw)
|
|
|
|
OpenClaw can log the **raw assistant stream** before any filtering/formatting.
|
|
This is the best way to see whether reasoning is arriving as plain text deltas
|
|
(or as separate thinking blocks).
|
|
|
|
Enable it via CLI:
|
|
|
|
```bash
|
|
pnpm gateway:watch --raw-stream
|
|
```
|
|
|
|
Equivalent env vars:
|
|
|
|
```bash
|
|
OPENCLAW_RAW_STREAM=1
|
|
```
|
|
|
|
Default storage:
|
|
|
|
SQLite diagnostics (`diagnostics.raw_stream`). Use an explicit export/debug
|
|
command when you need a file artifact.
|
|
|
|
## Safety notes
|
|
|
|
- Raw stream logs can include full prompts, tool output, and user data.
|
|
- 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)
|
|
- [FAQ](/help/faq)
|