Files
webstudio/packages/cli/package.json
T
Oleg Isonen 75840a119c fix: Start previews and diagnose runtime failures (#6321)
## Summary

Preview startup now binds loopback directly instead of scanning network
interfaces first. MCP no longer exposes or accepts a fixed preview host
or port: the CLI asks the operating system for an available loopback
port and returns the resulting URL.

The CLI also returns safe, structured diagnostics when the runtime
blocks preview networking or Chromium IPC, when generated IDs collide,
and when a listening preview fails its HTTP readiness probe. Preview
startup retries only a genuine automatic-port race; HTTP and connection
failures return immediately instead of repeating the full startup
timeout five times.

## Issue checklist

- [x] #6318 — reproduced the `uv_interface_addresses` failure, replaced
interface discovery with a direct TCP bind, and added a regression test
for the exact failure.
- [x] #6319 — reproduced Chromium aborting before DevTools startup when
the managed runtime blocks browser IPC/socket operations. The host
restriction cannot be bypassed by the CLI, but future reports now
include a safe `browser_ipc_permission_denied` issue without raw stderr,
paths, or tokens.
- [x] #6320 — ran four reported insert variants sequentially across two
pages; all generated unique IDs. Future collision errors now include the
affected namespace and insertion stage without exposing the generated
ID.
- [x] #6324 — reproduced the generic readiness timeout with a real
generated preview whose root probe returned HTTP 500 after the server
printed its Local URL. The MCP contract and documentation also allowed
agents to force a busy port; network binding is now runner-owned.
- [x] #6325 — confirmed the responsive screenshot uses the same
readiness path. Future reports distinguish HTTP, refused-connection,
timeout, and permission failures, non-port failures are no longer
retried, and screenshots cannot request a fixed preview port.
- [x] Documentation impact reviewed. Updated MCP examples and vision
guidance to omit runner-owned host and port fields.

## Technical notes

- Removes the CLI's direct `get-port` dependency. That package calls
`os.networkInterfaces()` even when a host is supplied.
- Binds `{ host: "127.0.0.1", port: 0 }`, reads the assigned TCP port,
then closes the temporary server.
- Removes `host` and `port` from MCP preview and screenshot input
schemas and rejects those fields at runtime.
- Returns the selected preview URL from `preview.start`; managed
screenshots reuse that active target.
- Returns `PREVIEW_NETWORK_RESTRICTED` with a stable
`network_permission_denied` issue when the OS rejects loopback binding.
- Reads at most the last 4 KB of Chromium startup stderr, maps only the
reproduced IPC/socket denial to a safe diagnostic, and discards the
buffer after startup.
- Preserves browser startup issues through CLI browser fallback
aggregation and the MCP screenshot error boundary.
- Reports generated record collisions with `generated_id_conflict`, the
namespace constraint, and the fragment insertion stage.
- Preserves structured readiness diagnostics when preview output is
appended.
- Reports HTTP 5xx and local connection failures without exposing raw
fetch errors.
- Retries with a newly allocated port only for `EADDRINUSE` /
`PREVIEW_PORT_IN_USE`.

## Verification

- [x] New regression tests were shown to fail before implementation and
pass afterward.
- [x] Reproduced the old generic timeout through the real preview
controller; after the fix, the same path returned `PREVIEW_HTTP_ERROR`
with `http_status:500`.
- [x] Verified MCP advertised and accepted fixed host/port fields before
the change, then rejected both fields after the change.
- [x] Preview readiness/controller tests: 2 files, 29 tests passed.
- [x] Vision tests: 13 files, 81 tests passed.
- [x] Project-build tests: 88 files, 2,282 tests passed.
- [x] CLI tests: 66 files, 1,038 tests passed.
- [x] Vision, project-build, and CLI typechecks passed.
- [x] Lint passed with warnings denied.
- [x] Package-boundary and MCP documentation checks passed.
- [x] Fixture impact reviewed; no fixture inputs or generated fixture
outputs are affected. Generated documentation was updated; the generated
runtime operation contract did not change.

Agent evaluations were not run because they require separate approval.

Closes #6318

Ref #6319

Ref #6320

Ref #6324

Ref #6325
2026-09-03 16:34:20 +02:00

137 lines
4.9 KiB
JSON

{
"name": "webstudio",
"version": "0.0.0-webstudio-version",
"description": "Webstudio CLI",
"author": "Webstudio <github@webstudio.is>",
"homepage": "https://webstudio.is",
"type": "module",
"bin": {
"webstudio-cli": "./bin.js",
"webstudio": "./bin.js"
},
"exports": {
"./vision": {
"webstudio": "./src/vision.ts"
}
},
"files": [
"lib/*",
"templates/*",
"bin.js",
"!*.{test,stories}.*"
],
"scripts": {
"typecheck": "tsc --noEmit",
"generate-docs": "tsx scripts/generate-docs.ts && oxfmt src/docs.generated.ts",
"build:content-runtime": "esbuild @webstudio-is/content-engine/runtime --bundle --format=esm --platform=browser --target=es2022 --conditions=webstudio,worker --minify --outfile=lib/content-runtime.js",
"fixtures:build": "pnpm build:content-runtime",
"build": "pnpm generate-docs && rm -rf lib && vite build && pnpm build:content-runtime",
"pretest": "mkdir -p lib && pnpm build:content-runtime",
"evaluations": "tsx --import ../../scripts/register-react-global.ts --conditions=webstudio evaluations/high-impact/run-local-agent.ts",
"test": "vitest run",
"test:ssg-package": "tsx --conditions=webstudio scripts/test-ssg-package.ts",
"check:published-cli-contract": "tsx --conditions=webstudio scripts/builder-contract-gate.ts",
"test:release-smoke": "pnpm build && tsx --conditions=webstudio scripts/release-smoke.ts",
"test:release-smoke:model": "WEBSTUDIO_RELEASE_SMOKE_MODEL_EVAL_REQUIRED=1 pnpm test:release-smoke",
"test:release-smoke:registry": "tsx --conditions=webstudio scripts/release-smoke.ts"
},
"license": "AGPL-3.0-or-later",
"engines": {
"node": ">=22.12.0"
},
"dependencies": {
"@clack/prompts": "^0.10.0",
"@emotion/hash": "^0.9.2",
"@trpc/client": "^10.45.2",
"@webstudio-is/http-client": "workspace:*",
"@webstudio-is/project-migrations": "workspace:*",
"@webstudio-is/protocol": "workspace:*",
"@webstudio-is/sync-client": "workspace:*",
"acorn": "^8.14.1",
"acorn-jsx": "^5.3.2",
"acorn-walk": "^8.3.4",
"change-case": "^5.4.4",
"chrome-launcher": "^1.2.1",
"deepmerge": "^4.3.1",
"decode-named-character-reference": "^1.0.2",
"detect-port": "^2.1.0",
"env-paths": "^3.0.0",
"esbuild": "^0.25.3",
"execa": "^10.0.1",
"fast-deep-equal": "^3.1.3",
"immer": "^10.1.1",
"p-limit": "^6.2.0",
"parse5": "7.3.0",
"path-key": "^4.0.0",
"picocolors": "^1.1.1",
"reserved-identifiers": "^1.0.0",
"semver": "7.7.1",
"tinyexec": "^0.3.2",
"tus-js-client": "^4.3.1",
"warn-once": "^0.1.1",
"which": "^5.0.0",
"yargs": "^17.7.2",
"zod": "^4.4.3"
},
"devDependencies": {
"@cloudflare/vite-plugin": "^1.1.0",
"@netlify/vite-plugin-react-router": "^1.0.1",
"@react-router/dev": "^7.5.3",
"@react-router/fs-routes": "^7.5.3",
"@react-router/node": "^7.5.3",
"@react-router/serve": "^7.5.3",
"@remix-run/cloudflare": "^2.16.5",
"@remix-run/cloudflare-pages": "^2.16.5",
"@remix-run/dev": "^2.16.5",
"@remix-run/node": "^2.16.5",
"@remix-run/react": "^2.16.5",
"@remix-run/server-runtime": "^2.16.5",
"@shikijs/langs": "4.4.1",
"@shikijs/themes": "4.4.1",
"@types/mdast": "^4.0.4",
"@types/react": "^18.2.70",
"@types/react-dom": "^18.2.25",
"@types/semver": "^7.7.0",
"@types/which": "^3.0.4",
"@types/yargs": "^17.0.33",
"@vercel/react-router": "^1.1.0",
"@vitejs/plugin-react": "^4.4.1",
"@webstudio-is/css-engine": "workspace:*",
"@webstudio-is/content-engine": "workspace:*",
"@webstudio-is/expression": "workspace:*",
"@webstudio-is/fonts": "workspace:*",
"@webstudio-is/image": "workspace:*",
"@webstudio-is/project-build": "workspace:*",
"@webstudio-is/query-builder": "workspace:*",
"@webstudio-is/react-sdk": "workspace:*",
"@webstudio-is/sdk": "workspace:*",
"@webstudio-is/sdk-components-animation": "workspace:*",
"@webstudio-is/sdk-components-react": "workspace:*",
"@webstudio-is/sdk-components-react-radix": "workspace:*",
"@webstudio-is/sdk-components-react-remix": "workspace:*",
"@webstudio-is/sdk-components-react-router": "workspace:*",
"@webstudio-is/sdk-components-registry": "workspace:*",
"@webstudio-is/tsconfig": "workspace:*",
"@webstudio-is/vision": "workspace:*",
"@webstudio-is/wsauth": "workspace:*",
"h3": "^1.15.1",
"ipx": "^3.0.3",
"isbot": "^5.1.25",
"mdast-util-directive": "^3.1.0",
"mdast-util-from-markdown": "^2.0.3",
"mdast-util-to-string": "^4.0.0",
"micromark-extension-directive": "^4.0.0",
"oxfmt": "0.58.0",
"react": "18.3.0-canary-14898b6a9-20240318",
"react-dom": "18.3.0-canary-14898b6a9-20240318",
"react-router": "^7.5.3",
"shiki": "4.4.1",
"ts-expect": "^1.3.0",
"typescript": "7.0.2",
"vike": "^0.4.229",
"vite": "^6.3.4",
"vitest": "^3.1.2",
"wrangler": "^3.63.2"
}
}