dev3000 0.0.181 → 0.0.183

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +36 -170
  2. package/bin/d3k-runtime +2 -0
  3. package/bin/dev3000 +2 -119
  4. package/dist/cdp-monitor.d.ts +4 -0
  5. package/dist/cdp-monitor.d.ts.map +1 -1
  6. package/dist/cdp-monitor.js +21 -5
  7. package/dist/cdp-monitor.js.map +1 -1
  8. package/dist/cli.js +4 -53
  9. package/dist/cli.js.map +1 -1
  10. package/dist/dev-environment.d.ts.map +1 -1
  11. package/dist/dev-environment.js +8 -46
  12. package/dist/dev-environment.js.map +1 -1
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +2 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/runtime/browser-events.d.ts +5 -0
  18. package/dist/runtime/browser-events.d.ts.map +1 -0
  19. package/dist/runtime/browser-events.js +87 -0
  20. package/dist/runtime/browser-events.js.map +1 -0
  21. package/dist/runtime/cli.d.ts +3 -0
  22. package/dist/runtime/cli.d.ts.map +1 -0
  23. package/dist/runtime/cli.js +83 -0
  24. package/dist/runtime/cli.js.map +1 -0
  25. package/dist/runtime/runtime.d.ts +10 -0
  26. package/dist/runtime/runtime.d.ts.map +1 -0
  27. package/dist/runtime/runtime.js +346 -0
  28. package/dist/runtime/runtime.js.map +1 -0
  29. package/dist/runtime/session.d.ts +18 -0
  30. package/dist/runtime/session.d.ts.map +1 -0
  31. package/dist/runtime/session.js +61 -0
  32. package/dist/runtime/session.js.map +1 -0
  33. package/dist/runtime/timeline.d.ts +40 -0
  34. package/dist/runtime/timeline.d.ts.map +1 -0
  35. package/dist/runtime/timeline.js +69 -0
  36. package/dist/runtime/timeline.js.map +1 -0
  37. package/dist/skills/d3k/internal-skill.md +20 -131
  38. package/dist/skills/index.d.ts +54 -0
  39. package/dist/skills/index.d.ts.map +1 -0
  40. package/dist/skills/index.js +214 -0
  41. package/dist/skills/index.js.map +1 -0
  42. package/dist/utils/d3k-skill-installer.d.ts +4 -0
  43. package/dist/utils/d3k-skill-installer.d.ts.map +1 -0
  44. package/dist/utils/d3k-skill-installer.js +30 -0
  45. package/dist/utils/d3k-skill-installer.js.map +1 -0
  46. package/dist/utils/version-check.d.ts +1 -21
  47. package/dist/utils/version-check.d.ts.map +1 -1
  48. package/dist/utils/version-check.js +2 -97
  49. package/dist/utils/version-check.js.map +1 -1
  50. package/package.json +7 -16
  51. package/skills/d3k/PUBLISH.md +46 -0
  52. package/skills/d3k/SKILL.md +32 -0
  53. package/skills/d3k/agents/openai.yaml +4 -0
  54. package/skills/d3k/scripts/runtime.mjs +21 -0
  55. package/dist/commands/skill-runner.d.ts +0 -40
  56. package/dist/commands/skill-runner.d.ts.map +0 -1
  57. package/dist/commands/skill-runner.js +0 -826
  58. package/dist/commands/skill-runner.js.map +0 -1
  59. package/dist/skills/index.test.ts +0 -203
  60. package/dist/skills/index.ts +0 -259
package/README.md CHANGED
@@ -1,210 +1,76 @@
1
- # d3k (dev3000)
1
+ # d3k
2
2
 
3
- d3k is an agent-first local web debugging runtime. It starts your dev server, opens a monitored browser with a project-stable Chrome profile, and gives your coding agent one timeline of server logs, browser errors, network activity, interactions, and screenshots.
3
+ d3k gives your coding agent a managed browser and a shared timeline of server output, browser console messages, exceptions, network requests, and interactions.
4
4
 
