wtt-connect 0.2.33 → 0.2.34

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.33",
3
+ "version": "0.2.34",
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
@@ -133,7 +133,7 @@ Commands:
133
133
  opendesign-upload --dir <path>
134
134
  Alias for upload-artifact
135
135
  preview-port --port <port> [--topic-id <id>]
136
- Create a Cloud Sandbox port preview URL
136
+ Create a Cloud Sandbox port preview URL through sandbox outbox
137
137
  help Show this help
138
138
  `);
139
139
  }
@@ -143,10 +143,10 @@ async function previewPort(config, argv) {
143
143
  if (!Number.isInteger(port) || port < 1 || port > 65535) {
144
144
  throw new Error('preview-port requires --port <1-65535>');
145
145
  }
146
- const api = new WTTApi(config);
147
- const preview = await api.createSandboxPreviewUrl(port, {
146
+ const preview = await createSandboxPreviewFromOutbox(config, port, {
148
147
  name: String(argv.previewName || argv.title || '').trim(),
149
148
  token: String(argv.previewToken || '').trim(),
149
+ timeoutMs: Number(argv.timeout || 15000),
150
150
  });
151
151
  const url = preview.preview_url || preview.url;
152
152
  if (!url) throw new Error('Cloud Sandbox preview API returned no URL');
@@ -169,6 +169,37 @@ async function previewPort(config, argv) {
169
169
  console.log(JSON.stringify({ ok: true, port, url, preview_url: url, markdown, published }, null, 2));
170
170
  }
171
171
 
172
+ async function createSandboxPreviewFromOutbox(config, port, { name = '', token = '', timeoutMs = 15000 } = {}) {
173
+ if (!config.cloudSandbox && !process.env.WTT_SANDBOX_OUTBOX_URL) {
174
+ throw new Error('preview-port is only available inside a WTT Cloud Sandbox');
175
+ }
176
+ const base = String(process.env.WTT_SANDBOX_OUTBOX_URL || 'http://wtt.preview').replace(/\/+$/, '');
177
+ const response = await fetch(`${base}/preview-port`, {
178
+ method: 'POST',
179
+ headers: { 'content-type': 'application/json' },
180
+ body: JSON.stringify({
181
+ agent_id: config.agentId,
182
+ port,
183
+ ...(name ? { name } : {}),
184
+ ...(token ? { token } : {}),
185
+ }),
186
+ signal: AbortSignal.timeout(Math.max(1000, Math.min(Number(timeoutMs || 15000), 60000))),
187
+ });
188
+ const text = await response.text();
189
+ let data = {};
190
+ if (text) {
191
+ try {
192
+ data = JSON.parse(text);
193
+ } catch {
194
+ data = { detail: text };
195
+ }
196
+ }
197
+ if (!response.ok) {
198
+ throw new Error(`Cloud Sandbox outbox preview failed: ${data.detail || data.error || response.statusText || response.status}`);
199
+ }
200
+ return data;
201
+ }
202
+
172
203
  async function uploadFile(config, argv) {
173
204
  const topicId = String(argv.topicId || argv.sourceId || '').trim();
174
205
  if (!topicId) throw new Error('upload-file requires --topic-id <topic_id>');
package/src/runner.js CHANGED
@@ -937,7 +937,7 @@ function renderCloudSandboxStorageInstruction(config, topicId = '') {
937
937
  '- Do not install large dependencies, clone large repositories, download datasets, or write bulky generated files into the workspace unless the user explicitly asks for local temporary storage.',
938
938
  '- Keep only source edits, small manifests, notes, and temporary scratch files in the workspace.',
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
- `- If you start a web server in the sandbox and the user should preview it, expose that port with: wtt-connect preview-port --port <port>${topicId ? ` --topic-id ${topicId}` : ' --topic-id <topic_id>'}. This creates a Cloudflare Sandbox preview URL and does not use the legacy artifact/media preview flow.`,
940
+ `- If you start a web server in the sandbox and the user should preview it, expose that port with: wtt-connect preview-port --port <port>${topicId ? ` --topic-id ${topicId}` : ' --topic-id <topic_id>'}. This calls the Cloudflare Sandbox outbound Worker directly to create a preview URL and does not use WTT backend preview or legacy artifact/media preview flows.`,
941
941
  );
942
942
  return lines.join('\n');
943
943
  }
package/src/wtt-api.js CHANGED
@@ -103,15 +103,4 @@ export class WTTApi {
103
103
  });
104
104
  }
105
105
 
106
- async createSandboxPreviewUrl(port, { name = '', token = '' } = {}) {
107
- if (!this.config.agentId) throw new Error('WTT_AGENT_ID is required');
108
- return this.request('POST', `/cloud-agents/${encodeURIComponent(this.config.agentId)}/preview`, {
109
- headers: this.agentHeaders(),
110
- json: {
111
- port,
112
- ...(name ? { name } : {}),
113
- ...(token ? { token } : {}),
114
- },
115
- });
116
- }
117
106
  }