wtt-connect 0.2.55 → 0.2.57

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.55",
3
+ "version": "0.2.57",
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(),
@@ -280,11 +277,6 @@ async function cleanupPreviewsCommand(config, argv) {
280
277
  console.log(JSON.stringify({ ok: true, cleanup }, null, 2));
281
278
  }
282
279
 
283
- function previewKeepLast(config, argv = {}) {
284
- if (Number.isFinite(Number(argv.keepLast))) return Math.max(0, Number(argv.keepLast));
285
- return Math.max(0, Number(config.previewKeepLast ?? 3) || 0);
286
- }
287
-
288
280
  function cleanupOldPreviews(config, { currentPort = 0, keepLast = 0 } = {}) {
289
281
  const registry = readPreviewRegistry(config);
290
282
  const entries = registry
package/src/runner.js CHANGED
@@ -939,17 +939,15 @@ 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`, 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` 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 are managed by the Cloudflare Sandbox Worker, not by WTT backend and not by `wtt-connect preview-port`.',
943
+ '- Each sandbox has one fixed live preview slot on port 5173. To create or replace a preview, call the Worker outbox `/preview/start` with a command and cwd. The Worker stops the old port-5173 dev server, starts the new one, checks reachability, exposes it publicly, and returns `preview_url`.',
944
+ '- The preview start command must bind to `0.0.0.0`, not `127.0.0.1` or `localhost`. The Worker auto-adds common Vite/Next/Python host flags when safe, but you should still provide explicit host flags.',
945
+ '- For Vite use command `npm run dev -- --host 0.0.0.0 --port 5173`; for Next use `next dev -H 0.0.0.0 -p 5173`; for Python use `python3 -m http.server 5173 --bind 0.0.0.0`.',
946
+ '- Never start multiple preview dev servers. If you need a new preview, call `/preview/start` again and let the Worker replace the old one.',
947
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.',
948
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.',
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>)`.',
950
- '- Preview ports must be 1024-65535 and cannot be 3000. For Vite/Next-style dev servers prefer 5173, 4173, or 8080.',
951
- `- Preview curl rule: curl -sS -X POST "\${WTT_SANDBOX_OUTBOX_URL:-http://wtt.preview}/preview-port" -H 'content-type: application/json' -d '{"agent_id":"'\${WTT_AGENT_ID:-cloud-agent}'","port":<port>}'`,
952
- `- Prefer automatic WTT publishing when topic id is available: wtt-connect preview-port --port <port>${topicId ? ` --topic-id ${topicId}` : ' --topic-id <topic_id>'} --title "Short Title". This publishes one cloud_sandbox_preview live card.`,
949
+ '- If a live preview is requested, call the Worker outbox directly and include the returned `preview_url` in your reply as `[preview_url:Short Title](<preview_url>)`.',
950
+ `- Preview start command: curl -sS -X POST "\${WTT_SANDBOX_OUTBOX_URL:-http://wtt.preview}/preview/start" -H 'content-type: application/json' -d '{"agent_id":"'\${WTT_AGENT_ID:-cloud-agent}'","title":"Short Title","cwd":"'\$(pwd)'","command":"npm run dev -- --host 0.0.0.0 --port 5173"}'`,
953
951
  );
954
952
  return lines.join('\n');
955
953
  }