5
- Every app gets a stable Portless URL by default, so browser state and callbacks do not move when the underlying development port changes.
6
-
7
- The primary interface is the d3k skill: tell your agent what you want, and let it own the runtime.
8
-
9
- > "Let me test this project with d3k."
10
- >
11
- > "Debug the checkout flow with d3k."
12
- >
13
- > "Run this app with d3k and watch for errors while I reproduce the bug."
14
-
15
- The TUI is still available for people who want a standalone terminal dashboard, but it is not required for the agent workflow.
16
-
17
- ## Install
18
-
19
- Node.js 24 or newer is required.
20
-
21
- Install the runtime globally:
5
+ Install the skill, then ask your agent to run the project, reproduce an issue, and inspect what happened:
22
6
 
23
7
  ```bash
24
- bun install -g dev3000
8
+ pnpm dlx skills add vercel-labs/dev3000 --skill d3k
25
9
  ```
26
10
 
27
- npm also works:
11
+ > Use d3k to run this project and help me debug the checkout flow.
28
12
 
29
- ```bash
30
- npm install -g dev3000
31
- ```
32
-
33
- Install the d3k skill for your coding agents:
34
-
35
- ```bash
36
- bunx skills add vercel-labs/dev3000 --skill d3k --agent '*' -g -y
37
- ```
13
+ The skill owns a small background JavaScript runtime. No global d3k binary or terminal dashboard is required. Node.js 24+, pnpm, and Chrome are needed. The installed skill runs the JavaScript runtime under Node; Bun is only used for development in this repository.
38
14
 
39
- The skill teaches agents to start d3k non-interactively, retain the background process, reuse the managed browser, and inspect the unified evidence instead of launching a separate dev server or browser.
15
+ ## Try the source
40
16
 
41
- ## The Agent Workflow
42
-
43
- When you ask to use d3k, the agent should:
44
-
45
- 1. Run `d3k portless status --json` and complete `d3k portless setup` if required.
46
- 2. Run `d3k status --json` and reuse only a ready Portless project session.
47
- 3. Start `d3k -t` in a retained background tool session when needed.
48
- 4. Wait for d3k to report a port-free HTTPS URL and managed browser.
49
- 5. Either hand the headed browser to you or drive it with `d3k agent-browser`, depending on your request.
50
- 6. Read `d3k errors --context` and the unified logs after reproduction.
51
- 7. Keep the same runtime and project-stable Chrome profile alive across edits and retests.
52
-
53
- That gives the user one stable URL, one browser, one evidence stream, and one dev server.
54
-
55
- ### "Let me test" vs. "Test this"
56
-
57
- "Let me test with d3k" means the agent prepares the headed monitored browser and hands control to you. It should wait while you reproduce the issue, then inspect what d3k captured.
58
-
59
- "Test/debug this with d3k" means the agent can drive the managed browser and investigate autonomously.
60
-
61
- ## Agent Commands
17
+ Until this runtime is released, use the helper from this checkout. Run these commands from the **app you want to debug**, replacing `/path/to/dev3000` with this checkout:
62
18
 
63
19
  ```bash
64
- # Is this project's runtime ready?
65
- d3k status --json
66
-
67
- # Is canonical Portless HTTPS ready?
68
- d3k portless status --json
69
-
70
- # Start the runtime manually in agent-safe mode (non-TUI default)
71
- d3k -t
72
-
73
- # Inspect unified evidence
74
- d3k errors --context
75
- d3k logs -n 200
76
- d3k logs --type browser
77
- d3k logs --type server
78
-
79
- # Drive the exact browser d3k is monitoring
80
- d3k agent-browser snapshot -i
81
- d3k agent-browser click @e2
82
- d3k agent-browser fill @e3 "text"
83
- d3k agent-browser --require-d3k-browser open https://my-app.localhost
20
+ node /path/to/dev3000/skills/d3k/scripts/runtime.mjs portless status
21
+ # One-time administrator authorization, if setup is required:
22
+ node /path/to/dev3000/skills/d3k/scripts/runtime.mjs portless setup
23
+ node /path/to/dev3000/skills/d3k/scripts/runtime.mjs start
84
24
  ```
85
25
 
