traderclaw-cli 1.0.77 → 1.0.78

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.
@@ -2158,6 +2158,16 @@ function wizardHtml(defaults) {
2158
2158
  <button type="button" id="oauthRetryBtn" class="secondary hidden">Try sign-in again</button>
2159
2159
  </div>
2160
2160
  <p id="oauthFlowStatus" class="muted" style="margin-top:8px;" aria-live="polite">Choose OAuth and wait a moment. We will prepare your sign-in automatically.</p>
2161
+ <div id="oauthFallbackPaste" class="hidden" style="margin-top:12px;padding:12px;background:#111827;border:1px solid #334a87;border-radius:8px;">
2162
+ <p class="muted" style="margin:0 0 8px;font-size:13px;color:#ffcc70;">
2163
+ <strong>Redirect didn't reach us?</strong> Copy the full URL from the error page in your browser (it starts with <code>http://localhost:1455/auth/callback?code=…</code>) and paste it below.
2164
+ </p>
2165
+ <div style="display:flex;gap:8px;">
2166
+ <input id="oauthFallbackUrlInput" type="text" placeholder="Paste the full localhost:1455/auth/callback?code=… URL here" style="flex:1;font-size:12px;padding:8px 10px;border-radius:6px;border:1px solid #334a87;background:#0a1224;color:#e0e8ff;">
2167
+ <button type="button" id="oauthFallbackSubmitBtn" class="secondary" style="padding:8px 14px;white-space:nowrap;">Submit URL</button>
2168
+ </div>
2169
+ <p id="oauthFallbackError" class="muted hidden" style="margin:6px 0 0;font-size:12px;color:#ff6b6b;"></p>
2170
+ </div>
2161
2171
  </div>
2162
2172
  </div>
2163
2173
  <p class="muted" id="llmLoadState" aria-live="polite">Loading LLM provider catalog...</p>
@@ -2344,6 +2354,11 @@ function wizardHtml(defaults) {
2344
2354
  const oauthStepOpen = document.getElementById("oauthStepOpen");
2345
2355
  const oauthStepComplete = document.getElementById("oauthStepComplete");
2346
2356
  const oauthStepVerify = document.getElementById("oauthStepVerify");
2357
+ const oauthFallbackPaste = document.getElementById("oauthFallbackPaste");
2358
+ const oauthFallbackUrlInput = document.getElementById("oauthFallbackUrlInput");
2359
+ const oauthFallbackSubmitBtn = document.getElementById("oauthFallbackSubmitBtn");
2360
+ const oauthFallbackError = document.getElementById("oauthFallbackError");
2361
+ let oauthFallbackTimer = null;
2347
2362
 
2348
2363
  function setOauthStep(stepEl, mode) {
2349
2364
  if (!stepEl) return;
@@ -2402,8 +2417,25 @@ function wizardHtml(defaults) {
2402
2417
  oauthSessionId = null;
2403
2418
  }
2404
2419
 
2420
+ function hideFallbackPaste() {
2421
+ if (oauthFallbackPaste) oauthFallbackPaste.classList.add("hidden");
2422
+ if (oauthFallbackUrlInput) oauthFallbackUrlInput.value = "";
2423
+ if (oauthFallbackError) { oauthFallbackError.textContent = ""; oauthFallbackError.classList.add("hidden"); }
2424
+ if (oauthFallbackTimer) { clearTimeout(oauthFallbackTimer); oauthFallbackTimer = null; }
2425
+ }
2426
+
2427
+ function showFallbackPasteAfterDelay(ms) {
2428
+ hideFallbackPaste();
2429
+ oauthFallbackTimer = setTimeout(() => {
2430
+ if (oauthFallbackPaste && oauthSessionId && oauthOpenedInBrowser && !oauthWizardLoginDone) {
2431
+ oauthFallbackPaste.classList.remove("hidden");
2432
+ }
2433
+ }, ms);
2434
+ }
2435
+
2405
2436
  function resetOauthWizardState() {
2406
2437
  stopOauthPolling();
2438
+ hideFallbackPaste();
2407
2439
  oauthSessionId = null;
2408
2440
  oauthWizardLoginDone = false;
2409
2441
  oauthStartInFlight = false;
@@ -2526,6 +2558,7 @@ function wizardHtml(defaults) {
2526
2558
  if (state === "succeeded") {
2527
2559
  oauthWizardLoginDone = true;
2528
2560
  oauthSessionId = null;
2561
+ hideFallbackPaste();
2529
2562
  setOauthStep(oauthStepPrepare, "done");
2530
2563
  setOauthStep(oauthStepOpen, "done");
2531
2564
  setOauthStep(oauthStepComplete, "done");
@@ -3068,7 +3101,49 @@ function wizardHtml(defaults) {
3068
3101
  setOauthStep(oauthStepOpen, "done");
3069
3102
  setOauthStep(oauthStepComplete, "active");
3070
3103
  setOauthStep(oauthStepVerify, "active");
3071
- setOauthStatus("Complete ChatGPT approval in this same browser, then return here. We detect completion automatically.");
3104
+ setOauthStatus("Complete ChatGPT approval in this browser, then return here. We detect completion automatically.");
3105
+ showFallbackPasteAfterDelay(15_000);
3106
+ });
3107
+ }
3108
+
3109
+ if (oauthFallbackSubmitBtn) {
3110
+ oauthFallbackSubmitBtn.addEventListener("click", async () => {
3111
+ const raw = (oauthFallbackUrlInput && oauthFallbackUrlInput.value || "").trim();
3112
+ if (!raw || !raw.includes("code=")) {
3113
+ if (oauthFallbackError) {
3114
+ oauthFallbackError.textContent = "Paste the full URL from the browser address bar. It must contain code=…";
3115
+ oauthFallbackError.classList.remove("hidden");
3116
+ }
3117
+ return;
3118
+ }
3119
+ if (oauthFallbackError) oauthFallbackError.classList.add("hidden");
3120
+ oauthFallbackSubmitBtn.disabled = true;
3121
+ oauthFallbackSubmitBtn.textContent = "Submitting…";
3122
+ try {
3123
+ const res = await fetch("/api/llm/oauth/submit-callback-url", {
3124
+ method: "POST",
3125
+ headers: { "content-type": "application/json" },
3126
+ body: JSON.stringify({ sessionId: oauthSessionId, callbackUrl: raw }),
3127
+ });
3128
+ const data = await res.json().catch(() => ({}));
3129
+ if (res.ok && data.ok) {
3130
+ hideFallbackPaste();
3131
+ setOauthStatus("Callback received! Waiting for OpenClaw to finish…", false);
3132
+ } else {
3133
+ if (oauthFallbackError) {
3134
+ oauthFallbackError.textContent = data.message || data.error || "Could not submit the URL. Try again.";
3135
+ oauthFallbackError.classList.remove("hidden");
3136
+ }
3137
+ }
3138
+ } catch (err) {
3139
+ if (oauthFallbackError) {
3140
+ oauthFallbackError.textContent = err.message || "Request failed.";
3141
+ oauthFallbackError.classList.remove("hidden");
3142
+ }
3143
+ } finally {
3144
+ oauthFallbackSubmitBtn.disabled = false;
3145
+ oauthFallbackSubmitBtn.textContent = "Submit URL";
3146
+ }
3072
3147
  });
3073
3148
  }
3074
3149
 
@@ -3486,6 +3561,41 @@ async function cmdInstall(args) {
3486
3561
  return;
3487
3562
  }
3488
3563
 
3564
+ if (req.method === "POST" && req.url === "/api/llm/oauth/submit-callback-url") {
3565
+ const body = await parseJsonBody(req).catch(() => ({}));
3566
+ const sessionId = typeof body.sessionId === "string" ? body.sessionId : "";
3567
+ const callbackUrl = typeof body.callbackUrl === "string" ? body.callbackUrl.trim() : "";
3568
+ if (!callbackUrl || !callbackUrl.includes("code=")) {
3569
+ respondJson(400, { ok: false, error: "invalid_url", message: "URL must contain a code= parameter." });
3570
+ return;
3571
+ }
3572
+ const s = sessionId ? oauthSessions.get(sessionId) : findActiveOauthSession();
3573
+ if (!s || !s.child) {
3574
+ respondJson(404, { ok: false, error: "no_active_session", message: "No active OAuth session. Click Try sign-in again." });
3575
+ return;
3576
+ }
3577
+ try {
3578
+ if (s.child.stdin && !s.child.stdin.writableEnded && !s.child.stdin.destroyed) {
3579
+ s.child.stdin.write(`${callbackUrl}\n`, () => {
3580
+ setTimeout(() => {
3581
+ try {
3582
+ if (s.child && s.child.stdin && !s.child.stdin.destroyed && !s.child.stdin.writableEnded) {
3583
+ s.child.stdin.end();
3584
+ }
3585
+ } catch { /* ignore */ }
3586
+ }, 100);
3587
+ });
3588
+ s.updatedAt = Date.now();
3589
+ respondJson(200, { ok: true, message: "Callback URL submitted. Waiting for OpenClaw to complete…" });
3590
+ } else {
3591
+ respondJson(500, { ok: false, error: "stdin_closed", message: "OpenClaw process stdin is closed. Click Try sign-in again." });
3592
+ }
3593
+ } catch (err) {
3594
+ respondJson(500, { ok: false, error: "write_error", message: err.message || "Failed to write to OpenClaw." });
3595
+ }
3596
+ return;
3597
+ }
3598
+
3489
3599
  if (req.method === "POST" && req.url === "/api/llm/oauth/cancel") {
3490
3600
  const body = await parseJsonBody(req).catch(() => ({}));
3491
3601
  const sessionId = typeof body.sessionId === "string" ? body.sessionId : "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "traderclaw-cli",
3
- "version": "1.0.77",
3
+ "version": "1.0.78",
4
4
  "description": "Global TraderClaw CLI (install --wizard, setup, precheck). Installs solana-traderclaw as a dependency for OpenClaw plugin files.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
  "node": ">=22"
18
18
  },
19
19
  "dependencies": {
20
- "solana-traderclaw": "^1.0.77"
20
+ "solana-traderclaw": "^1.0.78"
21
21
  },
22
22
  "keywords": [
23
23
  "traderclaw",