neoagent 2.3.1-beta.14 → 2.3.1-beta.15
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/lib/manager.js +49 -10
- package/package.json +1 -1
- package/server/public/flutter_bootstrap.js +1 -1
package/lib/manager.js
CHANGED
|
@@ -763,6 +763,8 @@ async function cmdLogin(args = []) {
|
|
|
763
763
|
const startTime = Date.now();
|
|
764
764
|
const timeoutMs = 15 * 60 * 1000;
|
|
765
765
|
let currentPollInterval = (interval || 5) * 1000;
|
|
766
|
+
let authorizationCode = null;
|
|
767
|
+
let codeVerifier = null;
|
|
766
768
|
|
|
767
769
|
while (Date.now() - startTime < timeoutMs) {
|
|
768
770
|
await new Promise((r) => setTimeout(r, currentPollInterval));
|
|
@@ -775,25 +777,62 @@ async function cmdLogin(args = []) {
|
|
|
775
777
|
})
|
|
776
778
|
});
|
|
777
779
|
|
|
780
|
+
if (tokenRes.status === 403 || tokenRes.status === 404) {
|
|
781
|
+
// These statuses are returned by OpenAI while authorization is pending
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
|
|
778
785
|
if (!tokenRes.ok) {
|
|
779
786
|
const errorText = await tokenRes.text().catch(() => 'Unknown error');
|
|
780
787
|
throw new Error(`OpenAI token request failed: HTTP ${tokenRes.status} - ${errorText}`);
|
|
781
788
|
}
|
|
782
789
|
|
|
783
|
-
const
|
|
784
|
-
if (
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
} else if (
|
|
790
|
+
const pollData = await tokenRes.json();
|
|
791
|
+
if (pollData.authorization_code && pollData.code_verifier) {
|
|
792
|
+
authorizationCode = pollData.authorization_code;
|
|
793
|
+
codeVerifier = pollData.code_verifier;
|
|
794
|
+
break;
|
|
795
|
+
} else if (pollData.error === 'authorization_pending') {
|
|
789
796
|
// Continue polling
|
|
790
|
-
} else if (
|
|
797
|
+
} else if (pollData.error === 'slow_down') {
|
|
791
798
|
currentPollInterval += 5000;
|
|
792
|
-
} else if (
|
|
793
|
-
throw new Error(`Authentication failed: ${
|
|
799
|
+
} else if (pollData.error) {
|
|
800
|
+
throw new Error(`Authentication failed: ${pollData.error_description || pollData.error}`);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
if (!authorizationCode || !codeVerifier) {
|
|
805
|
+
throw new Error('OpenAI authentication timed out after 15 minutes.');
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
logInfo('Exchanging authorization code for access token...');
|
|
809
|
+
const exchangeRes = await fetch('https://auth.openai.com/oauth/token', {
|
|
810
|
+
method: 'POST',
|
|
811
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
812
|
+
body: new URLSearchParams({
|
|
813
|
+
grant_type: 'authorization_code',
|
|
814
|
+
code: authorizationCode,
|
|
815
|
+
redirect_uri: 'https://auth.openai.com/deviceauth/callback',
|
|
816
|
+
client_id: clientId,
|
|
817
|
+
code_verifier: codeVerifier
|
|
818
|
+
})
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
if (!exchangeRes.ok) {
|
|
822
|
+
const errorText = await exchangeRes.text().catch(() => 'Unknown error');
|
|
823
|
+
throw new Error(`OpenAI token exchange failed: HTTP ${exchangeRes.status} - ${errorText}`);
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
const exchangeData = await exchangeRes.json();
|
|
827
|
+
if (exchangeData.access_token) {
|
|
828
|
+
upsertEnvValue('OPENAI_CODEX_ACCESS_TOKEN', exchangeData.access_token);
|
|
829
|
+
if (exchangeData.refresh_token) {
|
|
830
|
+
upsertEnvValue('OPENAI_CODEX_REFRESH_TOKEN', exchangeData.refresh_token);
|
|
794
831
|
}
|
|
832
|
+
logOk('Successfully authenticated and saved OpenAI Codex tokens to .env');
|
|
833
|
+
} else {
|
|
834
|
+
throw new Error('OpenAI token exchange succeeded but did not return an access token.');
|
|
795
835
|
}
|
|
796
|
-
throw new Error('OpenAI authentication timed out after 15 minutes.');
|
|
797
836
|
}
|
|
798
837
|
}
|
|
799
838
|
|
package/package.json
CHANGED
|
@@ -37,6 +37,6 @@ _flutter.buildConfig = {"engineRevision":"59aa584fdf100e6c78c785d8a5b565d1de4b48
|
|
|
37
37
|
|
|
38
38
|
_flutter.loader.load({
|
|
39
39
|
serviceWorkerSettings: {
|
|
40
|
-
serviceWorkerVersion: "
|
|
40
|
+
serviceWorkerVersion: "3977022641" /* Flutter's service worker is deprecated and will be removed in a future Flutter release. */
|
|
41
41
|
}
|
|
42
42
|
});
|