agent-rev 0.3.4 → 0.3.5
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/dist/utils/qwen-auth.js +16 -9
- package/package.json +1 -1
package/dist/utils/qwen-auth.js
CHANGED
|
@@ -42,14 +42,20 @@ async function loadToken() {
|
|
|
42
42
|
};
|
|
43
43
|
if (!token.accessToken)
|
|
44
44
|
return null;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
// Refresh proactivo: si vence en menos de 2 minutos (o ya venció)
|
|
46
|
+
const TWO_MIN = 2 * 60 * 1000;
|
|
47
|
+
if (token.expiresAt - Date.now() < TWO_MIN && token.refreshToken) {
|
|
48
|
+
const refreshed = await doRefreshToken(token.refreshToken);
|
|
49
|
+
if (refreshed) {
|
|
50
|
+
await saveToken(refreshed);
|
|
51
|
+
return refreshed;
|
|
52
|
+
}
|
|
53
|
+
// Si el refresh falla pero el token aún no venció del todo, seguir con él
|
|
54
|
+
if (token.expiresAt > Date.now())
|
|
55
|
+
return token;
|
|
56
|
+
return null;
|
|
51
57
|
}
|
|
52
|
-
return
|
|
58
|
+
return token;
|
|
53
59
|
}
|
|
54
60
|
catch {
|
|
55
61
|
return null;
|
|
@@ -308,8 +314,9 @@ export async function callQwenAPIFromCreds(prompt, model, credsPath) {
|
|
|
308
314
|
if (!token.accessToken) {
|
|
309
315
|
throw new Error(`Invalid credentials at ${credsPath}. Run the role binary with --login first.`);
|
|
310
316
|
}
|
|
311
|
-
// Refresh
|
|
312
|
-
|
|
317
|
+
// Refresh proactivo: si vence en menos de 2 minutos (o ya venció)
|
|
318
|
+
const TWO_MIN = 2 * 60 * 1000;
|
|
319
|
+
if (token.expiresAt - Date.now() < TWO_MIN && token.refreshToken) {
|
|
313
320
|
const refreshed = await doRefreshToken(token.refreshToken);
|
|
314
321
|
if (refreshed) {
|
|
315
322
|
token = refreshed;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"agent-rev","version":"0.3.
|
|
1
|
+
{"name":"agent-rev","version":"0.3.5","description":"agent-rev agent","type":"module","main":"./dist/index.js","files":["dist/"],"bin":{"agent-rev":"dist/index.js"},"scripts":{"build":"tsc"},"keywords":["ai","agent","cli"],"license":"MIT","dependencies":{"@anthropic-ai/sdk":"^0.39.0","@google/generative-ai":"^0.24.0","chalk":"^5.4.1","commander":"^13.1.0","open":"^11.0.0","openai":"^4.91.0"},"engines":{"node":">=18.0.0"}}
|