86
- Do not run `npm run dev` or `bun run dev` alongside d3k. d3k is the dev-server owner for the session.
87
-
88
- Portless is required by default and only counts as ready when it provides a genuinely port-free URL such as `https://my-app.localhost`. `d3k portless setup` performs one-time administrator authorization to generate/trust the local HTTPS CA and install a root-owned startup service on port 443. After setup, every d3k server registers behind that proxy and the managed browser opens the Portless URL. d3k fails before starting the app when canonical Portless is unavailable; use `--no-portless` only when direct localhost routing is specifically required.
89
-
90
- ## Why the Managed Browser Matters
91
-
92
- Each project gets a persistent Chrome profile under `~/.d3k/<project>/chrome-profile/`. Login state, cookies, and local storage survive across debugging sessions.
93
-
94
- d3k also connects browser activity to server output, so an agent can see the interaction that preceded an error instead of reasoning from disconnected terminal and browser snapshots.
26
+ Keep `start` in a retained background process session. The helper runs checkout source with Bun. An installed skill can target this source by setting `D3K_RUNTIME_ROOT=/path/to/dev3000`.
95
27
 
96
- For OAuth and other auth-sensitive flows, let d3k launch Chrome. A separate Playwright, browser MCP, raw Chrome, or custom `agent-browser --profile` session is a different browser identity and can break sign-in flows.
28
+ Canonical Portless HTTPS must be ready before starting the server or browser. The runtime uses a port-free URL such as `https://my-app.localhost`, with a project-stable Chrome profile for authentication. It fails before launching the app if setup is incomplete.
97
29
 
98
- ## What d3k Captures
30
+ ## Read evidence
99
31
 
100
- - Development-server output
101
- - Browser console messages and exceptions
102
- - Network requests and responses
103
- - User interactions
104
- - Navigation and error screenshots
105
- - Chrome DevTools Protocol events
106
- - A session manifest that agents can discover with `d3k status --json`
107
-
108
- Artifacts are stored per project:
109
-
110
- | Artifact | Location |
111
- | --- | --- |
112
- | Active session | `~/.d3k/<project>/session.json` |
113
- | Consolidated log | `~/.d3k/<project>/d3k.log` or `logs/` |
114
- | Screenshots | `~/.d3k/<project>/screenshots/` |
115
- | Chrome profile | `~/.d3k/<project>/chrome-profile/` |
116
- | Crash log | `~/.d3k/crash.log` |
117
-
118
- ## Standalone TUI
119
-
120
- Run `d3k` directly when you want the interactive terminal experience:
32
+ The commands below use `d3k-runtime`, the package's JavaScript entrypoint. In a checkout, substitute `node /path/to/dev3000/skills/d3k/scripts/runtime.mjs`.
121
33
 
122
34
  ```bash
123
- d3k
35
+ d3k-runtime status
36
+ d3k-runtime browser snapshot -i
37
+ d3k-runtime browser click @e2
38
+ d3k-runtime events --session <sessionId> --after <cursor>
39
+ d3k-runtime events --after <cursor> --source server
40
+ d3k-runtime events --after <cursor> --level error
41
+ d3k-runtime stop
124
42
  ```
125
43
 
126
- You can also launch an agent beside the TUI in tmux:
44
+ Before reproducing an issue, retain the `sessionId` and `cursor` from `status`. Read events after that cursor, continuing while `hasMore` is true. A new session returns `reset: true`; `dropped` reports events evicted from the buffer. Filtered queries advance through examined events, so keep the original cursor when comparing multiple views of an interval.
127
45
 
128
- ```bash
129
- d3k --with-agent claude
130
- d3k --with-agent codex
131
- d3k --with-agent opencode
132
- ```
133
-
134
- The split-screen workflow requires tmux. The agent-first background workflow does not.
135
-
136
- ## Runtime Options
137
-
138
- ```bash
139
- d3k --help
140
- ```
46
+ Server and browser events share sequence numbers assigned at collection time. Network events retain CDP request IDs, and exceptions retain stack traces. Chronological proximity to a server line does not establish causation.
141
47
 
142
- | Option | Purpose |
143
- | --- | --- |
144
- | `-p, --port <port>` | Override the detected dev-server port |
145
- | `-s, --script <script>` | Override the detected package script |
146
- | `-c, --command <command>` | Run a custom dev-server command |
147
- | `--app-url <url>` | Open a specific URL in the managed browser |
148
- | `--profile-dir <dir>` | Override the project Chrome profile |
149
- | `--no-portless` | Disable the default stable Portless URL |
150
- | `--headless` | Run Chrome headlessly for CI |
151
- | `--servers-only` | Intentionally disable browser monitoring |
152
- | `--tui` | Enable the interactive dashboard (off by default) |
153
- | `--no-agent` | Skip the standalone agent-selection prompt |
154
- | `-t, --tail` | Stream the consolidated log |
155
- | `--debug` | Print verbose runtime diagnostics |
156
-
157
- Prefer auto-detection. Use overrides only when the project has an unusual dev command, port, or target URL.
158
-
159
- ## Diagnostic Commands
48
+ The timeline holds at most 5,000 events or 8 MiB. Individual records are capped. No log files are written by the skill runtime, and its evidence disappears on exit. Request headers and bodies are omitted; URL query values are redacted. Console output and server messages can still contain application secrets.
160
49
 
