dev3000 0.0.189 → 0.0.192
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.
- package/README.md +101 -12
- package/dist/cdp-monitor.d.ts +10 -0
- package/dist/cdp-monitor.d.ts.map +1 -1
- package/dist/cdp-monitor.js +28 -4
- package/dist/cdp-monitor.js.map +1 -1
- package/dist/runtime/bridge.d.ts +2 -0
- package/dist/runtime/bridge.d.ts.map +1 -1
- package/dist/runtime/bridge.js +74 -0
- package/dist/runtime/bridge.js.map +1 -1
- package/dist/runtime/browser-capture.d.ts +117 -0
- package/dist/runtime/browser-capture.d.ts.map +1 -0
- package/dist/runtime/browser-capture.js +274 -0
- package/dist/runtime/browser-capture.js.map +1 -0
- package/dist/runtime/browser-compare.d.ts +91 -0
- package/dist/runtime/browser-compare.d.ts.map +1 -0
- package/dist/runtime/browser-compare.js +129 -0
- package/dist/runtime/browser-compare.js.map +1 -0
- package/dist/runtime/browser-events.d.ts +3 -2
- package/dist/runtime/browser-events.d.ts.map +1 -1
- package/dist/runtime/browser-events.js +11 -53
- package/dist/runtime/browser-events.js.map +1 -1
- package/dist/runtime/browser-metrics.d.ts +148 -0
- package/dist/runtime/browser-metrics.d.ts.map +1 -0
- package/dist/runtime/browser-metrics.js +243 -0
- package/dist/runtime/browser-metrics.js.map +1 -0
- package/dist/runtime/chrome-isolation.d.ts +4 -2
- package/dist/runtime/chrome-isolation.d.ts.map +1 -1
- package/dist/runtime/chrome-isolation.js +24 -35
- package/dist/runtime/chrome-isolation.js.map +1 -1
- package/dist/runtime/cli.js +67 -2
- package/dist/runtime/cli.js.map +1 -1
- package/dist/runtime/desktop-mcp.d.ts +216 -0
- package/dist/runtime/desktop-mcp.d.ts.map +1 -0
- package/dist/runtime/desktop-mcp.js +258 -0
- package/dist/runtime/desktop-mcp.js.map +1 -0
- package/dist/runtime/git-identity.d.ts +17 -0
- package/dist/runtime/git-identity.d.ts.map +1 -0
- package/dist/runtime/git-identity.js +41 -0
- package/dist/runtime/git-identity.js.map +1 -0
- package/dist/runtime/github-publish.d.ts +31 -0
- package/dist/runtime/github-publish.d.ts.map +1 -0
- package/dist/runtime/github-publish.js +237 -0
- package/dist/runtime/github-publish.js.map +1 -0
- package/dist/runtime/harness.d.ts +14 -3
- package/dist/runtime/harness.d.ts.map +1 -1
- package/dist/runtime/harness.js +55 -7
- package/dist/runtime/harness.js.map +1 -1
- package/dist/runtime/managed-cdp.d.ts +10 -0
- package/dist/runtime/managed-cdp.d.ts.map +1 -0
- package/dist/runtime/managed-cdp.js +80 -0
- package/dist/runtime/managed-cdp.js.map +1 -0
- package/dist/runtime/mcp-stdio.d.ts +17 -0
- package/dist/runtime/mcp-stdio.d.ts.map +1 -0
- package/dist/runtime/mcp-stdio.js +99 -0
- package/dist/runtime/mcp-stdio.js.map +1 -0
- package/dist/runtime/network-evidence.d.ts +28 -0
- package/dist/runtime/network-evidence.d.ts.map +1 -0
- package/dist/runtime/network-evidence.js +291 -0
- package/dist/runtime/network-evidence.js.map +1 -0
- package/dist/runtime/package-manager.d.ts +13 -0
- package/dist/runtime/package-manager.d.ts.map +1 -0
- package/dist/runtime/package-manager.js +69 -0
- package/dist/runtime/package-manager.js.map +1 -0
- package/dist/runtime/runtime.d.ts +7 -0
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +54 -30
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/sandbox-agent.d.ts +5 -0
- package/dist/runtime/sandbox-agent.d.ts.map +1 -1
- package/dist/runtime/sandbox-agent.js +32 -0
- package/dist/runtime/sandbox-agent.js.map +1 -1
- package/dist/runtime/sandbox-cleanup.d.ts +14 -0
- package/dist/runtime/sandbox-cleanup.d.ts.map +1 -0
- package/dist/runtime/sandbox-cleanup.js +77 -0
- package/dist/runtime/sandbox-cleanup.js.map +1 -0
- package/dist/runtime/sandbox-command.d.ts +1 -0
- package/dist/runtime/sandbox-command.d.ts.map +1 -1
- package/dist/runtime/sandbox-command.js +39 -9
- package/dist/runtime/sandbox-command.js.map +1 -1
- package/dist/runtime/sandbox-context.d.ts +5 -0
- package/dist/runtime/sandbox-context.d.ts.map +1 -0
- package/dist/runtime/sandbox-context.js +42 -0
- package/dist/runtime/sandbox-context.js.map +1 -0
- package/dist/runtime/sandbox-fx-resume.d.ts +11 -0
- package/dist/runtime/sandbox-fx-resume.d.ts.map +1 -0
- package/dist/runtime/sandbox-fx-resume.js +45 -0
- package/dist/runtime/sandbox-fx-resume.js.map +1 -0
- package/dist/runtime/sandbox-gateway.d.ts +17 -0
- package/dist/runtime/sandbox-gateway.d.ts.map +1 -0
- package/dist/runtime/sandbox-gateway.js +34 -0
- package/dist/runtime/sandbox-gateway.js.map +1 -0
- package/dist/runtime/sandbox-git.d.ts +19 -0
- package/dist/runtime/sandbox-git.d.ts.map +1 -0
- package/dist/runtime/sandbox-git.js +42 -0
- package/dist/runtime/sandbox-git.js.map +1 -0
- package/dist/runtime/sandbox-github.d.ts +10 -0
- package/dist/runtime/sandbox-github.d.ts.map +1 -0
- package/dist/runtime/sandbox-github.js +35 -0
- package/dist/runtime/sandbox-github.js.map +1 -0
- package/dist/runtime/sandbox-local-harness.d.ts +34 -0
- package/dist/runtime/sandbox-local-harness.d.ts.map +1 -0
- package/dist/runtime/sandbox-local-harness.js +151 -0
- package/dist/runtime/sandbox-local-harness.js.map +1 -0
- package/dist/runtime/sandbox-ports.d.ts +6 -0
- package/dist/runtime/sandbox-ports.d.ts.map +1 -0
- package/dist/runtime/sandbox-ports.js +11 -0
- package/dist/runtime/sandbox-ports.js.map +1 -0
- package/dist/runtime/sandbox-preview.d.ts +14 -0
- package/dist/runtime/sandbox-preview.d.ts.map +1 -0
- package/dist/runtime/sandbox-preview.js +96 -0
- package/dist/runtime/sandbox-preview.js.map +1 -0
- package/dist/runtime/sandbox-process.d.ts +11 -0
- package/dist/runtime/sandbox-process.d.ts.map +1 -0
- package/dist/runtime/sandbox-process.js +77 -0
- package/dist/runtime/sandbox-process.js.map +1 -0
- package/dist/runtime/sandbox-proxy.d.ts +2 -0
- package/dist/runtime/sandbox-proxy.d.ts.map +1 -1
- package/dist/runtime/sandbox-proxy.js +75 -20
- package/dist/runtime/sandbox-proxy.js.map +1 -1
- package/dist/runtime/sandbox-recovery.d.ts +4 -0
- package/dist/runtime/sandbox-recovery.d.ts.map +1 -0
- package/dist/runtime/sandbox-recovery.js +36 -0
- package/dist/runtime/sandbox-recovery.js.map +1 -0
- package/dist/runtime/sandbox-sessions.d.ts +8 -1
- package/dist/runtime/sandbox-sessions.d.ts.map +1 -1
- package/dist/runtime/sandbox-sessions.js +20 -2
- package/dist/runtime/sandbox-sessions.js.map +1 -1
- package/dist/runtime/sandbox-setup.d.ts +5 -0
- package/dist/runtime/sandbox-setup.d.ts.map +1 -0
- package/dist/runtime/sandbox-setup.js +62 -0
- package/dist/runtime/sandbox-setup.js.map +1 -0
- package/dist/runtime/sandbox-shell.d.ts +27 -0
- package/dist/runtime/sandbox-shell.d.ts.map +1 -0
- package/dist/runtime/sandbox-shell.js +169 -0
- package/dist/runtime/sandbox-shell.js.map +1 -0
- package/dist/runtime/sandbox-watch.d.ts +11 -0
- package/dist/runtime/sandbox-watch.d.ts.map +1 -0
- package/dist/runtime/sandbox-watch.js +30 -0
- package/dist/runtime/sandbox-watch.js.map +1 -0
- package/dist/runtime/sandbox-workspace.d.ts +125 -0
- package/dist/runtime/sandbox-workspace.d.ts.map +1 -0
- package/dist/runtime/sandbox-workspace.js +205 -0
- package/dist/runtime/sandbox-workspace.js.map +1 -0
- package/dist/runtime/sandbox.d.ts +21 -2
- package/dist/runtime/sandbox.d.ts.map +1 -1
- package/dist/runtime/sandbox.js +473 -207
- package/dist/runtime/sandbox.js.map +1 -1
- package/dist/runtime/session.d.ts +1 -1
- package/dist/runtime/session.d.ts.map +1 -1
- package/dist/runtime/session.js +3 -3
- package/dist/runtime/session.js.map +1 -1
- package/dist/runtime/terminal.d.ts +19 -0
- package/dist/runtime/terminal.d.ts.map +1 -0
- package/dist/runtime/terminal.js +60 -0
- package/dist/runtime/terminal.js.map +1 -0
- package/dist/runtime/workspace-client.d.ts +2 -0
- package/dist/runtime/workspace-client.d.ts.map +1 -0
- package/dist/runtime/workspace-client.js +46 -0
- package/dist/runtime/workspace-client.js.map +1 -0
- package/package.json +2 -1
- package/scripts/eve/README.md +341 -0
- package/scripts/eve/agent/agent.ts +12 -0
- package/scripts/eve/agent/channels/eve.ts +23 -0
- package/scripts/eve/agent/instructions.md +53 -0
- package/scripts/eve/agent/sandbox.ts +34 -0
- package/scripts/eve/build-cache.mjs +18 -0
- package/scripts/eve/build-cache.test.mjs +32 -0
- package/scripts/eve/client.mjs +229 -0
- package/scripts/eve/connection.mjs +89 -0
- package/scripts/eve/conversation.mjs +91 -0
- package/scripts/eve/conversation.test.mjs +113 -0
- package/scripts/eve/fixture-agent.ts +101 -0
- package/scripts/eve/images.mjs +84 -0
- package/scripts/eve/launch.mjs +277 -0
- package/scripts/eve/model-command.mjs +21 -0
- package/scripts/eve/reconnect.mjs +22 -0
- package/scripts/eve/reconnect.test.mjs +41 -0
- package/scripts/eve/settings.mjs +33 -0
- package/scripts/eve/supervisor.mjs +41 -0
- package/scripts/eve/tui-client.mjs +234 -0
- package/scripts/eve/tui-input.mjs +114 -0
- package/scripts/eve/verify.mjs +575 -0
- package/skills/d3k/SKILL.md +60 -5
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ pnpm dlx skills add vercel-labs/dev3000 --skill d3k
|
|
|
10
10
|
|
|
11
11
|
> Use d3k to run this project and help me debug the checkout flow.
|
|
12
12
|
|
|
13
|
-
The skill owns a small background JavaScript runtime. No global d3k binary is required. Node.js 24+, pnpm, and Chrome are needed. The installed local skill runs under Node; repository development and the
|
|
13
|
+
The skill owns a small background JavaScript runtime. No global d3k binary is required. Node.js 24+, pnpm, and Chrome are needed. The installed local skill runs under Node; repository development and the sandbox launcher also require Bun.
|
|
14
14
|
|
|
15
15
|
## Try the source
|
|
16
16
|
|
|
@@ -47,7 +47,13 @@ Before reproducing an issue, retain the `sessionId` and `cursor` from `status`.
|
|
|
47
47
|
|
|
48
48
|
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.
|
|
49
49
|
|
|
50
|
-
The timeline holds at most 5,000 events or 8 MiB. Individual records are capped. No log files are written by the runtime, and its evidence disappears on exit.
|
|
50
|
+
The timeline holds at most 5,000 events or 8 MiB. Individual records are capped. No log files are written by the runtime, and its evidence disappears on exit.
|
|
51
|
+
|
|
52
|
+
Network evidence includes redacted request/response headers (including wire-header events), protocol/cache metadata, encoded transfer size, raw CDP response timing, and DNS/connect/TLS/send/TTFB/download/total durations in milliseconds when available.
|
|
53
|
+
|
|
54
|
+
Request and response body previews capture app-origin Fetch/XHR JSON and URL-encoded forms, redact common credential fields recursively, and retain up to 8 KiB per preview. Bodies over 64 KiB, unsupported formats (including binary and streaming responses), and cross-origin bodies are omitted; completed API requests report an omission reason when capture is unavailable. Response bodies arrive as separate `response-body` events after completion, so continue reading the timeline after the request finishes.
|
|
55
|
+
|
|
56
|
+
URL query values, authorization/cookie headers, and common credential fields are redacted; this is best-effort redaction, and application payloads, console output, and server messages can still contain sensitive data.
|
|
51
57
|
|
|
52
58
|
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.
|
|
53
59
|
|
|
@@ -76,12 +82,14 @@ d3k --project my-team/my-project --name my-dev
|
|
|
76
82
|
fx
|
|
77
83
|
```
|
|
78
84
|
|
|
79
|
-
This
|
|
85
|
+
This command needs a recent Vercel CLI (tested with 59.26.0), Bun, Node.js 24+, macOS, and access to Vercel Sandbox. It uses your installed Google Chrome binary with a dedicated per-project profile; Chrome updates remain managed by your existing installation or IT. d3k does not download another browser. Run it from any directory: no local project checkout is needed. It uses your Vercel login to resolve the linked GitHub repository, project root, Development environment, and install/dev commands. It clones and installs the project remotely, uploads the installed d3k distribution, launches the dev server, opens a dedicated local Chrome, and enters the sandbox shell. `d3k sandbox --project my-project --scope my-team` is equivalent.
|
|
80
86
|
|
|
81
|
-
The shell starts in the Vercel project's root. d3k uses the image's fx binary or installs it from fx.sh when absent.
|
|
87
|
+
The shell starts in the Vercel project's root. d3k uses the image's fx binary or installs it from fx.sh when absent. fx connects automatically to the selected project’s team AI Gateway using a project-scoped session key. The key expires automatically after `--timeout` minutes (default: 60) and has a $5 non-renewing spending limit including BYOK usage. d3k prints the expiration time when the session closes. Resume creates a fresh key. Use `--gateway-budget 20` to change the session limit, `--gateway-budget none` to remove it, or `--no-gateway` for manual authentication. Automatic setup requires permission to create team Gateway API keys and does not bypass team model or provider restrictions. Project processes and harnesses share the sandbox identity, so use projects you trust with that limited Gateway access. d3k does not forward laptop harness credentials or Vercel management tokens. Use `--no-fx` to skip installation. App environment variables are supplied to dependency installation and the dev runtime; the interactive harness shell does not automatically inherit them.
|
|
82
88
|
|
|
83
89
|
Sandbox mode currently requires macOS. Chrome runs under an OS filesystem policy that permits its application bundle, system libraries, and dedicated d3k profile and temporary files. Other laptop files are denied, including CDP navigation and uploads. Host clipboard access is blocked at the OS pasteboard service. Chrome's inner sandbox cannot nest inside this macOS policy; the outer policy applies to the browser and all its children. Cookies use the dedicated profile’s local storage instead of the laptop keychain. A sandbox session can read and modify its own browser profile and authenticated web sessions. Use sandbox mode with projects you trust with that session's browser access. Other operating systems fail closed until equivalent confinement is available.
|
|
84
90
|
|
|
91
|
+
Remote harness context includes the laptop browser's existing CDP bridge, project directory, and exact `d3k-runtime browser` commands. Sandbox fx automatically loads the connected-session skill from a temporary block in its own `~/.fx/AGENTS.md` at startup, including when launched manually from the shell. Existing instructions are preserved, and the block is removed on exit; repository instruction files are untouched.
|
|
92
|
+
|
|
85
93
|
The launcher supplies project-scoped CLI authentication to the interactive connection without forwarding that management token into the VM. Inside the remote project directory, use the existing runtime:
|
|
86
94
|
|
|
87
95
|
```bash
|
|
@@ -90,9 +98,11 @@ d3k browser snapshot -i
|
|
|
90
98
|
d3k events --level error
|
|
91
99
|
```
|
|
92
100
|
|
|
93
|
-
The laptop keeps
|
|
101
|
+
Development environment values pass through launcher memory into the sandbox; d3k does not save a local env file or project checkout. The laptop keeps d3k, its browser profile, and session metadata. Other agents require their own authentication. Automatic creation supports public GitHub repositories and private repositories already onboarded to Vercel managed Sandbox Git. d3k detects an existing `git:write` Bound for the exact linked repository and requests brokered credentials using your configured Git name and email. The project must have the Sandbox Git credentials and signed-commits flags enabled and the Vercel GitHub App installed. The current platform warm-pool workaround requires six vCPUs for these sessions; effective team limits must permit that shape. d3k does not change authorization policies or copy laptop GitHub credentials into the VM. `--attach my-dev` remains available for a provisioned sandbox. Private package registry authentication also requires separate provisioning. The sandbox CLI reserves port 3000 for the app and exposes its authenticated proxy on a separate infrastructure port, so project startup checks do not mistake d3k for an existing dev server.
|
|
102
|
+
|
|
103
|
+
Project dependencies use the repository's package manager: `packageManager` takes precedence, followed by Bun, pnpm, Yarn, or npm lockfiles (npm is used when none is identified). Workspace installs run from the directory declaring that manager or containing its lockfile. Conflicting lockfiles require a `packageManager` declaration or an explicit command. A CLI `--install-command` overrides the Vercel project install setting; either explicit command runs from the project directory.
|
|
94
104
|
|
|
95
|
-
Use `--branch feature`, `--command '
|
|
105
|
+
Use `--branch feature`, `--command 'pnpm run dev'`, or `--install-command 'pnpm install'` to override project defaults. Dev commands must honor `PORT`, which identifies the private upstream port. `--no-shell` retains the local browser companion without opening a shell; `--headless` runs local Chrome headlessly. Sandbox compute and Gateway keys both default to a 60-minute lifetime; `--timeout <minutes>` changes both equally. Exiting stops the runtime and any sandbox created by this invocation, preserving its filesystem for `--attach <name>`. An attached sandbox stays running when the companion exits. Closing the dedicated Chrome also ends the session.
|
|
96
106
|
|
|
97
107
|
Chrome loads a stable local HTTPS origin: `https://<project>.d3k.localhost`. Use `--hostname songbook` for `https://songbook.d3k.localhost`. Canonical Portless must be ready on the laptop; no Portless installation is needed in the VM. A loopback streaming proxy forwards app traffic over verified HTTPS to the sandbox, preserving the local Host and forwarded origin, redirects, cookies, and WebSockets. The public sandbox app endpoint requires a fresh session token injected by the companion. Add the exact local callback URL to your auth provider's redirect allowlist (for example, `https://songbook.d3k.localhost/api/auth/callback`). A persistent outbound authenticated WSS connection carries CDP back to the VM; no externally reachable laptop listener, VPN, screen streaming, or file synchronization is needed. The VM exposes CDP discovery only on loopback. An in-VM streaming proxy preserves HTTP and application WebSockets and validates the exact app Origin before adapting Next.js HMR upgrades. Remote source edits can update local Chrome without a reload or project configuration change.
|
|
98
108
|
|
|
@@ -115,9 +125,49 @@ d3k --project my-team/my-project --harness fx
|
|
|
115
125
|
d3k --project my-team/my-project --attach my-dev --harness claude
|
|
116
126
|
```
|
|
117
127
|
|
|
118
|
-
|
|
128
|
+
New sandbox sessions default to **Eve**: `d3k --project my-team/my-project` runs Eve beside the remote code with Eve’s native terminal renderer and composer running locally. Haiku 5.5 with thinking off is the default; `/model` opens the model picker without clearing the conversation. Dependencies install temporarily; model access uses your team’s AI Gateway with no session spending cap by default and expires within 30 minutes. Use `--gateway-budget 20` to set an optional USD cap; `--gateway-budget none` removes a saved cap. Paste a local image path (including CleanShot’s escaped paths) to attach it as `[Image #1]`, or press **Ctrl+V** for a clipboard image. Ordinary sandbox tools run without per-command approval; tools with their own approval policy use Eve’s keyboard panel. Use `/detach` followed by Enter to reconnect within this launch. Press Ctrl-C at the reconnect prompt to exit. Closing the launcher stops compute; `d3k --resume <id>` restores the saved Eve conversation and its history with fresh access credentials. Phone handoff and laptop-close background execution are not implemented. Saved sessions retain their selected harness. `--no-shell` keeps the companion running without a harness. See [the Eve guide](scripts/eve/README.md).
|
|
129
|
+
|
|
130
|
+
`--harness` also accepts `fx`, `codex`, or `claude`. These harnesses run **locally by default** with `--project`, using a control directory with connection instructions. Local fx keeps the same workspace identity across d3k resumes; other local harnesses use a temporary directory. Project files, dependency installs, tests, Git branches and commits stay in the sandbox. Image pasting uses your local harness. Browser tools connect directly to local Chrome; file and runtime tools execute remotely. The selected alternative harness must already be installed. fx receives automatic team Gateway credentials locally; Codex and Claude use their own local authentication. Interactive harnesses require a terminal and cannot be combined with `--no-shell` or `--servers-only`. `d3k start` retains its local dev-server behavior; Eve requires `--project`.
|
|
131
|
+
|
|
132
|
+
Use `--harness-location sandbox` to run the harness inside the sandbox instead:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
d3k --project my-team/my-project --harness fx --harness-location sandbox
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
That mode retains fx installation and remote Gateway setup; other harnesses need remote installation and authentication. Without `--harness`, the command still opens a remote shell. Resume remembers both the harness and its location; `--harness-location` overrides the saved choice.
|
|
139
|
+
|
|
140
|
+
Local harnesses receive sandbox file, shell, runtime, browser, and repository-scoped GitHub tools. Codex and Claude load the tools through per-launch MCP configuration. fx can use the generated remote-command helper without MCP approval or discovery. Both paths use an authenticated loopback broker; Vercel credentials remain in the launcher. The GitHub tool uses local `gh` authentication against the linked repository to publish Git objects, branch refs and PRs without forwarding a GitHub credential. It rejects force pushes. Local harness conversations and tool results can contain code the agent reads, even though d3k creates no local checkout.
|
|
141
|
+
|
|
142
|
+
All local harnesses connected to a sandbox receive workspace instructions in the control directory; Codex and Claude also receive them directly at launch. For a harness running inside the sandbox, Codex and Claude receive the connected-session skill in their startup prompt, and fx automatically loads it through its temporary managed instructions. Project instruction files are left intact. The flag accepts fixed harness names, not commands, paths, or extra arguments. Exiting the harness closes a session started by that invocation.
|
|
143
|
+
|
|
144
|
+
## ChatGPT and Claude Desktop
|
|
145
|
+
|
|
146
|
+
Desktop clients can own a sandbox session directly through a local MCP server. No terminal harness or Gateway key is needed; the desktop client supplies the model. The project checkout, app environment, dev server, tests and Git edits stay remote, with Chrome running locally.
|
|
147
|
+
|
|
148
|
+
After installing the CLI and signing in to Vercel, prepare canonical HTTPS and print the desktop configuration:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
d3k portless setup
|
|
152
|
+
d3k mcp --print-config
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The generated `mcpServers.d3k` entry contains an absolute Node executable, the installed CLI path, and your shell's PATH so GUI clients can find Vercel CLI, Bun, and `gh`. It contains no credentials. Regenerate it after replacing the installation or Node version. This server uses **local stdio**, started by the desktop client with `d3k mcp`.
|
|
156
|
+
|
|
157
|
+
- **ChatGPT Desktop:** Settings → MCP servers → Add server → STDIO. Copy the generated command, arguments and PATH environment value, save, then restart the server. Use a local thread with access to that server.
|
|
158
|
+
- **Claude Desktop:** merge the generated `d3k` entry into `mcpServers` in `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS, preserving other servers, then restart Claude. This uses Claude Desktop's local MCP support, rather than a remote connector or Cowork.
|
|
159
|
+
|
|
160
|
+
Then ask:
|
|
161
|
+
|
|
162
|
+
> Use d3k to open my-team/my-project in a sandbox. Keep code and app env remote, and use the connected local Chrome to test my changes.
|
|
119
163
|
|
|
120
|
-
|
|
164
|
+
The server preloads remote-workspace instructions. `sandbox_start` returns immediately; `sandbox_status` reports startup progress and readiness. Once ready, `sandbox_exec`, `sandbox_read_file`, `sandbox_write_file`, `sandbox_runtime`, `sandbox_browser`, and `sandbox_github` provide the same workspace tools as local terminal harnesses. `sandbox_sessions` lists saved resume IDs; call `sandbox_start` with `resume` to reconnect. `sandbox_recover` restores a stopped dev runtime in the same session without cloning, reinstalling, or restarting the assistant or local Chrome. Call with `action: "start"`, then poll `action: "status"` until recovered or failed; reread runtime status afterward because restarted runtimes lose old in-memory evidence. Recovery does not replay agent commands, renew Gateway credentials, or extend compute lifetime. It is also available through local terminal harness workspace tools. `sandbox_stop` closes Chrome and d3k-owned compute while preserving remote files. Wait for `stopped` before starting another session.
|
|
165
|
+
|
|
166
|
+
For testing on a phone, ask the connected assistant to start with `browser: "link"`. Once ready, `sandbox_status` includes `preview.url` and `preview.expiresAt`. Open that HTTPS link in the phone's browser; the app renders on the phone while companion Chrome runs headlessly for agent testing. HTTP and HMR use the sandbox's HTTPS origin rather than `.localhost`. The link grants app access for this session, exchanges its secret fragment for a Secure, HttpOnly cookie, and expires when the session ends or its deadline passes. Keep it out of PRs and public logs. Resume with `browser: "link"` to create a fresh link. App authentication remains separate; auth providers may require the preview origin's exact callback URL in their redirect allowlist.
|
|
167
|
+
|
|
168
|
+
This still requires the running macOS companion and a client connected to its local MCP server. It does not make the MCP server accessible to ChatGPT on a phone. Stdio has no phone User-Agent; the assistant selects link mode from the user's request or explicit client context. The agent controls companion Chrome, not the phone's Safari or Chrome.
|
|
169
|
+
|
|
170
|
+
One sandbox is active per MCP server. Disconnecting or restarting the server also closes its session; resume it afterward. Sessions owned by another running companion are not taken over. macOS, local Vercel login, Bun, Node.js 24+, Sandbox access and canonical Portless remain required. GitHub publishing uses local `gh` authentication scoped to the linked repository. Client tool approvals and workspace policies still apply. Desktop conversation history may retain code returned by tools, even though d3k creates no local checkout or env file.
|
|
121
171
|
|
|
122
172
|
## Resume a sandbox
|
|
123
173
|
|
|
@@ -135,21 +185,60 @@ d3k --resume <id> --harness codex
|
|
|
135
185
|
d3k --resume <id> --no-shell
|
|
136
186
|
```
|
|
137
187
|
|
|
138
|
-
On harness exit, shell exit, or Ctrl-C, d3k closes Chrome and prints `d3k --resume <id>` to stdout. Resume uses the existing checkout and browser profile, restores the hostname and launch settings, refreshes Development env and
|
|
188
|
+
On harness exit, shell exit, or Ctrl-C, d3k closes Chrome and prints `d3k --resume <id>` to stdout. Resume uses the existing checkout and browser profile, restores the hostname and launch settings, refreshes Development env, reuses unchanged tool/dependency installs and Eve builds, restarts the dev runtime, and creates a fresh browser connection with new proxy and bridge tokens. The first resume after upgrading from an older CLI populates the setup cache. Dependency installs rerun when manifests, lockfiles, install command, or Development env change; Eve rebuilds when its sources, pinned dependencies, or workspace instructions change. Eve reopens its saved conversation from a stable remote service directory, including after a CLI upgrade. Missing or unreadable saved history stops startup instead of silently creating a new conversation. Older Eve sessions adopt their most recent remote conversation on the first upgraded resume; earlier separate conversations are not merged. When the saved harness is fx, resume also passes `fx -c` to continue its remembered conversation. Local fx uses a workspace directory recorded per d3k session, so separate sandboxes keep separate conversation histories. d3k refreshes connection instructions and removes the broker credential on exit; fx owns the saved conversation. Other harness conversations are not automatically resumed. A plain remote shell still requires typing `fx -c` yourself.
|
|
189
|
+
|
|
190
|
+
Temporary runtime-monitor connection failures retry without closing your shell. If the remote dev runtime exits while your harness is running, d3k reports it and keeps the shell open so you can finish or save your work. Exit the shell and resume to restore the dev server and browser. The sandbox's configured timeout still applies.
|
|
191
|
+
|
|
192
|
+
The interactive terminal uses WebSocket keepalives. If its connection drops without a confirmed remote process exit, d3k keeps the sandbox and browser running and prints a command to reconnect from another terminal. It does not automatically relaunch the harness or replay agent actions. Press Ctrl-C in the original terminal to close the session when finished.
|
|
139
193
|
|
|
140
194
|
Saved entries are local discovery metadata, without credentials or past terminal output. Remote availability is checked when resuming; a deleted sandbox cannot be recovered from the list. There is no automatic source-revision snapshot cache. Sandboxes created by d3k stop compute on exit while preserving their filesystem; externally attached sandboxes remain running.
|
|
141
195
|
|
|
142
|
-
Use `--command`, `--hostname`, `--timeout`, `--no-fx`, or `--headless` to override saved settings. A saved harness requires an interactive terminal, so use `--no-shell` only for sessions without a saved harness.
|
|
196
|
+
Use `--command`, `--hostname`, `--timeout`, `--harness-location`, `--no-fx`, `--no-gateway`, `--gateway-budget`, or `--headless` to override saved settings. A saved harness requires an interactive terminal, so use `--no-shell` only for sessions without a saved harness.
|
|
143
197
|
|
|
144
198
|
## Command surface and migration
|
|
145
199
|
|
|
146
|
-
|
|
200
|
+
Capture page-load metrics in a new tab of the managed browser:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
d3k browser metrics https://example.com/ --new-tab
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Returns JSON with Web Vitals, navigation timing (DNS, connect, TLS, TTFB, download, DOMContentLoaded and load), long tasks, and resource counts, sizes and slowest entries. Observers start before navigation. With no URL, `d3k browser metrics` inspects the current page without reloading; CLS and long tasks are unavailable. For MCP use `sandbox_browser` with `args: ["metrics", "https://example.com/", "--new-tab"]`. Harness startup instructions include this command.
|
|
207
|
+
|
|
208
|
+
These are explicit snapshots with provisional vitals, using the existing browser cache and throttling. They are not Lighthouse scores or field data. INP needs user interaction; unavailable metrics are `null`. Cross-origin timing restrictions and buffer limits can hide data; zero transfer bytes alone do not prove a cache hit. URL query values are redacted. Passive network events remain a separate source of request-level evidence.
|
|
209
|
+
|
|
210
|
+
The core commands are `start`, `stop`, `status`, `events`, `logs`, `errors`, `browser`, `portless status/setup`, `sandbox`, `mcp`, and explicit `upgrade`. Root options are for sandbox startup; local options belong after `start`. Unsupported options fail instead of being silently ignored.
|
|
211
|
+
|
|
212
|
+
For an explicit loading or jank investigation, capture a baseline **before editing**, then repeat the same scenario after the edit:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
d3k browser capture https://my-app.localhost/about --output /tmp/about-before --ready '#content' --actions '[{"click":"#expand"},{"scroll":600}]'
|
|
216
|
+
# Make the intended code change, wait for HMR/build readiness, then repeat unchanged:
|
|
217
|
+
d3k browser capture https://my-app.localhost/about --output /tmp/about-after --ready '#content' --actions '[{"click":"#expand"},{"scroll":600}]'
|
|
218
|
+
d3k browser compare /tmp/about-before /tmp/about-after --output /tmp/about-comparison.html
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Capture uses Chrome 153+'s native AV1 MP4 API in the existing managed browser: no extra browser, encoder installation or Chrome download. It warms the page once and records three runs by default (`--runs 1..5`), starting before navigation. `--ready` waits for a CSS selector after the load event; `--settle-ms 250..5000` defaults to 1000 before and after actions. Actions are repeatable CSS `click`, pixel `scroll`, or selector `waitFor` steps (up to ten); clicks are trusted browser input. Actions must stay in the same document; capture another page as a separate scenario. Scenarios that mutate application state need a repeatable reset or idempotent actions; d3k does not reset application data between runs.
|
|
222
|
+
|
|
223
|
+
Each new output directory contains requested videos and `capture.json`: navigation/paint timing, provisional LCP and CLS, long tasks, long animation frames, main-thread animation gaps and observed interaction durations. Existing directories are never overwritten. Browser IO streams are exported by the client without granting Chrome access to arbitrary output paths. For desktop MCP `sandbox_browser`, output paths are on the **laptop companion**; CLI commands running inside a sandbox export there instead. Comparison needs both directories on the same machine; move the HTML together with its referenced videos when sharing. Videos can contain authenticated page data; exports are explicit and remain until deleted.
|
|
224
|
+
|
|
225
|
+
The comparison report has synchronized side-by-side playback, run selection, seeking and slow playback, plus median/min/max metrics and comparability warnings. Navigation alignment is estimated from CDP timing, not frame-exact. Matching settings do not guarantee matching cache, CPU or network conditions; use repeatable production builds for performance decisions. Main-thread animation gaps are not compositor dropped-frame counts, observed interaction maxima are not INP, and unavailable values stay `null`. This workflow supplies evidence rather than an automatic Core Web Vitals pass/fail.
|
|
147
226
|
|
|
148
227
|
The previous local runtime, terminal UI, tmux agent launcher/resume, built-in skill catalog/installer, `fix`, `crawl`, and `cdp-port` have been removed. Replace `d3k -t` with `d3k start`, file-backed `logs`/`errors` with live timeline reads, and `d3k agent-browser` with `d3k browser`. Use `start --command` instead of `--port`/`--script`; Portless assigns local ports. Harnesses can run independently or through `--harness`. Screenshot capture is explicit through `browser screenshot`.
|
|
149
228
|
|
|
150
229
|
The npm package ships JavaScript, requires Node.js 24+, and exposes the same runtime through all three executable names. Standalone binaries are not yet distributed. Existing files from older versions are left untouched but are no longer read.
|
|
151
230
|
|
|
152
|
-
The website
|
|
231
|
+
The website contains the public landing page and changelog, plus an owner-only hosted MCP pilot. The previous hosted agent runners, workflow execution, teams, admin controls, report/blob storage, and CLI telemetry remain removed. Existing remote deployments and stored data are not deleted by a source change.
|
|
232
|
+
|
|
233
|
+
## Hosted MCP pilot
|
|
234
|
+
|
|
235
|
+
The hosted `/mcp` endpoint can run without your laptop. It starts the linked project, its Development environment, and automated Chrome inside Vercel Sandbox. A private HTTPS preview link opens the app in the user's phone or desktop browser; the agent controls a separate sandbox Chrome. The desktop `d3k mcp` companion described above remains available independently.
|
|
236
|
+
|
|
237
|
+
Access uses Sign in with Vercel through an OAuth 2.1 broker with PKCE and explicit client consent. This pilot admits one configured immutable Vercel user ID and an explicit project allowlist. The Vercel sign-in app currently supplies identity only; a dedicated project-scoped Vercel management token stays in the hosted service. Neither that token nor the OAuth client secret enters a project sandbox. Preview links grant app access only and expire with their session.
|
|
238
|
+
|
|
239
|
+
Hosted tools require an explicit session ID, so separate chats can use separate workspaces. The pilot permits two active workspaces with a one-hour deadline. `sandbox_stop` preserves files; `sandbox_start` with `resume` restores them with a new preview link. `sandbox_recover` restarts a stopped dev runtime without cloning or reinstalling. Initial support requires a linked public GitHub repository. Hosted GitHub publishing is not configured yet; the CLI companion's local `gh` publishing does not apply to the hosted service.
|
|
240
|
+
|
|
241
|
+
Deployment and credential setup are documented in [www/HOSTED-MCP.md](www/HOSTED-MCP.md). This is an opt-in pilot, not a generally available mobile connector.
|
|
153
242
|
|
|
154
243
|
## Development
|
|
155
244
|
|
package/dist/cdp-monitor.d.ts
CHANGED
|
@@ -29,6 +29,10 @@ export declare function selectCDPTarget(targets: CDPTargetInfo[], options?: {
|
|
|
29
29
|
export declare class CDPMonitor {
|
|
30
30
|
private eventObserver?;
|
|
31
31
|
setEventObserver(observer: (event: CDPEvent) => void): void;
|
|
32
|
+
readResponseBody(requestId: string): Promise<{
|
|
33
|
+
body: string;
|
|
34
|
+
base64Encoded: boolean;
|
|
35
|
+
}>;
|
|
32
36
|
private browser;
|
|
33
37
|
private connection;
|
|
34
38
|
private debugPort;
|
|
@@ -81,6 +85,12 @@ export declare class CDPMonitor {
|
|
|
81
85
|
/** A returning companion can retry after the previous finite recovery attempt was exhausted. */
|
|
82
86
|
recoverExternalConnection(): Promise<void>;
|
|
83
87
|
private attemptReconnect;
|
|
88
|
+
setSessionCookie(cookie: {
|
|
89
|
+
name: string;
|
|
90
|
+
value: string;
|
|
91
|
+
url: string;
|
|
92
|
+
expires: number;
|
|
93
|
+
}): Promise<void>;
|
|
84
94
|
private sendCDPCommand;
|
|
85
95
|
private getBundleTypeLabel;
|
|
86
96
|
private getReactDebugSnapshot;
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"cdp-monitor.d.ts","sourceRoot":"","sources":["../src/cdp-monitor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAI9B,kFAAkF;AAClF,wBAAgB,qBAAqB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,EAAE,CAEpF;AAED,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,CAAC,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC9B;AA6DD,eAAO,MAAM,sCAAsC,UAIlD,CAAA;AAyFD,wBAAgB,4BAA4B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAcvE;AAED,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAyB,GAAG,MAAM,EAAE,CAS1G;AAwDD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,aAAa,EAAE,EACxB,OAAO,GAA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ation } from "./runtime/chrome-isolation.js";
|
|
8
|
+
import { NETWORK_RESOURCE_LIMIT } from "./runtime/network-evidence.js";
|
|
8
9
|
/** Sandbox exceptions must be explicit; headless mode alone never disables it. */
|
|
9
10
|
export function getChromeSandboxFlags(env = process.env) {
|
|
10
11
|
return env.D3K_CHROME_NO_SANDBOX === "1" ? ["--no-sandbox", "--disable-setuid-sandbox"] : [];
|
|
@@ -237,6 +238,12 @@ export class CDPMonitor {
|
|
|
237
238
|
setEventObserver(observer) {
|
|
238
239
|
this.eventObserver = observer;
|
|
239
240
|
}
|
|
241
|
+
async readResponseBody(requestId) {
|
|
242
|
+
const result = await this.sendCDPCommand("Network.getResponseBody", { requestId }, 3000);
|
|
243
|
+
if (typeof result.body !== "string")
|
|
244
|
+
throw new Error("Response body unavailable");
|
|
245
|
+
return { body: result.body, base64Encoded: result.base64Encoded === true };
|
|
246
|
+
}
|
|
240
247
|
browser = null;
|
|
241
248
|
connection = null;
|
|
242
249
|
debugPort = 9222;
|
|
@@ -953,6 +960,17 @@ export class CDPMonitor {
|
|
|
953
960
|
this.reconnecting = false;
|
|
954
961
|
}
|
|
955
962
|
}
|
|
963
|
+
async setSessionCookie(cookie) {
|
|
964
|
+
const result = await this.sendCDPCommand("Network.setCookie", {
|
|
965
|
+
...cookie,
|
|
966
|
+
path: "/",
|
|
967
|
+
secure: true,
|
|
968
|
+
httpOnly: true,
|
|
969
|
+
sameSite: "Lax"
|
|
970
|
+
});
|
|
971
|
+
if (result.success === false)
|
|
972
|
+
throw new Error("Could not authorize the browser's preview session");
|
|
973
|
+
}
|
|
956
974
|
async sendCDPCommand(method, params = {}, timeoutMs = DEFAULT_CDP_COMMAND_TIMEOUT_MS) {
|
|
957
975
|
if (!this.connection) {
|
|
958
976
|
throw new Error("No CDP connection available");
|
|
@@ -1082,7 +1100,13 @@ export class CDPMonitor {
|
|
|
1082
1100
|
for (const domain of domains) {
|
|
1083
1101
|
try {
|
|
1084
1102
|
this.debugLog(`Enabling CDP domain: ${domain.name}`);
|
|
1085
|
-
await this.sendCDPCommand(`${domain.name}.enable`,
|
|
1103
|
+
await this.sendCDPCommand(`${domain.name}.enable`, domain.name === "Network"
|
|
1104
|
+
? {
|
|
1105
|
+
maxTotalBufferSize: 1024 * 1024,
|
|
1106
|
+
maxResourceBufferSize: NETWORK_RESOURCE_LIMIT,
|
|
1107
|
+
maxPostDataSize: NETWORK_RESOURCE_LIMIT
|
|
1108
|
+
}
|
|
1109
|
+
: {}, 3000);
|
|
1086
1110
|
this.debugLog(`Successfully enabled CDP domain: ${domain.name}`);
|
|
1087
1111
|
if (this.debug) {
|
|
1088
1112
|
this.logger("browser", `[CDP] Enabled ${domain.name} domain`);
|
|
@@ -1953,7 +1977,7 @@ export class CDPMonitor {
|
|
|
1953
1977
|
if (!browserClosedCleanly) {
|
|
1954
1978
|
try {
|
|
1955
1979
|
// Try to close the page
|
|
1956
|
-
await this.sendCDPCommand("Page.close");
|
|
1980
|
+
await this.sendCDPCommand("Page.close", {}, 1000);
|
|
1957
1981
|
this.debugLog("Sent Page.close command");
|
|
1958
1982
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1959
1983
|
}
|
|
@@ -1962,7 +1986,7 @@ export class CDPMonitor {
|
|
|
1962
1986
|
}
|
|
1963
1987
|
try {
|
|
1964
1988
|
// Get the list of targets to find our specific tab
|
|
1965
|
-
const targets = (await this.sendCDPCommand("Target.getTargets"));
|
|
1989
|
+
const targets = (await this.sendCDPCommand("Target.getTargets", {}, 1000));
|
|
1966
1990
|
this.debugLog(`Found ${targets.targetInfos?.length || 0} targets`);
|
|
1967
1991
|
// Find our page target
|
|
1968
1992
|
const pageTarget = targets.targetInfos?.find((t) => t.type === "page");
|
|
@@ -1970,7 +1994,7 @@ export class CDPMonitor {
|
|
|
1970
1994
|
this.debugLog(`Closing page target: ${pageTarget.targetId}`);
|
|
1971
1995
|
await this.sendCDPCommand("Target.closeTarget", {
|
|
1972
1996
|
targetId: pageTarget.targetId
|
|
1973
|
-
});
|
|
1997
|
+
}, 1000);
|
|
1974
1998
|
this.debugLog("Closed Chrome tab via CDP");
|
|
1975
1999
|
}
|
|
1976
2000
|
// Give it more time for the tab to close
|