agents-relay 2.0.239 → 2.0.240

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.
@@ -40,15 +40,33 @@ export function deriveJobRuntimeStatus(job, _prState = 'OPEN') {
40
40
  // scheduler queue. Do not advertise a not-yet-invoked Shortcut as QUEUED,
41
41
  // or a content-only Shortcut as pending a PR merge/review.
42
42
  if (job.executionMode === 'shortcut' && job.contentOnly === true) {
43
+ const now = Date.now();
44
+ const hasLiveLease = (task) => task.state === 'RUNNING'
45
+ && Boolean(task.executionId && task.leaseOwner && task.leaseExpiresAt)
46
+ && Number.isFinite(Date.parse(task.leaseExpiresAt)) && Date.parse(task.leaseExpiresAt) > now;
43
47
  const children = job.tasks.filter(task => task.parentTaskId !== null);
44
- if (children.some(task => task.state === 'BLOCKED') && !children.some(task => task.state === 'RUNNING'))
48
+ if (children.some(task => task.state === 'BLOCKED') && !children.some(hasLiveLease))
45
49
  return 'BLOCKED';
46
- if (children.some(task => task.state === 'FAILED') && !children.some(task => task.state === 'RUNNING'))
50
+ if (children.some(task => task.state === 'FAILED') && !children.some(hasLiveLease))
47
51
  return 'FAILED';
52
+ if (job.tasks.some(task => task.state === 'FAILED') && !job.tasks.some(hasLiveLease))
53
+ return 'FAILED';
54
+ if (job.pause)
55
+ return 'WAITING';
48
56
  if (job.tasks.some(task => task.state === 'AWAITING_DECISION'))
49
57
  return 'WAITING';
50
- if (job.tasks.some(task => task.state === 'RUNNING'))
58
+ if (job.tasks.some(hasLiveLease))
51
59
  return 'RUNNING';
60
+ const running = job.tasks.filter(task => task.state === 'RUNNING');
61
+ // WAITING_EVENT intentionally releases the runner lease but keeps the Task
62
+ // RUNNING until its correlated event receipt arrives.
63
+ if (running.some(task => task.leaseOwner === null && Boolean(task.executionId)
64
+ && Object.values(task.result?.data?.shortcut?.waits ?? {})
65
+ .some(wait => wait.executionId === task.executionId)))
66
+ return 'WAITING';
67
+ // A RUNNING Task without a current lease or event wait is not executing.
68
+ if (running.length > 0)
69
+ return 'BLOCKED';
52
70
  return 'WAITING'; // External Shortcut Runner has not started or needs a resume.
53
71
  }
54
72
  const currentPlan = job.plans?.at(-1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-relay",
3
- "version": "2.0.239",
3
+ "version": "2.0.240",
4
4
  "description": "Durable async agent jobs coordinated through GitHub pull requests",
5
5
  "repository": {
6
6
  "type": "git",