@algolia/wizard 0.24.0 → 0.26.0-rc.118.217
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 +58 -26
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1922,8 +1922,20 @@ function reconcileWorkflowState(state, workflow) {
|
|
|
1922
1922
|
const definedIds = workflow.steps.map((s) => s.id).join("\n");
|
|
1923
1923
|
if (persistedIds !== definedIds) return null;
|
|
1924
1924
|
for (let i = 0; i < state.steps.length; i++) {
|
|
1925
|
-
|
|
1926
|
-
|
|
1925
|
+
const record = state.steps[i];
|
|
1926
|
+
const step = workflow.steps[i];
|
|
1927
|
+
if (record.status === "done") {
|
|
1928
|
+
const parsed = step.outputSchema.safeParse(record.output);
|
|
1929
|
+
if (!parsed.success) {
|
|
1930
|
+
logger.warn(
|
|
1931
|
+
{ stepId: step.id, issues: parsed.error.issues },
|
|
1932
|
+
"reconcileWorkflowState: persisted output for a completed step no longer matches its schema; restarting the run from scratch"
|
|
1933
|
+
);
|
|
1934
|
+
return null;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
record.title = step.title;
|
|
1938
|
+
record.visible = step.visible;
|
|
1927
1939
|
}
|
|
1928
1940
|
return state;
|
|
1929
1941
|
}
|
|
@@ -3260,28 +3272,9 @@ import { tool as tool9 } from "ai";
|
|
|
3260
3272
|
import z16 from "zod";
|
|
3261
3273
|
import { stat as stat2 } from "node:fs/promises";
|
|
3262
3274
|
import { relative as relative5 } from "node:path";
|
|
3263
|
-
|
|
3264
|
-
// src/lib/editor.ts
|
|
3265
|
-
import { spawn as spawn3 } from "node:child_process";
|
|
3266
|
-
function openInEditor(filePath) {
|
|
3267
|
-
const { command, args } = process.platform === "darwin" ? (
|
|
3268
|
-
// -t forces the default *text* editor; plain `open` on an extension
|
|
3269
|
-
// with no handler (.mjs, .py) pops a "choose an application" dialog.
|
|
3270
|
-
{ command: "open", args: ["-t", filePath] }
|
|
3271
|
-
) : process.platform === "win32" ? { command: "cmd", args: ["/c", "start", "", filePath] } : { command: "xdg-open", args: [filePath] };
|
|
3272
|
-
try {
|
|
3273
|
-
const child = spawn3(command, args, { stdio: "ignore", detached: true });
|
|
3274
|
-
child.on("error", () => {
|
|
3275
|
-
});
|
|
3276
|
-
child.unref();
|
|
3277
|
-
} catch {
|
|
3278
|
-
}
|
|
3279
|
-
}
|
|
3280
|
-
|
|
3281
|
-
// src/lib/tools/reviewScript.ts
|
|
3282
3275
|
function reviewScriptTool(ctx) {
|
|
3283
3276
|
return tool9({
|
|
3284
|
-
description: "Show a script you have written to the user and wait while they read it. Call this as soon as the script is finished and before you run it for the first time, so nothing with a side effect happens behind their back. It
|
|
3277
|
+
description: "Show a script you have written to the user and wait while they read it. Call this as soon as the script is finished and before you run it for the first time, so nothing with a side effect happens behind their back. It shows the file path and returns once they have confirmed reviewing it.",
|
|
3285
3278
|
inputSchema: z16.object({
|
|
3286
3279
|
filePath: z16.string().describe(
|
|
3287
3280
|
"Path to the script to review, relative to the project root."
|
|
@@ -3299,7 +3292,6 @@ function reviewScriptTool(ctx) {
|
|
|
3299
3292
|
return `Refused: ${filePath} is not a file. Write the script first, then review the path you wrote.`;
|
|
3300
3293
|
}
|
|
3301
3294
|
return serializePrompt(async () => {
|
|
3302
|
-
openInEditor(resolved2.target);
|
|
3303
3295
|
await useWizard.getState().requestUserInput({
|
|
3304
3296
|
prompt: "",
|
|
3305
3297
|
promptType: "enterToContinue",
|
|
@@ -3497,7 +3489,30 @@ var MODEL_BY_SIZE = {
|
|
|
3497
3489
|
medium: "claude-sonnet-4-6",
|
|
3498
3490
|
large: "claude-opus-4-8"
|
|
3499
3491
|
};
|
|
3492
|
+
var MISSING_REPORT_STATUS_ERROR_MESSAGE = "Agent finished without calling reportStatus";
|
|
3493
|
+
var MISSING_REPORT_USER_MESSAGE = "This step ran into a problem finishing. Run the wizard again to retry it.";
|
|
3494
|
+
var REPORT_STATUS_RETRIES = 2;
|
|
3500
3495
|
async function runAgent(req) {
|
|
3496
|
+
for (let attempt = 0; attempt <= REPORT_STATUS_RETRIES; attempt++) {
|
|
3497
|
+
try {
|
|
3498
|
+
return await runAgentAttempt(req, attempt);
|
|
3499
|
+
} catch (err) {
|
|
3500
|
+
const isMissingReport = err instanceof Error && err.message === MISSING_REPORT_STATUS_ERROR_MESSAGE;
|
|
3501
|
+
if (!isMissingReport) {
|
|
3502
|
+
throw err;
|
|
3503
|
+
}
|
|
3504
|
+
if (attempt === REPORT_STATUS_RETRIES) {
|
|
3505
|
+
throw new Error(MISSING_REPORT_USER_MESSAGE);
|
|
3506
|
+
}
|
|
3507
|
+
logger.warn(
|
|
3508
|
+
{ attempt: attempt + 1 },
|
|
3509
|
+
"retrying runAgent after missing reportStatus"
|
|
3510
|
+
);
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
throw new Error("unreachable");
|
|
3514
|
+
}
|
|
3515
|
+
async function runAgentAttempt(req, attempt) {
|
|
3501
3516
|
const start = Date.now();
|
|
3502
3517
|
logger.info({ startedAt: new Date(start).toISOString() }, "runAgent started");
|
|
3503
3518
|
const token = getAuthToken();
|
|
@@ -3517,7 +3532,13 @@ async function runAgent(req) {
|
|
|
3517
3532
|
...hasReadTools ? [
|
|
3518
3533
|
"When you need to read or search multiple files, issue those tool calls together in one step rather than one at a time."
|
|
3519
3534
|
] : [],
|
|
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."
|
|
3535
|
+
"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.",
|
|
3536
|
+
// Last so a retry does not bust the cached tools+system prefix from
|
|
3537
|
+
// the first attempt. Inspect-and-continue, not start over: implement
|
|
3538
|
+
// shares the worktree and toolContext across attempts.
|
|
3539
|
+
...attempt > 0 ? [
|
|
3540
|
+
"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."
|
|
3541
|
+
] : []
|
|
3521
3542
|
];
|
|
3522
3543
|
const agent = new ToolLoopAgent({
|
|
3523
3544
|
model: anthropic(MODEL_BY_SIZE[req.modelSize ?? "medium"]),
|
|
@@ -3584,7 +3605,18 @@ async function runAgent(req) {
|
|
|
3584
3605
|
const toolResults = await stream.toolResults;
|
|
3585
3606
|
const report = [...toolResults].reverse().find((r) => r.toolName === "reportStatus");
|
|
3586
3607
|
if (!report) {
|
|
3587
|
-
|
|
3608
|
+
const steps = await stream.steps;
|
|
3609
|
+
const lastStep = steps[steps.length - 1];
|
|
3610
|
+
logger.error(
|
|
3611
|
+
{
|
|
3612
|
+
finishReason: lastStep?.finishReason,
|
|
3613
|
+
rawFinishReason: lastStep?.rawFinishReason,
|
|
3614
|
+
stepCount: steps.length,
|
|
3615
|
+
lastStepToolCalls: lastStep?.toolCalls?.map((c) => c.toolName)
|
|
3616
|
+
},
|
|
3617
|
+
"Agent finished without calling reportStatus"
|
|
3618
|
+
);
|
|
3619
|
+
throw new Error(MISSING_REPORT_STATUS_ERROR_MESSAGE);
|
|
3588
3620
|
}
|
|
3589
3621
|
const result = report.output;
|
|
3590
3622
|
if (result.status !== "success") {
|
|
@@ -3707,7 +3739,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3707
3739
|
// package.json
|
|
3708
3740
|
var package_default = {
|
|
3709
3741
|
name: "@algolia/wizard",
|
|
3710
|
-
version: "0.
|
|
3742
|
+
version: "0.26.0-rc.118.217",
|
|
3711
3743
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3712
3744
|
type: "module",
|
|
3713
3745
|
engines: {
|