@algolia/wizard 0.105.0 → 0.107.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 +26 -6
- 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.107.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();
|
|
@@ -7478,6 +7496,7 @@ async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES) {
|
|
|
7478
7496
|
ingestCommand
|
|
7479
7497
|
)
|
|
7480
7498
|
});
|
|
7499
|
+
const ingestStartedAt = Date.now();
|
|
7481
7500
|
await runIngestionAgent();
|
|
7482
7501
|
let outcome = ingestOutcome(executions, repoRoot, ingestCommand);
|
|
7483
7502
|
let failureAcknowledged = false;
|
|
@@ -7575,7 +7594,7 @@ async function implement(ctx, useCases = DEFAULT_IMPLEMENT_USE_CASES) {
|
|
|
7575
7594
|
track("AI Wizard Ingest Successful", {
|
|
7576
7595
|
data_model,
|
|
7577
7596
|
record_count: ingestRecordCount,
|
|
7578
|
-
duration_ms:
|
|
7597
|
+
duration_ms: Date.now() - ingestStartedAt,
|
|
7579
7598
|
index_name: targetIndex,
|
|
7580
7599
|
record_schema: recordSchema(sample, confirmed2?.[0]?.attributes ?? []),
|
|
7581
7600
|
attempts: ingestRunAttempts
|
|
@@ -7615,6 +7634,7 @@ ${detail}` : ""}`
|
|
|
7615
7634
|
error_type: "Ingest Records",
|
|
7616
7635
|
product_area: "AI Wizard",
|
|
7617
7636
|
attempts: ingestRunAttempts,
|
|
7637
|
+
duration_ms: Date.now() - ingestStartedAt,
|
|
7618
7638
|
...ingestAttempt?.exitCode != null ? { error_code: String(ingestAttempt.exitCode) } : {}
|
|
7619
7639
|
});
|
|
7620
7640
|
}
|
|
@@ -10180,7 +10200,7 @@ async function resetProjectState() {
|
|
|
10180
10200
|
// package.json with { type: 'json' }
|
|
10181
10201
|
var package_default2 = {
|
|
10182
10202
|
name: "@algolia/wizard",
|
|
10183
|
-
version: "0.
|
|
10203
|
+
version: "0.107.0",
|
|
10184
10204
|
description: "Magically implement Algolia functionality in your codebase",
|
|
10185
10205
|
type: "module",
|
|
10186
10206
|
engines: {
|