161
- ```bash
162
- d3k errors
163
- d3k errors --context
164
- d3k errors --all
50
+ Only browser profile and session discovery data persist under `~/.d3k/<project>/`. Local control uses authenticated IPC, not an HTTP listener on the network. Automatic screenshots are off; use `browser screenshot <absolute-path>` when needed.
165
51
 
166
- d3k logs
167
- d3k logs --type browser
168
- d3k logs --type server
169
- d3k logs --json
52
+ ## Server and browser ownership
170
53
 
171
- d3k fix
172
- d3k fix --focus build
54
+ The runtime detects the project's package manager and `dev` script. Use `start --command '<dev command>'` for other projects or custom servers. Use `--headless` for CI and `--servers-only` when browser monitoring is intentionally unwanted.
173
55
 
174
- d3k crawl
175
- d3k crawl --depth all
176
- ```
56
+ The agent and user share the same monitored browser. Do not launch a second server or substitute another browser profile during a session. Leave the runtime running when handing the browser to the user for testing.
177
57
 
178
- ## Supported Projects
58
+ ## Compatibility
179
59
 
180
- d3k detects common web projects, including:
60
+ `d3k` and `dev3000` retain the previous local CLI, including optional terminal UI and file-backed logging. The skill uses `d3k-runtime` instead. The two runtimes must not own the same project simultaneously. The npm package now ships JavaScript instead of platform-specific d3k binaries.
181
61
 
182
- - Next.js, Vite, React, Vue, Svelte, and Astro
183
- - Django, Flask, and FastAPI
184
- - Rails
185
- - Custom servers supplied through `--command`
62
+ The website is a public landing page and changelog. Hosted dev agents, skill runners, workflow execution, sandboxes, OAuth, teams, admin controls, report/blob storage, and CLI telemetry have been removed. Existing remote deployments and stored data are not deleted by a source change.
186
63
 
187
64
  ## Development
188
65
 
189
- Use d3k itself as the local runtime for this repository:
190
-
191
- ```bash
192
- d3k -t
193
- ```
194
-
195
- After code changes:
196
-
197
66
  ```bash
67
+ bun install
198
68
  bun run lint
199
69
  bun run typecheck
200
- ```
201
-
202
- For CLI or TUI changes under `src/`:
203
-
204
- ```bash
70
+ bun run test
205
71
  bun run canary
206
72
  ```
207
73
 
208
- ## License
74
+ `bun run canary` builds, packs, installs, and smoke-tests the JavaScript package locally. It does not publish to npm. Use `./scripts/release.sh` from a clean `main` checkout to prepare a stable release; GitHub Actions publishes through Trusted Publishing.
209
75
 
210
76
  MIT
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../dist/runtime/cli.js"
package/bin/dev3000 CHANGED
@@ -1,120 +1,3 @@
1
1
  #!/usr/bin/env node
