@wrenautomation/aerie 0.5.1 → 0.5.2

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/bin.js CHANGED
@@ -36427,6 +36427,22 @@ function date4(params) {
36427
36427
  return _coercedDate(ZodDate, params);
36428
36428
  }
36429
36429
 
36430
+ // src/deadline.ts
36431
+ async function withDeadline(ms2, outer, call) {
36432
+ const signal = AbortSignal.any([AbortSignal.timeout(ms2), ...outer ? [outer] : []]);
36433
+ let stop;
36434
+ const stopped = new Promise((_, reject) => {
36435
+ stop = () => reject(new Error(outer?.aborted ? "aborted" : `no answer in ${Math.round(ms2 / 1e3)} s`));
36436
+ if (signal.aborted) stop();
36437
+ else signal.addEventListener("abort", stop, { once: true });
36438
+ });
36439
+ try {
36440
+ return await Promise.race([call(signal), stopped]);
36441
+ } finally {
36442
+ if (stop) signal.removeEventListener("abort", stop);
36443
+ }
36444
+ }
36445
+
36430
36446
  // src/run/spawn.ts
36431
36447
  init_db2();
36432
36448
  import { spawn } from "node:child_process";
@@ -36714,11 +36730,16 @@ function apiRunner(o) {
36714
36730
  const m = modelFromSpec(spec, { ...process.env, ...o.env, ...ctx.env });
36715
36731
  await ctx.emit({ kind: "init", text: m.id, data: { spec, model: m.id } });
36716
36732
  try {
36717
- const { value, usage } = await m.ask(
36718
- `${promptOf(t, ctx.answers)}
36733
+ const { value, usage } = await withDeadline(
36734
+ o.timeoutMs ?? 12e4,
36735
+ ctx.signal,
36736
+ (signal) => m.ask(
36737
+ `${promptOf(t, ctx.answers)}
36719
36738
 
36720
36739
  You have no tools. Answer as JSON: outcome (done, needs-input or failed), summary, and question when a person must decide.`,
36721
- ApiAnswer
36740
+ ApiAnswer,
36741
+ { signal }
36742
+ )
36722
36743
  );
36723
36744
  await ctx.emit({ kind: "say", text: value.summary, data: { value, usage } });
36724
36745
  return {
@@ -36755,7 +36776,10 @@ function headlessRunners(get2) {
36755
36776
  codexRunner(opt("codex")),
36756
36777
  grokRunner(opt("grok")),
36757
36778
  autobrowseRunner(opt("autobrowse")),
36758
- apiRunner({ spec: get2("AERIE_API_MODEL") })
36779
+ apiRunner({
36780
+ spec: get2("AERIE_API_MODEL"),
36781
+ timeoutMs: Number(get2("AERIE_API_TIMEOUT_MS")) || void 0
36782
+ })
36759
36783
  ];
36760
36784
  return new Map(rs.map((r) => [r.name, r]));
36761
36785
  }