@wrenautomation/aerie 0.5.0 → 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 +40 -8
- package/dist/bin.js.map +4 -4
- package/dist/deadline.d.ts +2 -0
- package/dist/deadline.js +20 -0
- package/dist/deadline.js.map +1 -0
- package/dist/run/adapters.d.ts +3 -1
- package/dist/run/adapters.js +15 -3
- package/dist/run/adapters.js.map +1 -1
- package/dist/run/route.d.ts +7 -2
- package/dist/run/route.js +8 -4
- package/dist/run/route.js.map +1 -1
- package/dist/run/worker.js +2 -1
- package/dist/run/worker.js.map +1 -1
- package/package.json +1 -1
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";
|
|
@@ -36654,7 +36670,7 @@ function grokRunner(o = {}) {
|
|
|
36654
36670
|
}
|
|
36655
36671
|
};
|
|
36656
36672
|
}
|
|
36657
|
-
var DO_LINE = /^(done|needs-human|failed|planned) via (\S+)(?: (
|
|
36673
|
+
var DO_LINE = /^(done|needs-human|failed|planned) via (\S+)(?: ([^:]+))?: (.*)$/;
|
|
36658
36674
|
function autobrowseRunner(o = {}) {
|
|
36659
36675
|
return {
|
|
36660
36676
|
name: "autobrowse-do",
|
|
@@ -36705,14 +36721,25 @@ function apiRunner(o) {
|
|
|
36705
36721
|
async run(t, ctx) {
|
|
36706
36722
|
const { modelFromSpec } = await import("@wrenautomation/models/spec");
|
|
36707
36723
|
const spec = ctx.model ?? o.spec;
|
|
36724
|
+
if (!spec)
|
|
36725
|
+
return {
|
|
36726
|
+
outcome: "needs-input",
|
|
36727
|
+
summary: "no model for the api runner",
|
|
36728
|
+
question: `No model for ${t.id} on the api runner: set AERIE_API_MODEL, or a route rule with a model?`
|
|
36729
|
+
};
|
|
36708
36730
|
const m = modelFromSpec(spec, { ...process.env, ...o.env, ...ctx.env });
|
|
36709
36731
|
await ctx.emit({ kind: "init", text: m.id, data: { spec, model: m.id } });
|
|
36710
36732
|
try {
|
|
36711
|
-
const { value, usage } = await
|
|
36712
|
-
|
|
36733
|
+
const { value, usage } = await withDeadline(
|
|
36734
|
+
o.timeoutMs ?? 12e4,
|
|
36735
|
+
ctx.signal,
|
|
36736
|
+
(signal) => m.ask(
|
|
36737
|
+
`${promptOf(t, ctx.answers)}
|
|
36713
36738
|
|
|
36714
36739
|
You have no tools. Answer as JSON: outcome (done, needs-input or failed), summary, and question when a person must decide.`,
|
|
36715
|
-
|
|
36740
|
+
ApiAnswer,
|
|
36741
|
+
{ signal }
|
|
36742
|
+
)
|
|
36716
36743
|
);
|
|
36717
36744
|
await ctx.emit({ kind: "say", text: value.summary, data: { value, usage } });
|
|
36718
36745
|
return {
|
|
@@ -36749,7 +36776,10 @@ function headlessRunners(get2) {
|
|
|
36749
36776
|
codexRunner(opt("codex")),
|
|
36750
36777
|
grokRunner(opt("grok")),
|
|
36751
36778
|
autobrowseRunner(opt("autobrowse")),
|
|
36752
|
-
apiRunner({
|
|
36779
|
+
apiRunner({
|
|
36780
|
+
spec: get2("AERIE_API_MODEL"),
|
|
36781
|
+
timeoutMs: Number(get2("AERIE_API_TIMEOUT_MS")) || void 0
|
|
36782
|
+
})
|
|
36753
36783
|
];
|
|
36754
36784
|
return new Map(rs.map((r) => [r.name, r]));
|
|
36755
36785
|
}
|
|
@@ -36838,15 +36868,17 @@ async function route(a, coord, id, by, pick2) {
|
|
|
36838
36868
|
await coord.queueAdd([t.id], queueSpot(r));
|
|
36839
36869
|
return r;
|
|
36840
36870
|
}
|
|
36871
|
+
var RUN_FAILED = "Run failed";
|
|
36841
36872
|
async function afterDecision(a, coord, d, by, pick2) {
|
|
36842
36873
|
const out = [];
|
|
36874
|
+
const worker = d.askedBy.startsWith("runner:") && d.question.startsWith(`${RUN_FAILED} `);
|
|
36843
36875
|
for (const id of d.blocks) {
|
|
36844
36876
|
const t = await a.get(id);
|
|
36845
36877
|
if (t?.status !== "To Do" || !await a.lastEvent(t.id, "run.start")) continue;
|
|
36846
|
-
if (d.answer === "william") {
|
|
36878
|
+
if (worker && d.answer === "william") {
|
|
36847
36879
|
await a.edit(t.id, { assignees: ["@william"] }, by, { why: `decision ${d.id}` });
|
|
36848
36880
|
out.push({ id: t.id, lane: null });
|
|
36849
|
-
} else if (d.answer === "session") {
|
|
36881
|
+
} else if (worker && d.answer === "session") {
|
|
36850
36882
|
await a.log(
|
|
36851
36883
|
t.id,
|
|
36852
36884
|
by,
|
|
@@ -36974,7 +37006,7 @@ async function workOnce(o) {
|
|
|
36974
37006
|
}
|
|
36975
37007
|
const d2 = await store.ask(
|
|
36976
37008
|
{
|
|
36977
|
-
question:
|
|
37009
|
+
question: `${RUN_FAILED} ${fails} times on ${runner.name}: what next for ${id}?`,
|
|
36978
37010
|
options: [
|
|
36979
37011
|
{ key: "retry", text: `run it on ${runner.name} again` },
|
|
36980
37012
|
{ key: "session", text: "give it to a live session" },
|