@algolia/wizard 0.102.0 → 0.103.0-rc.217.754
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
|
@@ -1616,6 +1616,10 @@ async function clearWorkflowState(workflowId) {
|
|
|
1616
1616
|
}
|
|
1617
1617
|
|
|
1618
1618
|
// src/lib/modelProfiles.ts
|
|
1619
|
+
var MODEL_CAPABILITIES = {
|
|
1620
|
+
"claude-haiku-5-5": { forcedToolUse: true, lowestThinking: "disabled" },
|
|
1621
|
+
"claude-sonnet-5-5": { forcedToolUse: false, lowestThinking: "between_tools" }
|
|
1622
|
+
};
|
|
1619
1623
|
var TOKENS_PER_MILLION = 1e6;
|
|
1620
1624
|
var INITIAL_MODEL_ATTEMPT = 1;
|
|
1621
1625
|
var NO_TOKENS = 0;
|
|
@@ -1627,57 +1631,57 @@ var IMPLEMENTATION_MAX_OUTPUT_TOKENS = 65536;
|
|
|
1627
1631
|
var IMPLEMENTATION_MAX_STEPS = 48;
|
|
1628
1632
|
var VALIDATION_MAX_OUTPUT_TOKENS = 8192;
|
|
1629
1633
|
var VALIDATION_MAX_STEPS = 24;
|
|
1630
|
-
var
|
|
1631
|
-
input: 1,
|
|
1632
|
-
output: 5,
|
|
1633
|
-
cacheRead: 0.
|
|
1634
|
-
cacheWrite:
|
|
1634
|
+
var HAIKU_5_5_PRICES = {
|
|
1635
|
+
input: 0.1,
|
|
1636
|
+
output: 0.5,
|
|
1637
|
+
cacheRead: 0.01,
|
|
1638
|
+
cacheWrite: 0.125
|
|
1635
1639
|
};
|
|
1636
|
-
var
|
|
1640
|
+
var SONNET_5_5_PRICES = {
|
|
1637
1641
|
input: 2,
|
|
1638
1642
|
output: 10,
|
|
1639
|
-
cacheRead: 0.
|
|
1643
|
+
cacheRead: 0.1,
|
|
1640
1644
|
cacheWrite: 2.5
|
|
1641
1645
|
};
|
|
1642
1646
|
var MODEL_PROFILES = {
|
|
1643
1647
|
quick: {
|
|
1644
|
-
model: "claude-haiku-
|
|
1648
|
+
model: "claude-haiku-5-5",
|
|
1645
1649
|
thinking: "disabled",
|
|
1646
1650
|
maxOutputTokens: QUICK_MAX_OUTPUT_TOKENS,
|
|
1647
1651
|
maxSteps: QUICK_MAX_STEPS,
|
|
1648
|
-
prices:
|
|
1652
|
+
prices: HAIKU_5_5_PRICES
|
|
1649
1653
|
},
|
|
1650
1654
|
analysis: {
|
|
1651
|
-
model: "claude-sonnet-5",
|
|
1655
|
+
model: "claude-sonnet-5-5",
|
|
1652
1656
|
thinking: "adaptive",
|
|
1653
1657
|
effort: "low",
|
|
1654
1658
|
maxOutputTokens: ANALYSIS_MAX_OUTPUT_TOKENS,
|
|
1655
1659
|
maxSteps: ANALYSIS_MAX_STEPS,
|
|
1656
|
-
prices:
|
|
1660
|
+
prices: SONNET_5_5_PRICES
|
|
1657
1661
|
},
|
|
1658
1662
|
implementation: {
|
|
1659
|
-
model: "claude-sonnet-5",
|
|
1663
|
+
model: "claude-sonnet-5-5",
|
|
1660
1664
|
thinking: "adaptive",
|
|
1661
1665
|
effort: "medium",
|
|
1662
1666
|
maxOutputTokens: IMPLEMENTATION_MAX_OUTPUT_TOKENS,
|
|
1663
1667
|
maxSteps: IMPLEMENTATION_MAX_STEPS,
|
|
1664
|
-
prices:
|
|
1668
|
+
prices: SONNET_5_5_PRICES
|
|
1665
1669
|
},
|
|
1666
1670
|
implementationRetry: {
|
|
1667
|
-
model: "claude-sonnet-5",
|
|
1671
|
+
model: "claude-sonnet-5-5",
|
|
1668
1672
|
thinking: "adaptive",
|
|
1669
1673
|
effort: "high",
|
|
1670
1674
|
maxOutputTokens: IMPLEMENTATION_MAX_OUTPUT_TOKENS,
|
|
1671
1675
|
maxSteps: IMPLEMENTATION_MAX_STEPS,
|
|
1672
|
-
prices:
|
|
1676
|
+
prices: SONNET_5_5_PRICES
|
|
1673
1677
|
},
|
|
1674
1678
|
validation: {
|
|
1675
|
-
model: "claude-sonnet-5",
|
|
1679
|
+
model: "claude-sonnet-5-5",
|
|
1676
1680
|
thinking: "adaptive",
|
|
1677
1681
|
effort: "low",
|
|
1678
1682
|
maxOutputTokens: VALIDATION_MAX_OUTPUT_TOKENS,
|
|
1679
1683
|
maxSteps: VALIDATION_MAX_STEPS,
|
|
1680
|
-
prices:
|
|
1684
|
+
prices: SONNET_5_5_PRICES
|
|
1681
1685
|
}
|
|
1682
1686
|
};
|
|
1683
1687
|
function getModelProfile(profileName) {
|
|
@@ -1690,6 +1694,14 @@ function providerOptionsForProfile(profileName) {
|
|
|
1690
1694
|
...profile.effort !== void 0 && { effort: profile.effort }
|
|
1691
1695
|
};
|
|
1692
1696
|
}
|
|
1697
|
+
function toolChoiceForProfile(profileName) {
|
|
1698
|
+
const { model } = getModelProfile(profileName);
|
|
1699
|
+
return MODEL_CAPABILITIES[model].forcedToolUse ? "required" : "auto";
|
|
1700
|
+
}
|
|
1701
|
+
function lowestThinkingForProfile(profileName) {
|
|
1702
|
+
const { model } = getModelProfile(profileName);
|
|
1703
|
+
return { type: MODEL_CAPABILITIES[model].lowestThinking };
|
|
1704
|
+
}
|
|
1693
1705
|
function tokenCount(value = NO_TOKENS) {
|
|
1694
1706
|
return value;
|
|
1695
1707
|
}
|
|
@@ -2447,7 +2459,7 @@ async function ensureApplication(resumeAppId) {
|
|
|
2447
2459
|
// package.json
|
|
2448
2460
|
var package_default = {
|
|
2449
2461
|
name: "@algolia/wizard",
|
|
2450
|
-
version: "0.
|
|
2462
|
+
version: "0.103.0-rc.217.754",
|
|
2451
2463
|
description: "Magically implement Algolia functionality in your codebase",
|
|
2452
2464
|
type: "module",
|
|
2453
2465
|
engines: {
|
|
@@ -2494,11 +2506,11 @@ var package_default = {
|
|
|
2494
2506
|
vitest: "^4.1.11"
|
|
2495
2507
|
},
|
|
2496
2508
|
dependencies: {
|
|
2497
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
2498
|
-
"@ai-sdk/openai-compatible": "^2.0.
|
|
2509
|
+
"@ai-sdk/anthropic": "^3.0.128",
|
|
2510
|
+
"@ai-sdk/openai-compatible": "^2.0.81",
|
|
2499
2511
|
"@hono/node-server": "^2.0.10",
|
|
2500
2512
|
"@segment/analytics-node": "^3.1.0",
|
|
2501
|
-
ai: "^6.0.
|
|
2513
|
+
ai: "^6.0.302",
|
|
2502
2514
|
"cross-keychain": "^1.1.0",
|
|
2503
2515
|
dotenv: "^17.4.2",
|
|
2504
2516
|
hono: "^4.13.8",
|
|
@@ -5418,6 +5430,10 @@ var MISSING_REPORT_STATUS_ERROR_MESSAGE = "Agent finished without calling report
|
|
|
5418
5430
|
var MISSING_REPORT_USER_MESSAGE = "This step ran into a problem finishing. Run the wizard again to retry it.";
|
|
5419
5431
|
var REPORT_STATUS_RETRIES = 2;
|
|
5420
5432
|
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.";
|
|
5433
|
+
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.";
|
|
5434
|
+
var ENDED_TURN_NUDGE = "Your last response did not call a tool. Continue the work with tools. When the work is done, call reportStatus.";
|
|
5435
|
+
var INITIAL_PROMPT = "Follow system instructions";
|
|
5436
|
+
var ENDED_TURN_CONTINUATIONS = 3;
|
|
5421
5437
|
var RECENT_STEPS_LOGGED = 3;
|
|
5422
5438
|
var LOGGED_CHARS = 300;
|
|
5423
5439
|
var ATTEMPT_NUMBER_OFFSET = 1;
|
|
@@ -5455,6 +5471,13 @@ var MissingReportError = class extends Error {
|
|
|
5455
5471
|
this.incompleteCause = incompleteCause;
|
|
5456
5472
|
}
|
|
5457
5473
|
};
|
|
5474
|
+
var EndedTurnError = class extends MissingReportError {
|
|
5475
|
+
continuation;
|
|
5476
|
+
constructor(continuation) {
|
|
5477
|
+
super(null);
|
|
5478
|
+
this.continuation = continuation;
|
|
5479
|
+
}
|
|
5480
|
+
};
|
|
5458
5481
|
function incompleteCauseOf(stepCount, maxSteps, finishReason) {
|
|
5459
5482
|
if (stepCount >= maxSteps) return "stepLimit";
|
|
5460
5483
|
if (finishReason === "length") return "truncated";
|
|
@@ -5513,10 +5536,23 @@ function exhaustedError(kind, err) {
|
|
|
5513
5536
|
}
|
|
5514
5537
|
async function runAgent(req) {
|
|
5515
5538
|
let retryReason = null;
|
|
5516
|
-
|
|
5539
|
+
let attempt = INITIAL_ATTEMPT;
|
|
5540
|
+
let continuation;
|
|
5541
|
+
let continuations = 0;
|
|
5542
|
+
for (; ; ) {
|
|
5517
5543
|
try {
|
|
5518
|
-
return await runAgentAttempt(req, attempt, retryReason);
|
|
5544
|
+
return await runAgentAttempt(req, attempt, retryReason, continuation);
|
|
5519
5545
|
} catch (err) {
|
|
5546
|
+
continuation = void 0;
|
|
5547
|
+
if (err instanceof EndedTurnError && continuations < ENDED_TURN_CONTINUATIONS) {
|
|
5548
|
+
continuations++;
|
|
5549
|
+
continuation = err.continuation;
|
|
5550
|
+
logger.warn(
|
|
5551
|
+
{ attempt: attempt + 1, continuations },
|
|
5552
|
+
"continuing runAgent after a turn ended without a tool call"
|
|
5553
|
+
);
|
|
5554
|
+
continue;
|
|
5555
|
+
}
|
|
5520
5556
|
const kind = retryKind(err);
|
|
5521
5557
|
if (!kind) throw err;
|
|
5522
5558
|
if (attempt === REPORT_STATUS_RETRIES) throw exhaustedError(kind, err);
|
|
@@ -5525,19 +5561,23 @@ async function runAgent(req) {
|
|
|
5525
5561
|
{ attempt: attempt + 1, err },
|
|
5526
5562
|
isMissingReportRetry(kind) ? "retrying runAgent after missing reportStatus" : "retrying runAgent after a transient provider error"
|
|
5527
5563
|
);
|
|
5564
|
+
attempt++;
|
|
5528
5565
|
}
|
|
5529
5566
|
}
|
|
5530
|
-
throw new Error("unreachable");
|
|
5531
5567
|
}
|
|
5532
|
-
async function runAgentAttempt(req, attempt, retryReason) {
|
|
5568
|
+
async function runAgentAttempt(req, attempt, retryReason, continuation) {
|
|
5533
5569
|
const start = Date.now();
|
|
5534
5570
|
const profileName = req.modelProfile ?? "implementation" /* implementation */;
|
|
5535
5571
|
const profile = getModelProfile(profileName);
|
|
5536
5572
|
const profileOptions = providerOptionsForProfile(profileName);
|
|
5573
|
+
const toolChoice = toolChoiceForProfile(profileName);
|
|
5537
5574
|
const maxSteps = req.maxSteps ?? profile.maxSteps;
|
|
5575
|
+
const stepsUsed = continuation?.stepsUsed ?? 0;
|
|
5576
|
+
const stepsLeft = maxSteps - stepsUsed;
|
|
5538
5577
|
const forceReport = retryReason === "missingReport";
|
|
5539
5578
|
const incompleteReason = incompleteReasonOf(retryReason);
|
|
5540
|
-
const
|
|
5579
|
+
const reportThinking = lowestThinkingForProfile(profileName);
|
|
5580
|
+
const modelOptions = forceReport ? { thinking: reportThinking, effort: void 0 } : profileOptions;
|
|
5541
5581
|
logger.info(
|
|
5542
5582
|
{
|
|
5543
5583
|
startedAt: new Date(start).toISOString(),
|
|
@@ -5545,8 +5585,9 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5545
5585
|
profile: profileName,
|
|
5546
5586
|
model: profile.model,
|
|
5547
5587
|
effort: forceReport ? void 0 : profile.effort,
|
|
5548
|
-
thinking: forceReport ?
|
|
5549
|
-
retryReason
|
|
5588
|
+
thinking: forceReport ? reportThinking.type : profile.thinking,
|
|
5589
|
+
retryReason,
|
|
5590
|
+
stepsUsed
|
|
5550
5591
|
},
|
|
5551
5592
|
"runAgent started"
|
|
5552
5593
|
);
|
|
@@ -5560,7 +5601,7 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5560
5601
|
fetch: proxyFetch
|
|
5561
5602
|
});
|
|
5562
5603
|
const toolContext = req.toolContext ?? createToolContext();
|
|
5563
|
-
if (attempt > INITIAL_ATTEMPT) resetToolCounts(toolContext);
|
|
5604
|
+
if (attempt > INITIAL_ATTEMPT && !continuation) resetToolCounts(toolContext);
|
|
5564
5605
|
const readTools = ["readFile", "searchFiles", "listFiles"];
|
|
5565
5606
|
const hasReadTools = !req.tools || req.tools.some((t) => readTools.includes(t));
|
|
5566
5607
|
const instructions = [
|
|
@@ -5569,6 +5610,7 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5569
5610
|
"When you need to read or search multiple files, issue those tool calls together in one step rather than one at a time."
|
|
5570
5611
|
] : [],
|
|
5571
5612
|
"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.",
|
|
5613
|
+
...toolChoice === "auto" ? [TOOL_EVERY_TURN_INSTRUCTION] : [],
|
|
5572
5614
|
STEP_LIMIT_INSTRUCTION,
|
|
5573
5615
|
// Last so a retry does not bust the cached tools+system prefix from
|
|
5574
5616
|
// the first attempt. Inspect-and-continue, not start over: implement
|
|
@@ -5613,11 +5655,11 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5613
5655
|
output: req.outputSchema,
|
|
5614
5656
|
tools: req.tools
|
|
5615
5657
|
}),
|
|
5616
|
-
toolChoice
|
|
5617
|
-
stopWhen: [reportAccepted, stepCountIs(
|
|
5658
|
+
toolChoice,
|
|
5659
|
+
stopWhen: [reportAccepted, stepCountIs(stepsLeft)],
|
|
5618
5660
|
prepareStep: ({ stepNumber, messages }) => ({
|
|
5619
5661
|
messages: withCachedHistory(messages),
|
|
5620
|
-
...stepNumber >=
|
|
5662
|
+
...stepNumber >= stepsLeft - 1 && {
|
|
5621
5663
|
activeTools: ["reportStatus"]
|
|
5622
5664
|
}
|
|
5623
5665
|
}),
|
|
@@ -5625,9 +5667,11 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5625
5667
|
...{ onError: () => {
|
|
5626
5668
|
} }
|
|
5627
5669
|
});
|
|
5628
|
-
const
|
|
5629
|
-
|
|
5630
|
-
|
|
5670
|
+
const prompt = continuation ? [
|
|
5671
|
+
...continuation.messages,
|
|
5672
|
+
{ role: "user", content: ENDED_TURN_NUDGE }
|
|
5673
|
+
] : [{ role: "user", content: INITIAL_PROMPT }];
|
|
5674
|
+
const stream = await agent.stream({ prompt });
|
|
5631
5675
|
let chunks = [];
|
|
5632
5676
|
const chunkLimit = 5;
|
|
5633
5677
|
let streamError;
|
|
@@ -5659,7 +5703,8 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5659
5703
|
const usage = await stream.totalUsage;
|
|
5660
5704
|
const steps = await stream.steps;
|
|
5661
5705
|
const stepCount = steps.length;
|
|
5662
|
-
const
|
|
5706
|
+
const totalSteps = stepsUsed + stepCount;
|
|
5707
|
+
const hitStepLimit = totalSteps >= maxSteps;
|
|
5663
5708
|
const lastStep = steps[steps.length - 1];
|
|
5664
5709
|
const finishReason = lastStep?.finishReason;
|
|
5665
5710
|
trackAgentRun({
|
|
@@ -5707,8 +5752,16 @@ async function runAgentAttempt(req, attempt, retryReason) {
|
|
|
5707
5752
|
},
|
|
5708
5753
|
"Agent finished without calling reportStatus"
|
|
5709
5754
|
);
|
|
5755
|
+
const endedTurn = toolChoice === "auto" && finishReason === "stop" && !lastStep?.toolCalls?.length && !hitStepLimit;
|
|
5756
|
+
if (endedTurn) {
|
|
5757
|
+
const { messages } = await stream.response;
|
|
5758
|
+
throw new EndedTurnError({
|
|
5759
|
+
messages: [...prompt, ...messages],
|
|
5760
|
+
stepsUsed: totalSteps
|
|
5761
|
+
});
|
|
5762
|
+
}
|
|
5710
5763
|
throw new MissingReportError(
|
|
5711
|
-
incompleteCauseOf(
|
|
5764
|
+
incompleteCauseOf(totalSteps, maxSteps, finishReason)
|
|
5712
5765
|
);
|
|
5713
5766
|
}
|
|
5714
5767
|
const result = report.output;
|
|
@@ -10073,7 +10126,7 @@ async function resetProjectState() {
|
|
|
10073
10126
|
// package.json with { type: 'json' }
|
|
10074
10127
|
var package_default2 = {
|
|
10075
10128
|
name: "@algolia/wizard",
|
|
10076
|
-
version: "0.
|
|
10129
|
+
version: "0.103.0-rc.217.754",
|
|
10077
10130
|
description: "Magically implement Algolia functionality in your codebase",
|
|
10078
10131
|
type: "module",
|
|
10079
10132
|
engines: {
|
|
@@ -10120,11 +10173,11 @@ var package_default2 = {
|
|
|
10120
10173
|
vitest: "^4.1.11"
|
|
10121
10174
|
},
|
|
10122
10175
|
dependencies: {
|
|
10123
|
-
"@ai-sdk/anthropic": "^3.0.
|
|
10124
|
-
"@ai-sdk/openai-compatible": "^2.0.
|
|
10176
|
+
"@ai-sdk/anthropic": "^3.0.128",
|
|
10177
|
+
"@ai-sdk/openai-compatible": "^2.0.81",
|
|
10125
10178
|
"@hono/node-server": "^2.0.10",
|
|
10126
10179
|
"@segment/analytics-node": "^3.1.0",
|
|
10127
|
-
ai: "^6.0.
|
|
10180
|
+
ai: "^6.0.302",
|
|
10128
10181
|
"cross-keychain": "^1.1.0",
|
|
10129
10182
|
dotenv: "^17.4.2",
|
|
10130
10183
|
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.103.0-rc.217.754",
|
|
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",
|