@anthonyhaussman/opencode-agy-auth 1.0.14 → 1.0.15-alpha.1
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/index.js +26 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15610,6 +15610,29 @@ async function maybeShowAgyTestToast(client, projectId) {
|
|
|
15610
15610
|
// src/plugin/traffic.ts
|
|
15611
15611
|
import { randomUUID } from "crypto";
|
|
15612
15612
|
import * as os2 from "os";
|
|
15613
|
+
var MAX_SEND_ATTEMPTS = 2;
|
|
15614
|
+
async function sendWithRetry(label, url2, init) {
|
|
15615
|
+
for (let attempt = 0; attempt < MAX_SEND_ATTEMPTS; attempt++) {
|
|
15616
|
+
try {
|
|
15617
|
+
const response = await agyFetch(url2, init);
|
|
15618
|
+
if (response.ok) return;
|
|
15619
|
+
if (!isRetryableStatus(response.status) || attempt === MAX_SEND_ATTEMPTS - 1) {
|
|
15620
|
+
if (response.status >= 500 && response.status < 600) {
|
|
15621
|
+
console.debug(`[Agy] ${label} failed: ${response.status} (transient, suppressed)`);
|
|
15622
|
+
} else {
|
|
15623
|
+
console.warn(`[Agy] ${label} failed: ${response.status}`);
|
|
15624
|
+
}
|
|
15625
|
+
return;
|
|
15626
|
+
}
|
|
15627
|
+
} catch (error45) {
|
|
15628
|
+
if (attempt === MAX_SEND_ATTEMPTS - 1) {
|
|
15629
|
+
console.debug(`[Agy] ${label} failed with network error: ${error45} (suppressed)`);
|
|
15630
|
+
return;
|
|
15631
|
+
}
|
|
15632
|
+
}
|
|
15633
|
+
await wait2(getExponentialDelayWithJitter(attempt + 1));
|
|
15634
|
+
}
|
|
15635
|
+
}
|
|
15613
15636
|
var lastTrafficTime = 0;
|
|
15614
15637
|
var TRAFFIC_INTERVAL_MS = 5 * 60 * 1e3;
|
|
15615
15638
|
function simulateClientBackgroundTraffic(accessToken, projectId, userAgentModel) {
|
|
@@ -15629,7 +15652,7 @@ function simulateClientBackgroundTraffic(accessToken, projectId, userAgentModel)
|
|
|
15629
15652
|
async function sendListExperiments(accessToken, userAgentModel) {
|
|
15630
15653
|
const url2 = `${AGY_CODE_ASSIST_ENDPOINT}/v1internal:listExperiments`;
|
|
15631
15654
|
const userAgent = buildAgyCliUserAgent(userAgentModel);
|
|
15632
|
-
|
|
15655
|
+
await sendWithRetry("listExperiments", url2, {
|
|
15633
15656
|
method: "POST",
|
|
15634
15657
|
headers: {
|
|
15635
15658
|
"Content-Type": "application/json",
|
|
@@ -15638,9 +15661,6 @@ async function sendListExperiments(accessToken, userAgentModel) {
|
|
|
15638
15661
|
},
|
|
15639
15662
|
body: "{}"
|
|
15640
15663
|
});
|
|
15641
|
-
if (!response.ok) {
|
|
15642
|
-
console.warn(`[Agy] listExperiments failed: ${response.status}`);
|
|
15643
|
-
}
|
|
15644
15664
|
}
|
|
15645
15665
|
async function sendCodeAssistMetrics(accessToken, projectId, userAgentModel) {
|
|
15646
15666
|
const url2 = `${AGY_CODE_ASSIST_ENDPOINT}/v1internal:recordCodeAssistMetrics`;
|
|
@@ -15688,7 +15708,7 @@ async function sendCodeAssistMetrics(accessToken, projectId, userAgentModel) {
|
|
|
15688
15708
|
}
|
|
15689
15709
|
]
|
|
15690
15710
|
};
|
|
15691
|
-
|
|
15711
|
+
await sendWithRetry("recordCodeAssistMetrics", url2, {
|
|
15692
15712
|
method: "POST",
|
|
15693
15713
|
headers: {
|
|
15694
15714
|
"Content-Type": "application/json",
|
|
@@ -15697,9 +15717,6 @@ async function sendCodeAssistMetrics(accessToken, projectId, userAgentModel) {
|
|
|
15697
15717
|
},
|
|
15698
15718
|
body: JSON.stringify(body)
|
|
15699
15719
|
});
|
|
15700
|
-
if (!response.ok) {
|
|
15701
|
-
console.warn(`[Agy] recordCodeAssistMetrics failed: ${response.status}`);
|
|
15702
|
-
}
|
|
15703
15720
|
}
|
|
15704
15721
|
async function sendTrajectoryAnalytics(accessToken, userAgentModel) {
|
|
15705
15722
|
const url2 = `${AGY_CODE_ASSIST_ENDPOINT}/v1internal:recordTrajectoryAnalytics`;
|
|
@@ -15719,7 +15736,7 @@ async function sendTrajectoryAnalytics(accessToken, userAgentModel) {
|
|
|
15719
15736
|
const a = archMap[arch2] || "UNSPECIFIED";
|
|
15720
15737
|
const platform2 = `${p}_${a}`;
|
|
15721
15738
|
const body = buildTrajectoryAnalyticsBody(randomUUID(), platform2);
|
|
15722
|
-
|
|
15739
|
+
await sendWithRetry("recordTrajectoryAnalytics", url2, {
|
|
15723
15740
|
method: "POST",
|
|
15724
15741
|
headers: {
|
|
15725
15742
|
"Content-Type": "application/json",
|
|
@@ -15728,9 +15745,6 @@ async function sendTrajectoryAnalytics(accessToken, userAgentModel) {
|
|
|
15728
15745
|
},
|
|
15729
15746
|
body: JSON.stringify(body)
|
|
15730
15747
|
});
|
|
15731
|
-
if (!response.ok) {
|
|
15732
|
-
console.warn(`[Agy] recordTrajectoryAnalytics failed: ${response.status}`);
|
|
15733
|
-
}
|
|
15734
15748
|
}
|
|
15735
15749
|
function buildTrajectoryAnalyticsBody(cascadeId = randomUUID(), platform2 = "DARWIN_AMD64") {
|
|
15736
15750
|
return {
|