@autonoma-ai/planner 0.1.16 → 0.1.18

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
@@ -284,9 +284,21 @@ function chainMessages(err) {
284
284
  }
285
285
  return parts.join(" \u2190 ").toLowerCase();
286
286
  }
287
+ function apiStatusOf(err) {
288
+ let cur = err;
289
+ for (let depth = 0; cur != null && depth < 10; depth++) {
290
+ if (APICallError.isInstance(cur)) return cur.statusCode;
291
+ if (RetryError.isInstance(cur)) {
292
+ cur = cur.lastError;
293
+ continue;
294
+ }
295
+ cur = cur instanceof Error ? cur.cause : void 0;
296
+ }
297
+ return void 0;
298
+ }
287
299
  function describeKnownError(err) {
288
300
  const msg = chainMessages(err);
289
- const status = APICallError.isInstance(err) ? err.statusCode : void 0;
301
+ const status = apiStatusOf(err);
290
302
  const looksLikeAuth = msg.includes("missing authentication header") || msg.includes("no auth credentials") || msg.includes("not authenticated") || msg.includes("unauthorized") || msg.includes("user not found") || status === 401 || status === 403;
291
303
  if (looksLikeAuth) {
292
304
  return {
@@ -312,6 +324,12 @@ function describeKnownError(err) {
312
324
  hint: "Wait a minute and re-run. If it persists, reach out to support."
313
325
  };
314
326
  }
327
+ if (status === 404 || status === 502 || status === 503 || msg.includes("llm_proxy_unconfigured")) {
328
+ return {
329
+ title: "The Autonoma planner service is temporarily unavailable.",
330
+ hint: "This is on our side, not your setup - retry in a minute, and contact support if it keeps happening. If you set a custom AUTONOMA_API_URL, confirm it points at a host running the planner."
331
+ };
332
+ }
315
333
  return void 0;
316
334
  }
317
335
  function supportReference(extra = {}) {
@@ -378,7 +396,7 @@ var init_errors = __esm({
378
396
  phase;
379
397
  cause;
380
398
  };
381
- FATAL_STATUS_CODES = /* @__PURE__ */ new Set([400, 401, 403, 404, 422]);
399
+ FATAL_STATUS_CODES = /* @__PURE__ */ new Set([400, 401, 402, 403, 404, 422]);
382
400
  RETRYABLE_PROVIDER_QUIRKS = ["corrupted thought signature"];
383
401
  TRANSIENT_MESSAGE_PATTERNS = [
384
402
  "econnreset",
@@ -414,13 +432,14 @@ function getProvider() {
414
432
  function getModel(modelId) {
415
433
  return getProvider().languageModel(modelId ?? readEnv().OPENROUTER_MODEL ?? DEFAULT_MODEL);
416
434
  }
417
- var DEFAULT_MODEL, DEFAULT_API_URL, provider;
435
+ var DEFAULT_MODEL, AI_MAX_RETRIES, DEFAULT_API_URL, provider;
418
436
  var init_model = __esm({
419
437
  "src/core/model.ts"() {
420
438
  "use strict";
421
439
  init_esm_shims();
422
440
  init_env();
423
441
  DEFAULT_MODEL = "google/gemini-3-flash-preview";
442
+ AI_MAX_RETRIES = 10;
424
443
  DEFAULT_API_URL = "https://autonoma.app";
425
444
  }
426
445
  });
@@ -663,6 +682,7 @@ async function runAgent(config, prompt, extractResult) {
663
682
  const tools = typeof config.tools === "function" ? await config.tools(heartbeat) : config.tools;
664
683
  const agent = new ToolLoopAgent({
665
684
  model,
685
+ maxRetries: AI_MAX_RETRIES,
666
686
  instructions: config.systemPrompt,
667
687
  tools,
668
688
  temperature: config.temperature,
@@ -720,6 +740,7 @@ var init_agent = __esm({
720
740
  init_analytics();
721
741
  init_display();
722
742
  init_errors();
743
+ init_model();
723
744
  MAX_RETRIES = 3;
724
745
  STEP_TIMEOUT_MS = 12e4;
725
746
  MAX_NUDGES = 2;
@@ -1223,6 +1244,7 @@ function buildSubagentTool(model, workingDirectory, onHeartbeat, onFileRead) {
1223
1244
  let result;
1224
1245
  const subagent = new ToolLoopAgent2({
1225
1246
  model,
1247
+ maxRetries: AI_MAX_RETRIES,
1226
1248
  instructions: SYSTEM_PROMPT,
1227
1249
  tools: {
1228
1250
  ...buildSubagentTools(workingDirectory, onFileRead),
@@ -1256,6 +1278,7 @@ var init_subagent = __esm({
1256
1278
  "src/tools/subagent.ts"() {
1257
1279
  "use strict";
1258
1280
  init_esm_shims();
1281
+ init_model();
1259
1282
  init_pick_string();
1260
1283
  init_bash();
1261
1284
  init_glob();
@@ -3208,7 +3231,8 @@ async function callRanker(model, prompt) {
3208
3231
  const result = await generateText({
3209
3232
  model,
3210
3233
  prompt,
3211
- output: Output.object({ schema: rankedSchema })
3234
+ output: Output.object({ schema: rankedSchema }),
3235
+ maxRetries: AI_MAX_RETRIES
3212
3236
  });
3213
3237
  return result.output.ranked;
3214
3238
  }
@@ -3289,6 +3313,7 @@ var init_entity_relevance = __esm({
3289
3313
  "use strict";
3290
3314
  init_esm_shims();
3291
3315
  init_errors();
3316
+ init_model();
3292
3317
  rankedSchema = z15.object({
3293
3318
  ranked: z15.array(z15.string()).describe("Every entity name, ordered most-important first.")
3294
3319
  });
@@ -3807,7 +3832,8 @@ async function classifyFailure(model, args) {
3807
3832
  const result = await generateText2({
3808
3833
  model,
3809
3834
  prompt: buildClassifierPrompt(args),
3810
- output: Output2.object({ schema: classificationSchema })
3835
+ output: Output2.object({ schema: classificationSchema }),
3836
+ maxRetries: AI_MAX_RETRIES
3811
3837
  });
3812
3838
  return result.output;
3813
3839
  } catch (err) {
@@ -3820,6 +3846,7 @@ var init_failure_classifier = __esm({
3820
3846
  "use strict";
3821
3847
  init_esm_shims();
3822
3848
  init_errors();
3849
+ init_model();
3823
3850
  classificationSchema = z16.object({
3824
3851
  side: z16.enum(["recipe", "implementation", "unclear"]).describe(
3825
3852
  "recipe = the test data we sent is wrong and regenerating it could fix the failure; implementation = the developer's handler/factory code is wrong and only a code change fixes it; unclear = cannot confidently attribute the failure to either side."
@@ -6249,6 +6276,7 @@ function buildSpawnResearcherTool(model, workingDirectory, onHeartbeat) {
6249
6276
  let result;
6250
6277
  const subagent = new ToolLoopAgent3({
6251
6278
  model,
6279
+ maxRetries: AI_MAX_RETRIES,
6252
6280
  instructions: "You are a code researcher. Read the files specified in your instruction, analyze them, and call finish with a summary of what you found. Focus on: UI elements, forms, buttons, navigation, API calls, state management.",
6253
6281
  tools: {
6254
6282
  bash: buildBashTool(workingDirectory),
@@ -6293,6 +6321,7 @@ var init_tools2 = __esm({
6293
6321
  "src/agents/05-test-generator/tools.ts"() {
6294
6322
  "use strict";
6295
6323
  init_esm_shims();
6324
+ init_model();
6296
6325
  init_tools();
6297
6326
  init_graph();
6298
6327
  init_validation();