chofex-cli 0.1.192 → 0.1.193
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 +20 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -59728,7 +59728,9 @@ var resolveAuthentication = (suppliedToken, campaignAttribution, authenticate, f
|
|
|
59728
59728
|
catch: (error2) => cliError("AUTHENTICATION_REQUIRED", String(error2), false)
|
|
59729
59729
|
});
|
|
59730
59730
|
};
|
|
59731
|
-
var
|
|
59731
|
+
var defaultRequestTimeoutMs = 20000;
|
|
59732
|
+
var challengeEvaluateRequestTimeoutMs = 30000;
|
|
59733
|
+
var sendRequest = (options, path4, init, credentials, timeoutMs = defaultRequestTimeoutMs) => exports_Effect.tryPromise({
|
|
59732
59734
|
try: () => {
|
|
59733
59735
|
const headers = new Headers(init.headers);
|
|
59734
59736
|
headers.set("accept", "application/json");
|
|
@@ -59747,7 +59749,7 @@ var sendRequest = (options, path4, init, credentials) => exports_Effect.tryPromi
|
|
|
59747
59749
|
return fetch(endpoint(options.apiUrl, path4), {
|
|
59748
59750
|
...init,
|
|
59749
59751
|
headers,
|
|
59750
|
-
signal: AbortSignal.timeout(
|
|
59752
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
59751
59753
|
});
|
|
59752
59754
|
},
|
|
59753
59755
|
catch: (error2) => cliError("NETWORK_ERROR", `Could not reach the registration API: ${String(error2)}`, true)
|
|
@@ -59766,15 +59768,15 @@ var decodeHttpBody = exports_Effect.fn("decodeHttpBody")(function* (response, de
|
|
|
59766
59768
|
}
|
|
59767
59769
|
return yield* decodeResponse(body).pipe(exports_Effect.mapError((error2) => cliError("INVALID_API_RESPONSE", "The API response did not match protocol version 1", false, { issues: String(error2) })));
|
|
59768
59770
|
});
|
|
59769
|
-
var request3 = exports_Effect.fn("apiRequest")(function* (options, path4, init, decodeResponse) {
|
|
59771
|
+
var request3 = exports_Effect.fn("apiRequest")(function* (options, path4, init, decodeResponse, timeoutMs = defaultRequestTimeoutMs) {
|
|
59770
59772
|
const suppliedToken = options.token ?? process.env.CHOFEX_TOKEN;
|
|
59771
59773
|
const authenticate = options.authenticate ?? authentication;
|
|
59772
59774
|
const credentials = yield* resolveAuthentication(suppliedToken, options.campaignAttribution, authenticate);
|
|
59773
|
-
let response = yield* sendRequest(options, path4, init, credentials);
|
|
59775
|
+
let response = yield* sendRequest(options, path4, init, credentials, timeoutMs);
|
|
59774
59776
|
if (response.status === 401 && !suppliedToken) {
|
|
59775
59777
|
const refreshed = yield* resolveAuthentication(undefined, undefined, authenticate, true).pipe(exports_Effect.map((value3) => ({ ok: true, value: value3 })), exports_Effect.catch(() => exports_Effect.succeed({ ok: false })));
|
|
59776
59778
|
if (refreshed.ok) {
|
|
59777
|
-
response = yield* sendRequest(options, path4, init, refreshed.value);
|
|
59779
|
+
response = yield* sendRequest(options, path4, init, refreshed.value, timeoutMs);
|
|
59778
59780
|
}
|
|
59779
59781
|
}
|
|
59780
59782
|
return yield* decodeHttpBody(response, decodeResponse);
|
|
@@ -59810,7 +59812,7 @@ var listChallenges = (options) => publicRequest(options, "/api/v1/challenges", {
|
|
|
59810
59812
|
var getChallengeAttempt = (options, slug) => request3(options, `/api/v1/challenges/${slug}`, { method: "GET" }, decodeChallengeAttempt);
|
|
59811
59813
|
var queryChallenge = (options, slug, input) => request3(options, `/api/v1/challenges/${slug}/query`, { method: "POST", body: JSON.stringify(input) }, decodeChallengeQuery);
|
|
59812
59814
|
var testChallenge = (options, slug, input) => request3(options, `/api/v1/challenges/${slug}/test`, { method: "POST", body: JSON.stringify(input) }, decodeChallengeTest);
|
|
59813
|
-
var evaluateChallenge = (options, slug, input) => request3(options, `/api/v1/challenges/${slug}/evaluate`, { method: "POST", body: JSON.stringify(input) }, decodeChallengeEvaluation);
|
|
59815
|
+
var evaluateChallenge = (options, slug, input) => request3(options, `/api/v1/challenges/${slug}/evaluate`, { method: "POST", body: JSON.stringify(input) }, decodeChallengeEvaluation, challengeEvaluateRequestTimeoutMs);
|
|
59814
59816
|
var getChallengeRanking = (options, slug) => publicRequest(options, `/api/v1/challenges/${slug}/ranking`, { method: "GET" }, decodeChallengeRanking);
|
|
59815
59817
|
|
|
59816
59818
|
// src/challenge-input.ts
|
|
@@ -61111,7 +61113,18 @@ var optionalString = (name, description) => exports_Flag.string(name).pipe(expor
|
|
|
61111
61113
|
var challengeFlag = exports_Flag.string("challenge").pipe(exports_Flag.withDefault(defaultChallengeSlug), exports_Flag.withDescription("Challenge slug (default: broken-agent)"));
|
|
61112
61114
|
var sourceFlag = optionalString("source", "JavaScript challenge solution file");
|
|
61113
61115
|
var reviewFlag = optionalString("review", "Participant-authored Broken Agent engineering review JSON");
|
|
61116
|
+
var officialEvaluateRetryCommand = "chofex challenge evaluate --challenge broken-agent --source ./scheduler.js --review ./review.json";
|
|
61114
61117
|
var evaluationErrorText = (error2) => {
|
|
61118
|
+
if (error2.code === "CHALLENGE_ENGINE_UNAVAILABLE") {
|
|
61119
|
+
return [
|
|
61120
|
+
"La evaluación oficial no se pudo completar.",
|
|
61121
|
+
"No es un error de tu computadora, y este intento no se consumió.",
|
|
61122
|
+
"",
|
|
61123
|
+
"Vuelve a ejecutar el mismo comando en unos segundos:",
|
|
61124
|
+
` ${officialEvaluateRetryCommand}`
|
|
61125
|
+
].join(`
|
|
61126
|
+
`);
|
|
61127
|
+
}
|
|
61115
61128
|
if (error2.code !== "HUMAN_APPROVAL_REQUIRED")
|
|
61116
61129
|
return;
|
|
61117
61130
|
if (!error2.details || typeof error2.details !== "object")
|
|
@@ -61119,7 +61132,7 @@ var evaluationErrorText = (error2) => {
|
|
|
61119
61132
|
const details = error2.details;
|
|
61120
61133
|
if (typeof details.approvalUrl !== "string")
|
|
61121
61134
|
return;
|
|
61122
|
-
let retryCommand =
|
|
61135
|
+
let retryCommand = officialEvaluateRetryCommand;
|
|
61123
61136
|
if (typeof details.retryCommand === "string") {
|
|
61124
61137
|
retryCommand = details.retryCommand;
|
|
61125
61138
|
}
|