@algolia/wizard 0.97.0 → 0.98.0-rc.217.731
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 +94 -41
- package/package.json +4 -4
package/dist/main.js
CHANGED
|
@@ -1606,6 +1606,10 @@ async function clearWorkflowState(workflowId) {
|
|
|
1606
1606
|
}
|
|
1607
1607
|
|
|
1608
1608
|
// src/lib/modelProfiles.ts
|
|
1609
|
+
var MODEL_CAPABILITIES = {
|
|
1610
|
+
"claude-haiku-5-5": { forcedToolUse: true, lowestThinking: "disabled" },
|
|
1611
|
+
"claude-sonnet-5-5": { forcedToolUse: false, lowestThinking: "between_tools" }
|
|
1612
|
+
};
|
|
1609
1613
|
var TOKENS_PER_MILLION = 1e6;
|
|
1610
1614
|
var INITIAL_MODEL_ATTEMPT = 1;
|
|
1611
1615
|
var NO_TOKENS = 0;
|
|
@@ -1617,57 +1621,57 @@ var IMPLEMENTATION_MAX_OUTPUT_TOKENS = 65536;
|
|
|
1617
1621
|
var IMPLEMENTATION_MAX_STEPS = 48;
|
|
1618
1622
|
var VALIDATION_MAX_OUTPUT_TOKENS = 8192;
|
|
1619
1623
|
var VALIDATION_MAX_STEPS = 24;
|
|
1620
|
-
var
|
|
1621
|
-
input: 1,
|
|
1622
|
-
output: 5,
|
|
1623
|
-
cacheRead: 0.
|
|
1624
|
-
cacheWrite:
|
|
1624
|
+
var HAIKU_5_5_PRICES = {
|
|
1625
|
+
input: 0.1,
|
|
1626
|
+
output: 0.5,
|
|
1627
|
+
cacheRead: 0.01,
|
|
1628
|
+
cacheWrite: 0.125
|
|
1625
1629
|
};
|
|
1626
|
-
var
|
|
1630
|
+
var SONNET_5_5_PRICES = {
|
|
1627
1631
|
input: 2,
|
|
1628
1632
|
output: 10,
|
|
1629
|
-
cacheRead: 0.
|
|
1633
|
+
cacheRead: 0.1,
|
|
1630
1634
|
cacheWrite: 2.5
|
|
1631
1635
|
};
|
|
1632
1636
|
var MODEL_PROFILES = {
|
|
1633
1637
|
quick: {
|
|
1634
|
-
model: "claude-haiku-
|
|
1638
|
+
model: "claude-haiku-5-5",
|
|
1635
1639
|
thinking: "disabled",
|
|
1636
1640
|
maxOutputTokens: QUICK_MAX_OUTPUT_TOKENS,
|
|
1637
1641
|
maxSteps: QUICK_MAX_STEPS,
|
|
1638
|
-
prices:
|
|
1642
|
+
prices: HAIKU_5_5_PRICES
|
|
1639
1643
|
},
|
|
1640
1644
|
analysis: {
|
|
1641
|
-
model: "claude-sonnet-5",
|
|
1645
|
+
model: "claude-sonnet-5-5",
|
|
1642
1646
|
thinking: "adaptive",
|
|
1643
1647
|
effort: "low",
|
|
1644
1648
|
maxOutputTokens: ANALYSIS_MAX_OUTPUT_TOKENS,
|
|
1645
1649
|
maxSteps: ANALYSIS_MAX_STEPS,
|
|
1646
|
-
prices:
|
|
1650
|
+
prices: SONNET_5_5_PRICES
|
|
1647
1651
|
},
|
|
1648
1652
|
implementation: {
|
|
1649
|
-
model: "claude-sonnet-5",
|
|
1653
|
+
model: "claude-sonnet-5-5",
|
|
1650
1654
|
thinking: "adaptive",
|
|
1651
1655
|
effort: "medium",
|
|
1652
1656
|
maxOutputTokens: IMPLEMENTATION_MAX_OUTPUT_TOKENS,
|
|
1653
1657
|
maxSteps: IMPLEMENTATION_MAX_STEPS,
|
|
1654
|
-
prices:
|
|
1658
|
+
prices: SONNET_5_5_PRICES
|
|
1655
1659
|
},
|
|
1656
1660
|
implementationRetry: {
|
|
1657
|
-
model: "claude-sonnet-5",
|
|
1661
|
+
model: "claude-sonnet-5-5",
|
|
1658
1662
|
thinking: "adaptive",
|
|
1659
1663
|
effort: "high",
|
|
1660
1664
|
maxOutputTokens: IMPLEMENTATION_MAX_OUTPUT_TOKENS,
|
|
1661
1665
|
maxSteps: IMPLEMENTATION_MAX_STEPS,
|
|
1662
|
-
prices:
|
|
1666
|
+
prices: SONNET_5_5_PRICES
|
|
1663
1667
|
},
|
|
1664
1668
|
validation: {
|
|
1665
|
-
model: "claude-sonnet-5",
|
|
1669
|
+
model: "claude-sonnet-5-5",
|
|
1666
1670
|
thinking: "adaptive",
|
|
1667
1671
|
effort: "low",
|
|
1668
1672
|
maxOutputTokens: VALIDATION_MAX_OUTPUT_TOKENS,
|
|
1669
1673
|
maxSteps: VALIDATION_MAX_STEPS,
|
|
1670
|
-
prices:
|
|
1674
|
+
prices: SONNET_5_5_PRICES
|
|
1671
1675
|
}
|
|
1672
1676
|
};
|
|
1673
1677
|
function getModelProfile(profileName) {
|
|
@@ -1680,6 +1684,14 @@ function providerOptionsForProfile(profileName) {
|
|
|
1680
1684
|
...profile.effort !== void 0 && { effort: profile.effort }
|
|
1681
1685
|
};
|
|
1682
1686
|
}
|
|
1687
|
+
function toolChoiceForProfile(profileName) {
|
|
1688
|
+
const { model } = getModelProfile(profileName);
|
|
1689
|
+
return MODEL_CAPABILITIES[model].forcedToolUse ? "required" : "auto";
|
|
1690
|
+
}
|
|
1691
|
+
function lowestThinkingForProfile(profileName) {
|
|
1692
|
+
const { model } = getModelProfile(profileName);
|
|
1693
|
+
return { type: MODEL_CAPABILITIES[model].lowestThinking };
|
|
1694
|
+
}
|
|
1683
1695
|
function tokenCount(value = NO_TOKENS) {
|
|
1684
1696
|
return value;
|
|
1685
1697
|
}
|
|
@@ -2384,7 +2396,7 @@ async function ensureApplication(resumeAppId) {
|
|
|
2384
2396
|
// package.json
|
|
2385
2397
|
var package_default = {
|
|
2386
2398
|
name: "@algolia/wizard",
|
|
2387
|
-
version: "0.
|
|
2399
|
+
version: "0.98.0-rc.217.731",
|
|
2388
2400
|
description: "Magically implement Algolia functionality in your codebase",
|
|
2389
2401
|
type: "module",
|
|
2390
2402
|
engines: {
|
|
@@ -2431,11 +2443,11 @@ var package_default = {
|
|
|
2431
2443
|
vitest: "^4.1.11"
|
|
2432
2444
|
},
|
|
2433
2445
|
dependencies: {
|
|
2434
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
2435
|
-
"@ai-sdk/openai-compatible": "^2.0.
|
|
2446
|
+
"@ai-sdk/anthropic": "^3.0.128",
|
|
2447
|
+
"@ai-sdk/openai-compatible": "^2.0.81",
|
|
2436
2448
|
"@hono/node-server": "^2.0.10",
|
|
2437
2449
|
"@segment/analytics-node": "^3.1.0",
|
|
2438
|
-
ai: "^6.0.
|
|
2450
|
+
ai: "^6.0.302",
|
|
2439
2451
|
"cross-keychain": "^1.1.0",
|
|
2440
2452
|
dotenv: "^17.4.2",
|
|
2441
2453
|
hono: "^4.13.8",
|
|
@@ -5270,6 +5282,10 @@ var MISSING_REPORT_STATUS_ERROR_MESSAGE = "Agent finished without calling report
|
|
|
5270
5282
|
var MISSING_REPORT_USER_MESSAGE = "This step ran into a problem finishing. Run the wizard again to retry it.";
|
|
5271
5283
|
var REPORT_STATUS_RETRIES = 2;
|
|
5272
5284
|
var STEP_LIMIT_INSTRUCTION = "When reportStatus is the only tool available, you reached the step limit. This limit is not a failure, so do not report fail because of it: report status=success with the work done so far, and name the remaining work in the summary.";
|
|
5285
|
+
var TOOL_EVERY_TURN_INSTRUCTION = "Call at least one tool in every response. Do not reply with text only. The run ends only when you call reportStatus.";
|
|
5286
|
+
var ENDED_TURN_NUDGE = "Your last response did not call a tool. Continue the work with tools. When the work is done, call reportStatus.";
|
|
5287
|
+
var INITIAL_PROMPT = "Follow system instructions";
|
|
5288
|
+
var ENDED_TURN_CONTINUATIONS = 3;
|
|
5273
5289
|
var RECENT_STEPS_LOGGED = 3;
|
|
5274
5290
|
var LOGGED_CHARS = 300;
|
|
5275
5291
|
var ATTEMPT_NUMBER_OFFSET = 1;
|
|
@@ -5307,6 +5323,13 @@ var MissingReportError = class extends Error {
|
|
|
5307
5323
|
this.incompleteCause = incompleteCause;
|
|
5308
5324
|
}
|
|
5309
5325
|
};
|
|
5326
|
+
var EndedTurnError = class extends MissingReportError {
|
|
5327
|
+
continuation;
|
|
5328
|
+
constructor(continuation) {
|
|
5329
|
+
super(null);
|
|
5330
|
+
this.continuation = continuation;
|
|
5331
|
+
}
|
|
5332
|
+
};
|
|
5310
5333
|
function incompleteCauseOf(stepCount, maxSteps, finishReason) {
|
|
5311
5334
|
if (stepCount >= maxSteps) return "stepLimit";
|
|
5312
5335
|
if (finishReason === "length") return "truncated";
|
|
@@ -5357,10 +5380,23 @@ function exhaustedError(kind, err) {
|
|
|
5357
5380
|
}
|
|
5358
5381
|
async function runAgent(req) {
|
|
5359
5382
|
let retryReason = null;
|
|
5360
|
-
|
|
5383
|
+
let attempt = INITIAL_ATTEMPT;
|
|
5384
|
+
let continuation;
|
|
5385
|
+
let continuations = 0;
|
|
5386
|
+
for (; ; ) {
|
|
5361
5387
|
try {
|
|
5362
|
-
return await runAgentAttempt(req, attempt, retryReason);
|
|
5388
|
+
return await runAgentAttempt(req, attempt, retryReason, continuation);
|
|
5363
5389
|
} catch (err) {
|
|
5390
|
+
continuation = void 0;
|
|
5391
|
+
if (err instanceof EndedTurnError && continuations < ENDED_TURN_CONTINUATIONS) {
|
|
5392
|
+
continuations++;
|
|
5393
|
+
continuation = err.continuation;
|
|
5394
|
+
logger.warn(
|
|
5395
|
+
{ attempt: attempt + 1, continuations },
|
|
5396
|
+
"continuing runAgent after a turn ended without a tool call"
|
|
5397
|
+
);
|
|
5398
|
+
continue;
|
|
5399
|
+
}
|
|
5364
5400
|
const kind = retryKind(err);
|
|
5365
5401
|
if (!kind) throw err;
|
|
5366
5402
|
if (attempt === REPORT_STATUS_RETRIES) throw exhaustedError(kind, err);
|
|
@@ -5369,19 +5405,23 @@ async function runAgent(req) {
|
|
|
5369
5405
|
{ attempt: attempt + 1, err },
|
|
5370
5406
|
isMissingReportRetry(kind) ? "retrying runAgent after missing reportStatus" : "retrying runAgent after a transient provider error"
|
|
5371
5407
|
);
|
|
5408
|
+
attempt++;
|
|
5372
5409
|
}
|
|
5373
5410
|
}
|
|
5374
|
-
throw new Error("unreachable");
|
|
5375
5411
|
}
|
|
5376
|
-
async function runAgentAttempt(req, attempt, retryReason) {
|
|
5412
|
+
async function runAgentAttempt(req, attempt, retryReason, continuation) {
|
|
5377
5413
|
const start = Date.now();
|
|
5378
5414
|
const profileName = req.modelProfile ?? "implementation" /* implementation */;
|
|
5379
5415
|
const profile = getModelProfile(profileName);
|
|
5380
5416
|
const profileOptions = providerOptionsForProfile(profileName);
|
|
5417
|
+
const toolChoice = toolChoiceForProfile(profileName);
|
|
5381
5418
|
const maxSteps = req.maxSteps ?? profile.maxSteps;
|
|
5419
|
+
const stepsUsed = continuation?.stepsUsed ?? 0;
|
|
5420
|
+
const stepsLeft = maxSteps - stepsUsed;
|
|
5382
5421
|
const forceReport = retryReason === "missingReport";
|
|
5383
5422
|
const incompleteReason = incompleteReasonOf(retryReason);
|
|
5384
|
-
const
|
|
5423
|
+
const reportThinking = lowestThinkingForProfile(profileName);
|
|
5424
|
+
const modelOptions = forceReport ? { thinking: reportThinking, effort: void 0 } : profileOptions;
|
|
5385
5425
|
logger.info(
|
|
5386
5426
|
{
|
|
5387
5427
|
startedAt: new Date(start).toISOString(),
|
|
@@ -5389,8 +5429,9 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5389
5429
|
profile: profileName,
|
|
5390
5430
|
model: profile.model,
|
|
5391
5431
|
effort: forceReport ? void 0 : profile.effort,
|
|
5392
|
-
thinking: forceReport ?
|
|
5393
|
-
retryReason
|
|
5432
|
+
thinking: forceReport ? reportThinking.type : profile.thinking,
|
|
5433
|
+
retryReason,
|
|
5434
|
+
stepsUsed
|
|
5394
5435
|
},
|
|
5395
5436
|
"runAgent started"
|
|
5396
5437
|
);
|
|
@@ -5404,7 +5445,7 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5404
5445
|
fetch: proxyFetch
|
|
5405
5446
|
});
|
|
5406
5447
|
const toolContext = req.toolContext ?? createToolContext();
|
|
5407
|
-
if (attempt > INITIAL_ATTEMPT) resetToolCounts(toolContext);
|
|
5448
|
+
if (attempt > INITIAL_ATTEMPT && !continuation) resetToolCounts(toolContext);
|
|
5408
5449
|
const readTools = ["readFile", "searchFiles", "listFiles"];
|
|
5409
5450
|
const hasReadTools = !req.tools || req.tools.some((t) => readTools.includes(t));
|
|
5410
5451
|
const instructions = [
|
|
@@ -5413,6 +5454,7 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5413
5454
|
"When you need to read or search multiple files, issue those tool calls together in one step rather than one at a time."
|
|
5414
5455
|
] : [],
|
|
5415
5456
|
"Call notifyUser whenever you start a new phase of work or your focus shifts (e.g. moving from reading code to writing files) \u2014 a short, plain-language, high-level update. Do not call it for every tool use.",
|
|
5457
|
+
...toolChoice === "auto" ? [TOOL_EVERY_TURN_INSTRUCTION] : [],
|
|
5416
5458
|
STEP_LIMIT_INSTRUCTION,
|
|
5417
5459
|
// Last so a retry does not bust the cached tools+system prefix from
|
|
5418
5460
|
// the first attempt. Inspect-and-continue, not start over: implement
|
|
@@ -5457,14 +5499,14 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5457
5499
|
output: req.outputSchema,
|
|
5458
5500
|
tools: req.tools
|
|
5459
5501
|
}),
|
|
5460
|
-
toolChoice
|
|
5502
|
+
toolChoice,
|
|
5461
5503
|
stopWhen: [
|
|
5462
5504
|
hasToolCall("reportStatus"),
|
|
5463
|
-
stepCountIs(
|
|
5505
|
+
stepCountIs(stepsLeft)
|
|
5464
5506
|
],
|
|
5465
5507
|
prepareStep: ({ stepNumber, messages }) => ({
|
|
5466
5508
|
messages: withCachedHistory(messages),
|
|
5467
|
-
...stepNumber >=
|
|
5509
|
+
...stepNumber >= stepsLeft - 1 && {
|
|
5468
5510
|
activeTools: ["reportStatus"]
|
|
5469
5511
|
}
|
|
5470
5512
|
}),
|
|
@@ -5472,9 +5514,11 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5472
5514
|
...{ onError: () => {
|
|
5473
5515
|
} }
|
|
5474
5516
|
});
|
|
5475
|
-
const
|
|
5476
|
-
|
|
5477
|
-
|
|
5517
|
+
const prompt = continuation ? [
|
|
5518
|
+
...continuation.messages,
|
|
5519
|
+
{ role: "user", content: ENDED_TURN_NUDGE }
|
|
5520
|
+
] : [{ role: "user", content: INITIAL_PROMPT }];
|
|
5521
|
+
const stream = await agent.stream({ prompt });
|
|
5478
5522
|
let chunks = [];
|
|
5479
5523
|
const chunkLimit = 5;
|
|
5480
5524
|
let streamError;
|
|
@@ -5506,7 +5550,8 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5506
5550
|
const usage = await stream.totalUsage;
|
|
5507
5551
|
const steps = await stream.steps;
|
|
5508
5552
|
const stepCount = steps.length;
|
|
5509
|
-
const
|
|
5553
|
+
const totalSteps = stepsUsed + stepCount;
|
|
5554
|
+
const hitStepLimit = totalSteps >= maxSteps;
|
|
5510
5555
|
const lastStep = steps[steps.length - 1];
|
|
5511
5556
|
const finishReason = lastStep?.finishReason;
|
|
5512
5557
|
trackAgentRun({
|
|
@@ -5554,8 +5599,16 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5554
5599
|
},
|
|
5555
5600
|
"Agent finished without calling reportStatus"
|
|
5556
5601
|
);
|
|
5602
|
+
const endedTurn = toolChoice === "auto" && finishReason === "stop" && !lastStep?.toolCalls?.length && !hitStepLimit;
|
|
5603
|
+
if (endedTurn) {
|
|
5604
|
+
const { messages } = await stream.response;
|
|
5605
|
+
throw new EndedTurnError({
|
|
5606
|
+
messages: [...prompt, ...messages],
|
|
5607
|
+
stepsUsed: totalSteps
|
|
5608
|
+
});
|
|
5609
|
+
}
|
|
5557
5610
|
throw new MissingReportError(
|
|
5558
|
-
incompleteCauseOf(
|
|
5611
|
+
incompleteCauseOf(totalSteps, maxSteps, finishReason)
|
|
5559
5612
|
);
|
|
5560
5613
|
}
|
|
5561
5614
|
const result = report.output;
|
|
@@ -9903,7 +9956,7 @@ async function resetProjectState() {
|
|
|
9903
9956
|
// package.json with { type: 'json' }
|
|
9904
9957
|
var package_default2 = {
|
|
9905
9958
|
name: "@algolia/wizard",
|
|
9906
|
-
version: "0.
|
|
9959
|
+
version: "0.98.0-rc.217.731",
|
|
9907
9960
|
description: "Magically implement Algolia functionality in your codebase",
|
|
9908
9961
|
type: "module",
|
|
9909
9962
|
engines: {
|
|
@@ -9950,11 +10003,11 @@ var package_default2 = {
|
|
|
9950
10003
|
vitest: "^4.1.11"
|
|
9951
10004
|
},
|
|
9952
10005
|
dependencies: {
|
|
9953
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
9954
|
-
"@ai-sdk/openai-compatible": "^2.0.
|
|
10006
|
+
"@ai-sdk/anthropic": "^3.0.128",
|
|
10007
|
+
"@ai-sdk/openai-compatible": "^2.0.81",
|
|
9955
10008
|
"@hono/node-server": "^2.0.10",
|
|
9956
10009
|
"@segment/analytics-node": "^3.1.0",
|
|
9957
|
-
ai: "^6.0.
|
|
10010
|
+
ai: "^6.0.302",
|
|
9958
10011
|
"cross-keychain": "^1.1.0",
|
|
9959
10012
|
dotenv: "^17.4.2",
|
|
9960
10013
|
hono: "^4.13.8",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algolia/wizard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0-rc.217.731",
|
|
4
4
|
"description": "Magically implement Algolia functionality in your codebase",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"vitest": "^4.1.11"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
51
|
-
"@ai-sdk/openai-compatible": "^2.0.
|
|
50
|
+
"@ai-sdk/anthropic": "^3.0.128",
|
|
51
|
+
"@ai-sdk/openai-compatible": "^2.0.81",
|
|
52
52
|
"@hono/node-server": "^2.0.10",
|
|
53
53
|
"@segment/analytics-node": "^3.1.0",
|
|
54
|
-
"ai": "^6.0.
|
|
54
|
+
"ai": "^6.0.302",
|
|
55
55
|
"cross-keychain": "^1.1.0",
|
|
56
56
|
"dotenv": "^17.4.2",
|
|
57
57
|
"hono": "^4.13.8",
|