next-issue 6.6.97 → 6.6.99

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/README.md CHANGED
@@ -163,8 +163,10 @@ the run handles one issue. For each issue:
163
163
  default branch as its commit. It also leaves out the `push` runs that a
164
164
  push of a tag or of another branch started on the same commit, such as
165
165
  a release or a deploy. A failed or errored commit status, or a
166
- check run that ends with `failure`, `timed_out` or `action_required`,
167
- fails the checks. When any check ends `cancelled`, for example because
166
+ workflow run or check run that ends with `failure`, `timed_out` or
167
+ `action_required`, fails the checks. The harness does not rerun a
168
+ workflow run that ends `action_required`, since it waits for a person
169
+ to approve it. When any check ends `cancelled`, for example because
168
170
  a later push cancelled the workflow run, that check never finished,
169
171
  even when another check (such as a release workflow) ends `success`:
170
172
  the harness hands the issue to a person with the reason
package/dist/agents.mjs CHANGED
@@ -27,15 +27,31 @@ export async function runAgent(recorder, request) {
27
27
  process.argv[1] = PI_CLI;
28
28
  log.event('agent.start', { model: request.model, timeoutMs: request.timeoutMs });
29
29
  const session = await openSession(recorder, log, request, agentDir);
30
- const timer = deadline(request.timeoutMs, () => void session.abort());
30
+ // pi drops an abort that comes before its run starts (during bindExtensions or the prompt
31
+ // preflight), so remember it and abort again once the run is active, before its first turn.
32
+ let ended = false;
33
+ const end = () => {
34
+ ended = true;
35
+ void session.abort();
36
+ };
37
+ const timer = deadline(request.timeoutMs, end);
31
38
  const unsubscribe = session.subscribe((event) => observe(log, event));
32
- const release = onStop(() => void session.abort());
39
+ const release = onStop(end);
33
40
  try {
34
41
  refuseWhenStopped();
35
42
  await session.bindExtensions({});
36
43
  let result;
37
44
  try {
38
- await session.prompt(request.prompt, { expandPromptTemplates: false });
45
+ if (!ended) {
46
+ await session.prompt(request.prompt, {
47
+ expandPromptTemplates: false,
48
+ preflightResult: (disposition) => {
49
+ if (disposition === 'started' && ended) {
50
+ void session.abort();
51
+ }
52
+ },
53
+ });
54
+ }
39
55
  }
40
56
  finally {
41
57
  // A call that times out, fails or is stopped has spent tokens too.
@@ -6,7 +6,8 @@ import { runLogs } from './run-logs.mjs';
6
6
  const RESTART_TRIES = 10;
7
7
  const ACTIONS_APP = 'github-actions';
8
8
  const FAILED_STATES = new Set(['failure', 'error']);
9
- const FAILED_CONCLUSIONS = new Set(['failure', 'timed_out', 'startup_failure']);
9
+ const AWAITS_APPROVAL = 'action_required';
10
+ const FAILED_CONCLUSIONS = new Set(['failure', 'timed_out', 'startup_failure', AWAITS_APPROVAL]);
10
11
  function jsonLines(raw) {
11
12
  return raw
12
13
  .split('\n')
@@ -70,7 +71,7 @@ export function waitForBaseChecks(repo, sha, branch, options) {
70
71
  }, options);
71
72
  }
72
73
  export async function rerunFailedBase(repo, sha, branch, started = () => { }) {
73
- const failed = (await baseRuns(repo, sha, branch)).filter(failedRun);
74
+ const failed = (await baseRuns(repo, sha, branch)).filter((entry) => failedRun(entry) && entry.conclusion !== AWAITS_APPROVAL);
74
75
  for (const entry of failed) {
75
76
  await gh(repo, ['run', 'rerun', String(entry.databaseId), '--failed']);
76
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-issue",
3
- "version": "6.6.97",
3
+ "version": "6.6.99",
4
4
  "description": "Autonomous issue harness driven by the pi SDK",
5
5
  "keywords": [
6
6
  "github",