@autonoma-ai/planner 0.1.11 → 0.1.13

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/index.js CHANGED
@@ -302,6 +302,10 @@ function classifyAgentError(err) {
302
302
  if (msg.includes("timed out") || msg.includes("timeout") || msg.includes("abort")) {
303
303
  return "timeout";
304
304
  }
305
+ const chain = chainMessages(err);
306
+ if (RETRYABLE_PROVIDER_QUIRKS.some((pattern) => chain.includes(pattern))) {
307
+ return "transient";
308
+ }
305
309
  if (APICallError.isInstance(err)) {
306
310
  if (err.statusCode != null && FATAL_STATUS_CODES.has(err.statusCode)) return "fatal";
307
311
  return "transient";
@@ -320,7 +324,7 @@ function classifyAgentError(err) {
320
324
  }
321
325
  return "transient";
322
326
  }
323
- var AgentError, FATAL_STATUS_CODES, TRANSIENT_MESSAGE_PATTERNS;
327
+ var AgentError, FATAL_STATUS_CODES, RETRYABLE_PROVIDER_QUIRKS, TRANSIENT_MESSAGE_PATTERNS;
324
328
  var init_errors = __esm({
325
329
  "src/core/errors.ts"() {
326
330
  "use strict";
@@ -338,6 +342,7 @@ var init_errors = __esm({
338
342
  cause;
339
343
  };
340
344
  FATAL_STATUS_CODES = /* @__PURE__ */ new Set([400, 401, 403, 404, 422]);
345
+ RETRYABLE_PROVIDER_QUIRKS = ["corrupted thought signature"];
341
346
  TRANSIENT_MESSAGE_PATTERNS = [
342
347
  "econnreset",
343
348
  "econnrefused",
@@ -1407,7 +1412,7 @@ var init_pages_finder = __esm({
1407
1412
  import * as p3 from "@clack/prompts";
1408
1413
  import { access } from "fs/promises";
1409
1414
  import { join as join12, isAbsolute } from "path";
1410
- import { spawn } from "child_process";
1415
+ import spawn from "cross-spawn";
1411
1416
  import which from "which";
1412
1417
  function resolvePath(artifact, outputDir) {
1413
1418
  if (isAbsolute(artifact)) return artifact;
@@ -1425,13 +1430,28 @@ async function detectEditors() {
1425
1430
  }
1426
1431
  async function launchEditor(editor, files) {
1427
1432
  const args = editor.args(files);
1428
- const proc = spawn(editor.command, args, { stdio: "inherit" });
1429
- if (["nano", "vim"].includes(editor.command)) {
1430
- await new Promise((resolve5, reject) => {
1431
- proc.on("close", () => resolve5());
1432
- proc.on("error", reject);
1433
+ const isTerminalEditor = TERMINAL_EDITORS.has(editor.command);
1434
+ await new Promise((resolve5) => {
1435
+ let settled = false;
1436
+ const settle = () => {
1437
+ if (settled) return;
1438
+ settled = true;
1439
+ resolve5();
1440
+ };
1441
+ const proc = spawn(editor.command, args, { stdio: "inherit" });
1442
+ proc.on("error", (err) => {
1443
+ p3.log.warn(
1444
+ `Couldn't open ${editor.label} (${err.message}). Review the files manually:`
1445
+ );
1446
+ for (const f of files) console.log(` ${CYAN2}${f}${RESET3}`);
1447
+ settle();
1433
1448
  });
1434
- }
1449
+ if (isTerminalEditor) {
1450
+ proc.on("close", () => settle());
1451
+ } else {
1452
+ proc.on("spawn", () => settle());
1453
+ }
1454
+ });
1435
1455
  }
1436
1456
  async function openInEditor(files) {
1437
1457
  const editors = await detectEditors();
@@ -1548,7 +1568,7 @@ async function reviewLoop(result, options) {
1548
1568
  await showResults(result, options);
1549
1569
  }
1550
1570
  }
1551
- var DIM3, CYAN2, GREEN2, RESET3, EDITORS, cachedEditors, preferredEditor;
1571
+ var DIM3, CYAN2, GREEN2, RESET3, EDITORS, cachedEditors, preferredEditor, TERMINAL_EDITORS;
1552
1572
  var init_review = __esm({
1553
1573
  "src/core/review.ts"() {
1554
1574
  "use strict";
@@ -1567,6 +1587,7 @@ var init_review = __esm({
1567
1587
  ];
1568
1588
  cachedEditors = null;
1569
1589
  preferredEditor = null;
1590
+ TERMINAL_EDITORS = /* @__PURE__ */ new Set(["nano", "vim"]);
1570
1591
  }
1571
1592
  });
1572
1593
 
@@ -3795,7 +3816,7 @@ import * as p5 from "@clack/prompts";
3795
3816
  import { writeFile as writeFile8, readFile as readFile16 } from "fs/promises";
3796
3817
  import { join as join23 } from "path";
3797
3818
  import { tmpdir } from "os";
3798
- import { spawn as spawn2 } from "child_process";
3819
+ import spawn2 from "cross-spawn";
3799
3820
  import { tool as tool14 } from "ai";
3800
3821
  import { z as z17 } from "zod";
3801
3822
  function summarizeCompletedAliases(completedEntities, excludeName) {
@@ -4006,11 +4027,17 @@ async function reviewRecipeData(entityName, entityIndex, totalEntities, proposed
4006
4027
  await writeFile8(tmpPath, JSON.stringify(proposed, null, 2), "utf-8");
4007
4028
  const editor = process.env.EDITOR ?? process.env.VISUAL ?? "vi";
4008
4029
  p5.log.info(`Opening ${editor}... Save and close when done.`);
4009
- await new Promise((resolve5, reject) => {
4030
+ const launched = await new Promise((resolve5) => {
4010
4031
  const proc = spawn2(editor, [tmpPath], { stdio: "inherit" });
4011
- proc.on("close", () => resolve5());
4012
- proc.on("error", reject);
4032
+ proc.on("close", () => resolve5(true));
4033
+ proc.on("error", (err) => {
4034
+ p5.log.error(
4035
+ `Couldn't open ${editor} (${err.message}). Edit this file manually, then choose "edit" again: ${tmpPath}`
4036
+ );
4037
+ resolve5(false);
4038
+ });
4013
4039
  });
4040
+ if (!launched) continue;
4014
4041
  const edited = await readFile16(tmpPath, "utf-8");
4015
4042
  try {
4016
4043
  proposed = JSON.parse(edited);