@algolia/wizard 0.101.0 → 0.102.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.
Files changed (2) hide show
  1. package/dist/main.js +29 -8
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -2447,7 +2447,7 @@ async function ensureApplication(resumeAppId) {
2447
2447
  // package.json
2448
2448
  var package_default = {
2449
2449
  name: "@algolia/wizard",
2450
- version: "0.101.0",
2450
+ version: "0.102.0",
2451
2451
  description: "Magically implement Algolia functionality in your codebase",
2452
2452
  type: "module",
2453
2453
  engines: {
@@ -3075,7 +3075,6 @@ var selectIndexStep = async (ctx) => {
3075
3075
  // src/lib/agent.ts
3076
3076
  import {
3077
3077
  ToolLoopAgent,
3078
- hasToolCall,
3079
3078
  Output as Output3,
3080
3079
  APICallError,
3081
3080
  NoOutputGeneratedError,
@@ -3289,6 +3288,19 @@ function changeDirectoryTool(ctx) {
3289
3288
  // src/lib/tools/reportStatus.ts
3290
3289
  import { tool as tool3 } from "ai";
3291
3290
  import z8 from "zod";
3291
+ var PLACEHOLDER_REPORT_REFUSAL = 'Refused: reportStatus got the placeholder text "placeholder" instead of a real result. The task is not finished. Continue the task, then call reportStatus with the real status, reason, and output.';
3292
+ var PLACEHOLDER_VALUE = /^\s*placeholder\s*$/i;
3293
+ function isPlaceholder(value) {
3294
+ return typeof value === "string" && PLACEHOLDER_VALUE.test(value);
3295
+ }
3296
+ function hasPlaceholder(reason, output) {
3297
+ if (isPlaceholder(reason)) return true;
3298
+ if (typeof output !== "object" || output === null) return false;
3299
+ return Object.values(output).some(isPlaceholder);
3300
+ }
3301
+ function isAcceptedReport(result) {
3302
+ return typeof result === "object" && result !== null && "status" in result && !("rejected" in result);
3303
+ }
3292
3304
  function reportStatusTool(output) {
3293
3305
  return tool3({
3294
3306
  description: "Report the status of your execution. Return a reason in case of failure.",
@@ -3298,6 +3310,10 @@ function reportStatusTool(output) {
3298
3310
  output
3299
3311
  }),
3300
3312
  execute: async ({ status, reason, output: output2 }) => {
3313
+ if (hasPlaceholder(reason, output2)) {
3314
+ logger.warn({ status, reason }, "reportStatus: refused a placeholder report");
3315
+ return { rejected: true, message: PLACEHOLDER_REPORT_REFUSAL };
3316
+ }
3301
3317
  logger.info({ status, reason }, "called reportStatus tool");
3302
3318
  return { status, reason, output: output2 };
3303
3319
  }
@@ -5471,6 +5487,14 @@ function withCachedHistory(messages) {
5471
5487
  }
5472
5488
  ];
5473
5489
  }
5490
+ function isAcceptedReportResult(result) {
5491
+ return result.toolName === "reportStatus" && isAcceptedReport(result.output);
5492
+ }
5493
+ function reportAccepted({
5494
+ steps
5495
+ }) {
5496
+ return steps.at(-1)?.toolResults?.some(isAcceptedReportResult) ?? false;
5497
+ }
5474
5498
  function isMissingReportRetry(kind) {
5475
5499
  return kind === "missingReport" || incompleteReasonOf(kind) !== void 0;
5476
5500
  }
@@ -5590,10 +5614,7 @@ async function runAgentAttempt(req, attempt, retryReason) {
5590
5614
  tools: req.tools
5591
5615
  }),
5592
5616
  toolChoice: "required",
5593
- stopWhen: [
5594
- hasToolCall("reportStatus"),
5595
- stepCountIs(maxSteps)
5596
- ],
5617
+ stopWhen: [reportAccepted, stepCountIs(maxSteps)],
5597
5618
  prepareStep: ({ stepNumber, messages }) => ({
5598
5619
  messages: withCachedHistory(messages),
5599
5620
  ...stepNumber >= maxSteps - 1 && {
@@ -5675,7 +5696,7 @@ async function runAgentAttempt(req, attempt, retryReason) {
5675
5696
  "tool usage"
5676
5697
  );
5677
5698
  const toolResults = await stream.toolResults;
5678
- const report = [...toolResults].reverse().find((r) => r.toolName === "reportStatus");
5699
+ const report = [...toolResults].reverse().find(isAcceptedReportResult);
5679
5700
  if (!report) {
5680
5701
  logger.error(
5681
5702
  {
@@ -10052,7 +10073,7 @@ async function resetProjectState() {
10052
10073
  // package.json with { type: 'json' }
10053
10074
  var package_default2 = {
10054
10075
  name: "@algolia/wizard",
10055
- version: "0.101.0",
10076
+ version: "0.102.0",
10056
10077
  description: "Magically implement Algolia functionality in your codebase",
10057
10078
  type: "module",
10058
10079
  engines: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algolia/wizard",
3
- "version": "0.101.0",
3
+ "version": "0.102.0",
4
4
  "description": "Magically implement Algolia functionality in your codebase",
5
5
  "type": "module",
6
6
  "engines": {