2
- /**
3
- * Platform wrapper script for d3k
4
- *
5
- * This script detects the current platform and executes the appropriate
6
- * pre-compiled binary from the platform-specific optional dependency.
7
- */
8
-
9
- import { spawn } from "child_process"
10
- import { existsSync } from "fs"
11
- import { createRequire } from "module"
12
- import { arch, platform } from "os"
13
- import { dirname, join } from "path"
14
- import { fileURLToPath } from "url"
15
-
16
- const __filename = fileURLToPath(import.meta.url)
17
- const __dirname = dirname(__filename)
18
- const require = createRequire(import.meta.url)
19
-
20
- // Map of platform-arch to package name
21
- const PLATFORMS = {
22
- "darwin-arm64": "@d3k/darwin-arm64",
23
- "linux-x64": "@d3k/linux-x64",
24
- "win32-x64": "@d3k/windows-x64",
25
- // "darwin-x64": "@d3k/darwin-x64", // Add later
26
- // "linux-arm64": "@d3k/linux-arm64", // Add later
27
- }
28
-
29
- function findBinary() {
30
- const key = `${platform()}-${arch()}`
31
- const pkgName = PLATFORMS[key]
32
-
33
- if (!pkgName) {
34
- console.error(`\n Unsupported platform: ${key}`)
35
- console.error(` Currently supported platforms: macOS ARM64 (Apple Silicon), Linux x64, Windows x64`)
36
- console.error(`\n For other platforms, please open an issue at:`)
37
- console.error(` https://github.com/vercel-labs/dev3000/issues\n`)
38
- process.exit(1)
39
- }
40
-
41
- // Windows binaries have .exe extension
42
- const isWindows = platform() === "win32"
43
- const binaryName = isWindows ? "dev3000.exe" : "dev3000"
44
-
45
- // Try to find the binary in node_modules
46
- // It could be in the local node_modules or a parent directory
47
- const possiblePaths = [
48
- // Installed as a dependency
49
- join(__dirname, "..", "node_modules", pkgName, "bin", binaryName),
50
- // Installed globally (npm)
51
- join(__dirname, "..", "..", pkgName, "bin", binaryName),
52
- // Installed globally (pnpm)
53
- join(__dirname, "..", "node_modules", ".pnpm", `${pkgName}@*`, "node_modules", pkgName, "bin", binaryName),
54
- ]
55
-
56
- for (const binPath of possiblePaths) {
57
- if (existsSync(binPath)) {
58
- return binPath
59
- }
60
- }
61
-
62
- // Try to resolve through require
63
- try {
64
- const pkgPath = require.resolve(`${pkgName}/package.json`)
65
- const pkgDir = join(pkgPath, "..")
66
- const binPath = join(pkgDir, "bin", binaryName)
67
- if (existsSync(binPath)) {
68
- return binPath
69
- }
70
- } catch {
71
- // Package not found via require.resolve
72
- }
73
-
74
- console.error(`\n Could not find ${pkgName} binary.`)
75
- console.error(` Please ensure the package is properly installed:`)
76
- console.error(` npm install -g dev3000`)
77
- console.error(` or`)
78
- console.error(` pnpm install -g dev3000\n`)
79
- process.exit(1)
80
- }
81
-
82
- function main() {
83
- const binPath = findBinary()
84
-
85
- // Keep the JavaScript launcher alive so it can forward terminal signals to
86
- // the compiled runtime. This matters when the runtime owns detached child
87
- // process groups such as Portless-managed dev servers.
88
- const child = spawn(binPath, process.argv.slice(2), {
89
- stdio: "inherit",
90
- shell: false,
91
- })
92
-
93
- const forwardSignal = (signal) => {
94
- if (!child.killed) {
95
- child.kill(signal)
96
- }
97
- }
98
-
99
- process.on("SIGINT", () => forwardSignal("SIGINT"))
100
- process.on("SIGTERM", () => forwardSignal("SIGTERM"))
101
- if (process.platform !== "win32") {
102
- process.on("SIGHUP", () => forwardSignal("SIGHUP"))
103
- }
104
-
105
- child.on("error", (error) => {
106
- console.error(`Failed to start d3k: ${error.message}`)
107
- process.exit(1)
108
- })
109
-
110
- child.on("exit", (code, signal) => {
111
- if (code !== null) {
112
- process.exit(code)
113
- }
114
-
115
- const signalExitCodes = { SIGINT: 130, SIGTERM: 143, SIGHUP: 129 }
116
- process.exit(signalExitCodes[signal] || 1)
117
- })
118
- }
119
-
120
- main()
2
+ // Compatibility CLI. The skill uses bin/d3k-runtime, which doesn't load this UI.
3
+ import "../dist/cli.js"
@@ -25,6 +25,10 @@ export declare function selectCDPTarget(targets: CDPTargetInfo[], options?: {
25
25
  initialAppUrl?: string;
26
26
  }): CDPTargetInfo;
