fluxy-bot 0.5.50 → 0.5.51

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": "fluxy-bot",
3
- "version": "0.5.50",
3
+ "version": "0.5.51",
4
4
  "releaseNotes": [
5
5
  "Fixed some bugs to iOs ",
6
6
  "2. ",
@@ -973,8 +973,17 @@ export default function OnboardWizard({ onComplete, isInitialSetup = false, onSa
973
973
  {provider === 'anthropic' && (
974
974
  <div className="space-y-2.5">
975
975
  {isConnected && (
976
- <div className="bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5">
977
- <p className="text-emerald-400/90 text-[12px]">Connected Anthropic subscription is active.</p>
976
+ <div className="space-y-2.5">
977
+ <div className="bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5">
978
+ <p className="text-emerald-400/90 text-[12px]">Connected — Anthropic subscription is active.</p>
979
+ </div>
980
+ <button
981
+ onClick={() => { setAuthState((s) => ({ ...s, anthropic: 'idle' })); setOauthStarted(false); setAnthropicCode(''); setAnthropicError(''); }}
982
+ className="w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5"
983
+ >
984
+ <RefreshCw className="h-3 w-3" />
985
+ Re-authenticate
986
+ </button>
978
987
  </div>
979
988
  )}
980
989
 
@@ -1056,8 +1065,17 @@ export default function OnboardWizard({ onComplete, isInitialSetup = false, onSa
1056
1065
  {provider === 'openai' && (
1057
1066
  <div className="space-y-2.5">
1058
1067
  {isConnected && (
1059
- <div className="bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5">
1060
- <p className="text-emerald-400/90 text-[12px]">Connected ChatGPT subscription is active.</p>
1068
+ <div className="space-y-2.5">
1069
+ <div className="bg-emerald-500/8 border border-emerald-500/15 rounded-lg px-3.5 py-2.5">
1070
+ <p className="text-emerald-400/90 text-[12px]">Connected — ChatGPT subscription is active.</p>
1071
+ </div>
1072
+ <button
1073
+ onClick={() => { setAuthState((s) => ({ ...s, openai: 'idle' })); setOpenaiError(''); }}
1074
+ className="w-full py-1.5 text-white/25 text-[11px] hover:text-white/40 transition-colors flex items-center justify-center gap-1.5"
1075
+ >
1076
+ <RefreshCw className="h-3 w-3" />
1077
+ Re-authenticate
1078
+ </button>
1061
1079
  </div>
1062
1080
  )}
1063
1081
 
@@ -146,6 +146,7 @@ export async function startFluxyAgentQuery(
146
146
 
147
147
  let fullText = '';
148
148
  const usedTools = new Set<string>();
149
+ let stderrBuf = '';
149
150
 
150
151
  // If there are saved files but no inline attachments, append path info to plain text prompt
151
152
  let plainPrompt = prompt;
@@ -188,7 +189,6 @@ export async function startFluxyAgentQuery(
188
189
  }
189
190
  } catch {}
190
191
 
191
- let stderrBuf = '';
192
192
  const claudeQuery = query({
193
193
  prompt: sdkPrompt,
194
194
  options: {
@@ -762,36 +762,20 @@ export async function startSupervisor() {
762
762
  config.tunnelUrl = tunnelUrl;
763
763
  saveConfig(config);
764
764
 
765
- // Register tunnel URL with relay and start heartbeats
766
- if (config.relay?.token) {
767
- try {
768
- await updateTunnelUrl(config.relay.token, tunnelUrl);
769
- startHeartbeat(config.relay.token, tunnelUrl);
770
- if (config.relay.url) {
771
- log.ok(`Relay: ${config.relay.url}`);
772
- console.log(`__RELAY_URL__=${config.relay.url}`);
773
- }
774
- } catch (err) {
775
- log.warn(`Relay: ${err instanceof Error ? err.message : err}`);
776
- }
777
- }
778
-
779
- // Poll until the full relay→tunnel→server chain is actually working.
780
- // A 502/503 means the relay can't reach the tunnel yet; anything else
781
- // (200, 401, 403, etc.) means the chain is live.
782
- const probeUrl = config.relay?.url || tunnelUrl;
783
- let ready = false;
784
- log.info(`Readiness probe: polling ${probeUrl}`);
765
+ // Wait for the tunnel to be reachable before telling the relay about it.
766
+ // This prevents the relay from proxying traffic to a tunnel that isn't ready,
767
+ // which would cause 502s for users on the custom domain.
768
+ let tunnelReady = false;
769
+ log.info(`Readiness probe: waiting for tunnel ${tunnelUrl}`);
785
770
  for (let i = 0; i < 30; i++) {
786
771
  try {
787
- const res = await fetch(probeUrl + `/api/health?_cb=${Date.now()}`, {
772
+ const res = await fetch(tunnelUrl + `/api/health?_cb=${Date.now()}`, {
788
773
  signal: AbortSignal.timeout(3000),
789
774
  headers: { 'Cache-Control': 'no-cache, no-store' },
790
775
  });
791
776
  log.info(`Readiness probe #${i + 1}: ${res.status}`);
792
- // Any non-502/503 means the relay is reaching the tunnel
793
777
  if (res.status !== 502 && res.status !== 503) {
794
- ready = true;
778
+ tunnelReady = true;
795
779
  break;
796
780
  }
797
781
  } catch (err) {
@@ -799,8 +783,22 @@ export async function startSupervisor() {
799
783
  }
800
784
  await new Promise(r => setTimeout(r, 1000));
801
785
  }
802
- if (!ready) {
803
- log.warn('Readiness probe timed out — URL may not be reachable yet');
786
+ if (!tunnelReady) {
787
+ log.warn('Tunnel readiness probe timed out — updating relay anyway');
788
+ }
789
+
790
+ // Now register tunnel URL with relay and start heartbeats
791
+ if (config.relay?.token) {
792
+ try {
793
+ await updateTunnelUrl(config.relay.token, tunnelUrl);
794
+ startHeartbeat(config.relay.token, tunnelUrl);
795
+ if (config.relay.url) {
796
+ log.ok(`Relay: ${config.relay.url}`);
797
+ console.log(`__RELAY_URL__=${config.relay.url}`);
798
+ }
799
+ } catch (err) {
800
+ log.warn(`Relay: ${err instanceof Error ? err.message : err}`);
801
+ }
804
802
  }
805
803
  console.log('__READY__');
806
804
  } catch (err) {
@@ -826,6 +824,28 @@ export async function startSupervisor() {
826
824
  log.warn('Tunnel dead, restarting...');
827
825
  try {
828
826
  const newUrl = await restartTunnel(config.port);
827
+
828
+ // Wait for the new tunnel to be reachable before updating the relay
829
+ log.info(`Waiting for new tunnel to become reachable: ${newUrl}`);
830
+ let tunnelReady = false;
831
+ for (let i = 0; i < 30; i++) {
832
+ try {
833
+ const res = await fetch(newUrl + `/api/health?_cb=${Date.now()}`, {
834
+ signal: AbortSignal.timeout(3000),
835
+ headers: { 'Cache-Control': 'no-cache, no-store' },
836
+ });
837
+ if (res.status !== 502 && res.status !== 503) {
838
+ tunnelReady = true;
839
+ log.info(`Tunnel reachable after ${i + 1} probes`);
840
+ break;
841
+ }
842
+ } catch {}
843
+ await new Promise(r => setTimeout(r, 1000));
844
+ }
845
+ if (!tunnelReady) {
846
+ log.warn('Tunnel readiness probe timed out — updating relay anyway');
847
+ }
848
+
829
849
  tunnelUrl = newUrl;
830
850
  config.tunnelUrl = newUrl;
831
851
  saveConfig(config);