@algolia/wizard 0.104.0 → 0.106.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/main.js +23 -5
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1706,7 +1706,9 @@ function tokenCount(value = NO_TOKENS) {
|
|
|
1706
1706
|
return value;
|
|
1707
1707
|
}
|
|
1708
1708
|
function estimateModelCost(profileName, usage) {
|
|
1709
|
-
|
|
1709
|
+
return estimateCostFromPrices(getModelProfile(profileName).prices, usage);
|
|
1710
|
+
}
|
|
1711
|
+
function estimateCostFromPrices(prices, usage) {
|
|
1710
1712
|
const inputDetails = Object.assign({}, usage.inputTokenDetails);
|
|
1711
1713
|
const cacheRead = tokenCount(inputDetails.cacheReadTokens);
|
|
1712
1714
|
const cacheWrite = tokenCount(inputDetails.cacheWriteTokens);
|
|
@@ -2467,7 +2469,7 @@ async function ensureApplication(resumeAppId) {
|
|
|
2467
2469
|
// package.json
|
|
2468
2470
|
var package_default = {
|
|
2469
2471
|
name: "@algolia/wizard",
|
|
2470
|
-
version: "0.
|
|
2472
|
+
version: "0.106.0",
|
|
2471
2473
|
description: "Magically implement Algolia functionality in your codebase",
|
|
2472
2474
|
type: "module",
|
|
2473
2475
|
engines: {
|
|
@@ -5469,11 +5471,25 @@ var ATTEMPT_NUMBER_OFFSET = 1;
|
|
|
5469
5471
|
var INITIAL_ATTEMPT = 0;
|
|
5470
5472
|
var PROVIDER_ERROR_USER_MESSAGE = "The AI service had trouble responding. Run the wizard again to retry this step.";
|
|
5471
5473
|
var SESSION_TIMEOUT_USER_MESSAGE = "The wizard session timed out after a period of inactivity. Run the wizard again to retry this step.";
|
|
5474
|
+
var USER_BUDGET_USER_MESSAGE = "You reached the daily AI usage limit of the wizard. Try again tomorrow.";
|
|
5475
|
+
var GLOBAL_BUDGET_USER_MESSAGE = "The wizard reached its daily AI usage limit for all users. Try again tomorrow.";
|
|
5472
5476
|
var PROXY_AUTH_REJECTED_HEADER2 = "x-wizard-proxy-auth";
|
|
5473
5477
|
var PROXY_REJECTION_BODY = "You shall not pass!";
|
|
5474
|
-
|
|
5478
|
+
var BUDGET_EXCEEDED_HEADER = "x-wizard-budget-exceeded";
|
|
5479
|
+
function lastCallError(err) {
|
|
5475
5480
|
const cause = RetryError.isInstance(err) ? err.lastError : err;
|
|
5476
|
-
return APICallError.isInstance(cause)
|
|
5481
|
+
return APICallError.isInstance(cause) ? cause : void 0;
|
|
5482
|
+
}
|
|
5483
|
+
function isProxyInactivityRejection(err) {
|
|
5484
|
+
const cause = lastCallError(err);
|
|
5485
|
+
return cause?.statusCode === 401 && cause.responseBody === PROXY_REJECTION_BODY && cause.responseHeaders?.[PROXY_AUTH_REJECTED_HEADER2] === void 0;
|
|
5486
|
+
}
|
|
5487
|
+
function budgetExceededMessage(err) {
|
|
5488
|
+
const cause = lastCallError(err);
|
|
5489
|
+
const scope = cause?.responseHeaders?.[BUDGET_EXCEEDED_HEADER];
|
|
5490
|
+
if (scope === "user") return USER_BUDGET_USER_MESSAGE;
|
|
5491
|
+
if (scope === "global") return GLOBAL_BUDGET_USER_MESSAGE;
|
|
5492
|
+
return void 0;
|
|
5477
5493
|
}
|
|
5478
5494
|
var INCOMPLETE_CAUSES = {
|
|
5479
5495
|
stepLimit: {
|
|
@@ -5726,6 +5742,8 @@ async function runAgentAttempt(req, attempt, retryReason, continuation) {
|
|
|
5726
5742
|
if (isProxyInactivityRejection(streamError)) {
|
|
5727
5743
|
throw new Error(SESSION_TIMEOUT_USER_MESSAGE, { cause: streamError });
|
|
5728
5744
|
}
|
|
5745
|
+
const budgetMessage = budgetExceededMessage(streamError);
|
|
5746
|
+
if (budgetMessage) throw new Error(budgetMessage, { cause: streamError });
|
|
5729
5747
|
throw streamError;
|
|
5730
5748
|
}
|
|
5731
5749
|
const end = Date.now();
|
|
@@ -10180,7 +10198,7 @@ async function resetProjectState() {
|
|
|
10180
10198
|
// package.json with { type: 'json' }
|
|
10181
10199
|
var package_default2 = {
|
|
10182
10200
|
name: "@algolia/wizard",
|
|
10183
|
-
version: "0.
|
|
10201
|
+
version: "0.106.0",
|
|
10184
10202
|
description: "Magically implement Algolia functionality in your codebase",
|
|
10185
10203
|
type: "module",
|
|
10186
10204
|
engines: {
|