@algolia/wizard 0.24.0 → 0.25.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 +43 -3
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -3497,7 +3497,30 @@ var MODEL_BY_SIZE = {
|
|
|
3497
3497
|
medium: "claude-sonnet-4-6",
|
|
3498
3498
|
large: "claude-opus-4-8"
|
|
3499
3499
|
};
|
|
3500
|
+
var MISSING_REPORT_STATUS_ERROR_MESSAGE = "Agent finished without calling reportStatus";
|
|
3501
|
+
var MISSING_REPORT_USER_MESSAGE = "This step ran into a problem finishing. Run the wizard again to retry it.";
|
|
3502
|
+
var REPORT_STATUS_RETRIES = 2;
|
|
3500
3503
|
async function runAgent(req) {
|
|
3504
|
+
for (let attempt = 0; attempt <= REPORT_STATUS_RETRIES; attempt++) {
|
|
3505
|
+
try {
|
|
3506
|
+
return await runAgentAttempt(req, attempt);
|
|
3507
|
+
} catch (err) {
|
|
3508
|
+
const isMissingReport = err instanceof Error && err.message === MISSING_REPORT_STATUS_ERROR_MESSAGE;
|
|
3509
|
+
if (!isMissingReport) {
|
|
3510
|
+
throw err;
|
|
3511
|
+
}
|
|
3512
|
+
if (attempt === REPORT_STATUS_RETRIES) {
|
|
3513
|
+
throw new Error(MISSING_REPORT_USER_MESSAGE);
|
|
3514
|
+
}
|
|
3515
|
+
logger.warn(
|
|
3516
|
+
{ attempt: attempt + 1 },
|
|
3517
|
+
"retrying runAgent after missing reportStatus"
|
|
3518
|
+
);
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
throw new Error("unreachable");
|
|
3522
|
+
}
|
|
3523
|
+
async function runAgentAttempt(req, attempt) {
|
|
3501
3524
|
const start = Date.now();
|
|
3502
3525
|
logger.info({ startedAt: new Date(start).toISOString() }, "runAgent started");
|
|
3503
3526
|
const token = getAuthToken();
|
|
@@ -3517,7 +3540,13 @@ async function runAgent(req) {
|
|
|
3517
3540
|
...hasReadTools ? [
|
|
3518
3541
|
"When you need to read or search multiple files, issue those tool calls together in one step rather than one at a time."
|
|
3519
3542
|
] : [],
|
|
3520
|
-
"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."
|
|
3543
|
+
"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.",
|
|
3544
|
+
// Last so a retry does not bust the cached tools+system prefix from
|
|
3545
|
+
// the first attempt. Inspect-and-continue, not start over: implement
|
|
3546
|
+
// shares the worktree and toolContext across attempts.
|
|
3547
|
+
...attempt > 0 ? [
|
|
3548
|
+
"This run is a retry after a previous attempt that did not finish. Files, shell commands, or ingestion may already have been applied in this workspace \u2014 inspect what is already there and continue from it rather than repeating that work."
|
|
3549
|
+
] : []
|
|
3521
3550
|
];
|
|
3522
3551
|
const agent = new ToolLoopAgent({
|
|
3523
3552
|
model: anthropic(MODEL_BY_SIZE[req.modelSize ?? "medium"]),
|
|
@@ -3584,7 +3613,18 @@ async function runAgent(req) {
|
|
|
3584
3613
|
const toolResults = await stream.toolResults;
|
|
3585
3614
|
const report = [...toolResults].reverse().find((r) => r.toolName === "reportStatus");
|
|
3586
3615
|
if (!report) {
|
|
3587
|
-
|
|
3616
|
+
const steps = await stream.steps;
|
|
3617
|
+
const lastStep = steps[steps.length - 1];
|
|
3618
|
+
logger.error(
|
|
3619
|
+
{
|
|
3620
|
+
finishReason: lastStep?.finishReason,
|
|
3621
|
+
rawFinishReason: lastStep?.rawFinishReason,
|
|
3622
|
+
stepCount: steps.length,
|
|
3623
|
+
lastStepToolCalls: lastStep?.toolCalls?.map((c) => c.toolName)
|
|
3624
|
+
},
|
|
3625
|
+
"Agent finished without calling reportStatus"
|
|
3626
|
+
);
|
|
3627
|
+
throw new Error(MISSING_REPORT_STATUS_ERROR_MESSAGE);
|
|
3588
3628
|
}
|
|
3589
3629
|
const result = report.output;
|
|
3590
3630
|
if (result.status !== "success") {
|
|
@@ -3707,7 +3747,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3707
3747
|
// package.json
|
|
3708
3748
|
var package_default = {
|
|
3709
3749
|
name: "@algolia/wizard",
|
|
3710
|
-
version: "0.
|
|
3750
|
+
version: "0.25.0",
|
|
3711
3751
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3712
3752
|
type: "module",
|
|
3713
3753
|
engines: {
|