theclawbay 0.3.51 → 0.3.52

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.
@@ -237,6 +237,7 @@ async function createBrowserLinkedDeviceSession(params) {
237
237
  const callbackServer = await createLocalCallbackServer(state);
238
238
  const exchangeAbortController = new AbortController();
239
239
  const exchangeSignal = exchangeAbortController.signal;
240
+ let exchangeInFlight = null;
240
241
  try {
241
242
  const startResponse = await fetch(`${params.backendUrl}/api/setup/device-session/start`, {
242
243
  method: "POST",
@@ -261,25 +262,31 @@ async function createBrowserLinkedDeviceSession(params) {
261
262
  const deadlineMs = Date.now() + BROWSER_SETUP_TIMEOUT_MS;
262
263
  let fallbackNoticeShown = false;
263
264
  const timeoutError = new Error("browser setup timed out");
264
- const waitForLocalCallbackExchange = async () => {
265
- const callback = await withTimeout(callbackServer.waitForCallback(), BROWSER_SETUP_TIMEOUT_MS, exchangeSignal);
266
- return exchangeBrowserSetupSession({
265
+ const performExchange = (code) => {
266
+ if (exchangeInFlight)
267
+ return exchangeInFlight;
268
+ const promise = exchangeBrowserSetupSession({
267
269
  backendUrl: params.backendUrl,
268
- sessionId: callback.sessionId,
269
- state: callback.state,
270
- code: callback.code,
270
+ sessionId: setupSessionId,
271
+ state,
272
+ code,
273
+ });
274
+ exchangeInFlight = promise.catch((error) => {
275
+ exchangeInFlight = null;
276
+ throw error;
271
277
  });
278
+ return exchangeInFlight;
279
+ };
280
+ const waitForLocalCallbackExchange = async () => {
281
+ const callback = await withTimeout(callbackServer.waitForCallback(), BROWSER_SETUP_TIMEOUT_MS, exchangeSignal);
282
+ return performExchange(callback.code);
272
283
  };
273
284
  const waitForPolledExchange = async () => {
274
285
  while (Date.now() < deadlineMs) {
275
286
  if (exchangeSignal.aborted)
276
287
  throw createSetupAbortError();
277
288
  try {
278
- return await exchangeBrowserSetupSession({
279
- backendUrl: params.backendUrl,
280
- sessionId: setupSessionId,
281
- state,
282
- });
289
+ return await performExchange();
283
290
  }
284
291
  catch (error) {
285
292
  const message = error.message || "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "theclawbay",
3
- "version": "0.3.51",
3
+ "version": "0.3.52",
4
4
  "description": "CLI for connecting Codex, Continue, Cline, OpenClaw, OpenCode, Kilo, Roo Code, Aider, experimental Trae, and experimental Zo to The Claw Bay.",
5
5
  "license": "MIT",
6
6
  "bin": {