@anthonyhaussman/opencode-agy-auth 1.0.14 → 1.0.15-alpha.0
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 +19 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15610,6 +15610,22 @@ 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
|
+
const response = await agyFetch(url2, init);
|
|
15617
|
+
if (response.ok) return;
|
|
15618
|
+
if (!isRetryableStatus(response.status) || attempt === MAX_SEND_ATTEMPTS - 1) {
|
|
15619
|
+
if (response.status >= 500 && response.status < 600) {
|
|
15620
|
+
console.debug(`[Agy] ${label} failed: ${response.status} (transient, suppressed)`);
|
|
15621
|
+
} else {
|
|
15622
|
+
console.warn(`[Agy] ${label} failed: ${response.status}`);
|
|
15623
|
+
}
|
|
15624
|
+
return;
|
|
15625
|
+
}
|
|
15626
|
+
await wait2(getExponentialDelayWithJitter(attempt));
|
|
15627
|
+
}
|
|
15628
|
+
}
|
|
15613
15629
|
var lastTrafficTime = 0;
|
|
15614
15630
|
var TRAFFIC_INTERVAL_MS = 5 * 60 * 1e3;
|
|
15615
15631
|
function simulateClientBackgroundTraffic(accessToken, projectId, userAgentModel) {
|
|
@@ -15629,7 +15645,7 @@ function simulateClientBackgroundTraffic(accessToken, projectId, userAgentModel)
|
|
|
15629
15645
|
async function sendListExperiments(accessToken, userAgentModel) {
|
|
15630
15646
|
const url2 = `${AGY_CODE_ASSIST_ENDPOINT}/v1internal:listExperiments`;
|
|
15631
15647
|
const userAgent = buildAgyCliUserAgent(userAgentModel);
|
|
15632
|
-
|
|
15648
|
+
await sendWithRetry("listExperiments", url2, {
|
|
15633
15649
|
method: "POST",
|
|
15634
15650
|
headers: {
|
|
15635
15651
|
"Content-Type": "application/json",
|
|
@@ -15638,9 +15654,6 @@ async function sendListExperiments(accessToken, userAgentModel) {
|
|
|
15638
15654
|
},
|
|
15639
15655
|
body: "{}"
|
|
15640
15656
|
});
|
|
15641
|
-
if (!response.ok) {
|
|
15642
|
-
console.warn(`[Agy] listExperiments failed: ${response.status}`);
|
|
15643
|
-
}
|
|
15644
15657
|
}
|
|
15645
15658
|
async function sendCodeAssistMetrics(accessToken, projectId, userAgentModel) {
|
|
15646
15659
|
const url2 = `${AGY_CODE_ASSIST_ENDPOINT}/v1internal:recordCodeAssistMetrics`;
|
|
@@ -15688,7 +15701,7 @@ async function sendCodeAssistMetrics(accessToken, projectId, userAgentModel) {
|
|
|
15688
15701
|
}
|
|
15689
15702
|
]
|
|
15690
15703
|
};
|
|
15691
|
-
|
|
15704
|
+
await sendWithRetry("recordCodeAssistMetrics", url2, {
|
|
15692
15705
|
method: "POST",
|
|
15693
15706
|
headers: {
|
|
15694
15707
|
"Content-Type": "application/json",
|
|
@@ -15697,9 +15710,6 @@ async function sendCodeAssistMetrics(accessToken, projectId, userAgentModel) {
|
|
|
15697
15710
|
},
|
|
15698
15711
|
body: JSON.stringify(body)
|
|
15699
15712
|
});
|
|
15700
|
-
if (!response.ok) {
|
|
15701
|
-
console.warn(`[Agy] recordCodeAssistMetrics failed: ${response.status}`);
|
|
15702
|
-
}
|
|
15703
15713
|
}
|
|
15704
15714
|
async function sendTrajectoryAnalytics(accessToken, userAgentModel) {
|
|
15705
15715
|
const url2 = `${AGY_CODE_ASSIST_ENDPOINT}/v1internal:recordTrajectoryAnalytics`;
|
|
@@ -15719,7 +15729,7 @@ async function sendTrajectoryAnalytics(accessToken, userAgentModel) {
|
|
|
15719
15729
|
const a = archMap[arch2] || "UNSPECIFIED";
|
|
15720
15730
|
const platform2 = `${p}_${a}`;
|
|
15721
15731
|
const body = buildTrajectoryAnalyticsBody(randomUUID(), platform2);
|
|
15722
|
-
|
|
15732
|
+
await sendWithRetry("recordTrajectoryAnalytics", url2, {
|
|
15723
15733
|
method: "POST",
|
|
15724
15734
|
headers: {
|
|
15725
15735
|
"Content-Type": "application/json",
|
|
@@ -15728,9 +15738,6 @@ async function sendTrajectoryAnalytics(accessToken, userAgentModel) {
|
|
|
15728
15738
|
},
|
|
15729
15739
|
body: JSON.stringify(body)
|
|
15730
15740
|
});
|
|
15731
|
-
if (!response.ok) {
|
|
15732
|
-
console.warn(`[Agy] recordTrajectoryAnalytics failed: ${response.status}`);
|
|
15733
|
-
}
|
|
15734
15741
|
}
|
|
15735
15742
|
function buildTrajectoryAnalyticsBody(cascadeId = randomUUID(), platform2 = "DARWIN_AMD64") {
|
|
15736
15743
|
return {
|