wtt-connect 0.2.54 → 0.2.56

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wtt-connect",
3
- "version": "0.2.54",
3
+ "version": "0.2.56",
4
4
  "private": false,
5
5
  "description": "WTT-native connector daemon for Codex, Claude Code, Cursor, Gemini, ACP, and other coding agent surfaces.",
6
6
  "type": "module",
package/src/main.js CHANGED
@@ -149,7 +149,8 @@ Commands:
149
149
  Alias for upload-artifact
150
150
  preview-port --port <port> [--topic-id <id>] [--snapshot-dir <dir>]
151
151
  Create a Cloud Sandbox live preview URL; snapshots are opt-in
152
- cleanup-previews Stop preview servers previously registered by this agent
152
+ cleanup-previews [--keep-last <n>]
153
+ Stop preview servers previously registered by this agent
153
154
  help Show this help
154
155
  `);
155
156
  }
@@ -160,11 +161,7 @@ async function previewPort(config, argv) {
160
161
  throw new Error('preview-port requires --port <1024-65535>, excluding 3000');
161
162
  }
162
163
  await assertLocalPreviewPort(port, Number(argv.portCheckTimeout || argv.timeout || 5000));
163
- const keepLast = previewKeepLast(config, argv);
164
- const cleanup = cleanupOldPreviews(config, {
165
- currentPort: port,
166
- keepLast: Math.max(0, keepLast - 1),
167
- });
164
+ const cleanup = { stopped: [], kept: readPreviewRegistry(config).map((entry) => ({ port: Number(entry.port), url: entry.url || '' })) };
168
165
  const preview = await createSandboxPreviewFromOutbox(config, port, {
169
166
  name: String(argv.previewName || argv.title || '').trim(),
170
167
  token: String(argv.previewToken || '').trim(),
@@ -208,7 +205,8 @@ async function previewPort(config, argv) {
208
205
  }
209
206
 
210
207
  async function assertLocalPreviewPort(port, timeoutMs = 5000) {
211
- const url = `http://127.0.0.1:${port}/`;
208
+ const host = String(process.env.WTT_CONNECT_PREVIEW_CHECK_HOST || '10.0.0.1').trim() || '10.0.0.1';
209
+ const url = `http://${host}:${port}/`;
212
210
  try {
213
211
  await fetch(url, {
214
212
  method: 'GET',
@@ -216,7 +214,7 @@ async function assertLocalPreviewPort(port, timeoutMs = 5000) {
216
214
  });
217
215
  } catch (error) {
218
216
  const message = error instanceof Error ? error.message : String(error);
219
- throw new Error(`preview-port local server is not reachable at ${url}: ${message}`);
217
+ throw new Error(`preview-port server is not reachable from the Cloudflare preview network at ${url}. Bind the dev server to 0.0.0.0 instead of 127.0.0.1 or localhost: ${message}`);
220
218
  }
221
219
  }
222
220
 
@@ -279,11 +277,6 @@ async function cleanupPreviewsCommand(config, argv) {
279
277
  console.log(JSON.stringify({ ok: true, cleanup }, null, 2));
280
278
  }
281
279
 
282
- function previewKeepLast(config, argv = {}) {
283
- if (Number.isFinite(Number(argv.keepLast))) return Math.max(0, Number(argv.keepLast));
284
- return Math.max(0, Number(config.previewKeepLast ?? 3) || 0);
285
- }
286
-
287
280
  function cleanupOldPreviews(config, { currentPort = 0, keepLast = 0 } = {}) {
288
281
  const registry = readPreviewRegistry(config);
289
282
  const entries = registry
package/src/runner.js CHANGED
@@ -939,10 +939,11 @@ function renderCloudSandboxStorageInstruction(config, topicId = '') {
939
939
  '- If a generated user-facing file is stored in R2/persistent output storage and should appear in WTT chat, still publish it with `wtt-connect upload-file` or a WTT artifact marker.',
940
940
  '- If the user asks for a visual page, HTML artifact, chart, dashboard, animation, or browser preview, build it in the workspace, start a local web server, create a Cloudflare Sandbox preview URL, and return that preview URL to WTT.',
941
941
  '- The Cloud Sandbox preview URL feature is only for WTT Cloud Sandbox agents. Do not use WTT backend artifact/media preview flows for live sandbox web servers.',
942
- '- Preview servers must keep running after your command finishes. Start them in the background with `nohup ... >/tmp/<name>.log 2>&1 &` or an equivalent long-lived process, and bind to `0.0.0.0`.',
943
- '- Before publishing a preview URL, verify the server is actually listening and serving content with `curl -fsS http://127.0.0.1:<port>/ >/dev/null`.',
944
- '- If local curl fails, fix or restart the web server first. Never publish a preview URL for a dead port.',
945
- '- `wtt-connect preview-port` automatically keeps the most recent preview servers for this agent and stops older registered previews beyond the retention limit. Default retention is 3 live previews; use `--keep-last <n>` only when the user asks.',
942
+ '- Preview servers must keep running after your command finishes. Start them in the background with `nohup ... >/tmp/<name>.log 2>&1 &` or an equivalent long-lived process, and bind to `0.0.0.0`, not `127.0.0.1` or `localhost`.',
943
+ '- For Vite use `npm run dev -- --host 0.0.0.0 --port <port>`; for Next use `next dev -H 0.0.0.0 -p <port>`; for Python use `python3 -m http.server <port> --bind 0.0.0.0`.',
944
+ '- Before publishing a preview URL, verify the server is reachable from the Cloudflare preview network with `curl -fsS http://10.0.0.1:<port>/ >/dev/null`.',
945
+ '- If that curl fails, fix or restart the web server first. Never publish a preview URL for a dead or localhost-only port.',
946
+ '- `wtt-connect preview-port` must not stop older preview servers. WTT Web closes a live preview only when the user clicks the preview card X, or when `wtt-connect cleanup-previews` is explicitly requested.',
946
947
  '- Do not pass `--snapshot-dir` for normal live previews. Live Cloud Sandbox previews should render as inline WTT preview cards, not as ordinary index.html/document artifacts.',
947
948
  '- If the user explicitly asks for a persistent static artifact or downloadable HTML, publish that separately with `wtt-connect upload-artifact --dir <dir> --title "Short Title"` instead of mixing it with the live preview URL.',
948
949
  '- If you start a web server in the sandbox and the user should preview it, call the Cloudflare Sandbox outbound Worker directly with curl and include the returned `preview_url` in your reply as `[preview_url:Short Title](<preview_url>)`.',