wtt-connect 0.2.48 → 0.2.50

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.48",
3
+ "version": "0.2.50",
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,6 +149,7 @@ async function previewPort(config, argv) {
149
149
  if (!Number.isInteger(port) || port < 1024 || port > 65535 || port === 3000) {
150
150
  throw new Error('preview-port requires --port <1024-65535>, excluding 3000');
151
151
  }
152
+ await assertLocalPreviewPort(port, Number(argv.portCheckTimeout || argv.timeout || 5000));
152
153
  const keepLast = previewKeepLast(config, argv);
153
154
  const cleanup = cleanupOldPreviews(config, {
154
155
  currentPort: port,
@@ -195,6 +196,19 @@ async function previewPort(config, argv) {
195
196
  console.log(JSON.stringify({ ok: true, port, url, preview_url: url, snapshot, markdown, cleanup, published }, null, 2));
196
197
  }
197
198
 
199
+ async function assertLocalPreviewPort(port, timeoutMs = 5000) {
200
+ const url = `http://127.0.0.1:${port}/`;
201
+ try {
202
+ await fetch(url, {
203
+ method: 'GET',
204
+ signal: AbortSignal.timeout(Math.max(1000, Math.min(Number(timeoutMs || 5000), 15000))),
205
+ });
206
+ } catch (error) {
207
+ const message = error instanceof Error ? error.message : String(error);
208
+ throw new Error(`preview-port local server is not reachable at ${url}: ${message}`);
209
+ }
210
+ }
211
+
198
212
  async function createPreviewSnapshot(config, argv, { title = 'Cloud Sandbox Preview' } = {}) {
199
213
  const dir = String(argv.snapshotDir || '').trim();
200
214
  if (!dir) return null;
package/src/wtt-client.js CHANGED
@@ -195,10 +195,23 @@ export class WTTClient {
195
195
  ...(options.adapter ? { adapter: options.adapter } : {}),
196
196
  ...(options.model ? { model: options.model } : {}),
197
197
  };
198
+ try {
199
+ const result = await this.action('typing', payload, 5000);
200
+ log('info', 'typing status sent via websocket', {
201
+ topicId,
202
+ state,
203
+ kind: payload.status_kind || '',
204
+ broadcast: result?.broadcast ?? '',
205
+ text: payload.status_text ? String(payload.status_text).slice(0, 80) : '',
206
+ });
207
+ return;
208
+ } catch (err) {
209
+ log('warn', 'websocket typing failed; trying HTTP fallback', { topicId, state, error: err?.message || err });
210
+ }
198
211
  if (this.config.token) {
199
212
  try {
200
213
  const result = await this.httpTyping(payload, options.timeoutMs || 5000);
201
- log('info', 'typing status sent via HTTP', {
214
+ log('info', 'typing status sent via HTTP fallback', {
202
215
  topicId,
203
216
  state,
204
217
  kind: payload.status_kind || '',
@@ -207,20 +220,10 @@ export class WTTClient {
207
220
  });
208
221
  return;
209
222
  } catch (err) {
210
- log('warn', 'HTTP typing fallback failed; trying websocket action', { topicId, state, error: err?.message || err });
223
+ log('warn', 'typing status dropped', { topicId, state, error: err?.message || err });
211
224
  }
212
- }
213
- try {
214
- const result = await this.action('typing', payload, 5000);
215
- log('info', 'typing status sent via websocket', {
216
- topicId,
217
- state,
218
- kind: payload.status_kind || '',
219
- broadcast: result?.broadcast ?? '',
220
- text: payload.status_text ? String(payload.status_text).slice(0, 80) : '',
221
- });
222
- } catch (err) {
223
- log('warn', 'typing status dropped', { topicId, state, error: err?.message || err });
225
+ } else {
226
+ log('warn', 'typing status dropped', { topicId, state, error: 'missing token for HTTP fallback' });
224
227
  }
225
228
  }
226
229