27
27
  export declare class CDPMonitor {
28
+ private eventObserver?;
29
+ private automaticScreenshots;
30
+ setEventObserver(observer: (event: CDPEvent) => void): void;
31
+ setAutomaticScreenshots(enabled: boolean): void;
28
32
  private browser;
29
33
  private connection;
30
34
  private debugPort;
@@ -1 +1 @@
1
- {"version":3,"file":"cdp-monitor.d.ts","sourceRoot":"","sources":["../src/cdp-monitor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAE9B,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,SAAS,CAAA;IACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,CA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M,CAAA;SAAE,CAAA;QACtC,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACnC,EAAE,CAAC,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;QAC7B,IAAI,CAAC,EAAE;YAAE,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAChC,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDhB;IAED;;;OAGG;IACH,eAAe,IAAI,IAAI,CAGtB;YAEa,kBAAkB;YAyBlB,uBAAuB;IAoF/B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAkF9B;YAEa,2BAA2B;CA+C1C"}
@@ -228,6 +228,14 @@ export function selectCDPTarget(targets, options = {}) {
228
228
  throw new Error(`CDP target mismatch on port ${options.appServerPort || "unknown"}; expected ${expectedDetails}, found ${debuggableTargets.map(formatTargetForLog).join(", ")}`);
229
229
  }
230
230
  export class CDPMonitor {
231
+ eventObserver;
232
+ automaticScreenshots = true;
233
+ setEventObserver(observer) {
234
+ this.eventObserver = observer;
235
+ }
236
+ setAutomaticScreenshots(enabled) {
237
+ this.automaticScreenshots = enabled;
238
+ }
231
239
  browser = null;
232
240
  connection = null;
233
241
  debugPort = 9222;
@@ -435,7 +443,7 @@ export class CDPMonitor {
435
443
  }
436
444
  }
437
445
  getCdpUrl() {
438
- return this.cdpUrl;
446
+ return this.connection?.ws.readyState === 1 ? this.cdpUrl : null;
439
447
  }
440
448
  getChromePids() {
441
449
  return Array.from(this.chromePids);
@@ -1307,7 +1315,8 @@ export class CDPMonitor {
1307
1315
  this.debugLog(`Target destroyed: ${params.targetId}`);
1308
1316
  this.logger("browser", `[TARGET] Window/tab closed: ${params.targetId}`);
1309
1317
  // If this is our main tab/window being closed, trigger shutdown callback
1310
- if (this.onWindowClosedCallback && !this.isShuttingDown) {
1318
+ const monitoredTarget = this.cdpUrl?.split("/").pop();
1319
+ if (params.targetId === monitoredTarget && this.onWindowClosedCallback && !this.isShuttingDown) {
1311
1320
  this.debugLog("Chrome window was manually closed, triggering d3k shutdown");
1312
1321
  this.logger("browser", "[TARGET] Chrome window manually closed, shutting down d3k");
1313
1322
  this.onWindowClosedCallback();
@@ -1345,6 +1354,12 @@ export class CDPMonitor {
1345
1354
  }
1346
1355
  if (message.method) {
1347
1356
  this.debugLog(`Received CDP event: ${message.method}`);
1357
+ this.eventObserver?.({
1358
+ method: message.method,
1359
+ params: message.params || {},
1360
+ timestamp: Date.now(),
1361
+ sessionId: message.sessionId
1362
+ });
1348
1363
  const handler = this.eventHandlers.get(message.method);
1349
1364
  if (handler) {
1350
1365
  const event = {
@@ -1496,8 +1511,7 @@ export class CDPMonitor {
1496
1511
  id: el.id || '',
1497
1512
  className: el.className || '',
1498
1513
  name: el.name || '',
1499
- type: el.type || '',
1500
- value: el.value || ''
1514
+ type: el.type || ''
1501
1515
  };
1502
1516
  return JSON.stringify(details);
1503
1517
  }
@@ -1524,7 +1538,7 @@ export class CDPMonitor {
1524
1538
  let details = getElementDetails(e.target);
1525
1539
  // Send interaction data via custom event instead of console.log to avoid user visibility
1526
1540
  window.dispatchEvent(new CustomEvent('dev3000-interaction', {
1527
- detail: { type: 'KEY', key: e.key, element: details }
1541
+ detail: { type: 'KEY', key: e.key.length === 1 ? '[character]' : e.key, element: details }
1528
1542
  }));
1529
1543
  });
1530
1544
 
@@ -1794,6 +1808,8 @@ export class CDPMonitor {
1794
1808
  }
1795
1809
  }
1796
1810
  async takeScreenshot(event) {
1811
+ if (!this.automaticScreenshots)
1812
+ return null;
1797
1813
  try {
1798
1814
  // Throttle screenshots to avoid spam
1799
1815
  const now = Date.now();