@atolis-hq/wake 0.3.48 → 0.3.49

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.
@@ -108,4 +108,4 @@ export function resolveWakeVersion(options = {}) {
108
108
  return `g${headHash.slice(0, 7)}`;
109
109
  return '0.1.0-dev';
110
110
  }
111
- export const wakeVersion = "g6d47388";
111
+ export const wakeVersion = "g2b6df21";
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-lines */
1
2
  import { ActivityOutcomeKind, ReviewActorKind, ReviewDecisionKind, ReviewerAuthorizationSource, createPullRequestService, isReviewAuthorized, } from '../../../activities/index.js';
2
3
  import { ApprovalAuthorityKind } from '../../../orchestration/index.js';
3
4
  import { BuiltInResourceKind, ResourceCorrelationRole, ResourceStreamKind, resourceId, } from '../../../resources/index.js';
@@ -52,6 +53,7 @@ async function applyFormalReviewSignal(input) {
52
53
  await applyPullRequestWorkflowSignal({
53
54
  event,
54
55
  resources,
56
+ work,
55
57
  lookup,
56
58
  orchestration,
57
59
  adapter,
@@ -88,6 +90,7 @@ async function applyIssueReviewSignal(input) {
88
90
  await applyWorkflowSignal({
89
91
  event,
90
92
  resources,
93
+ work,
91
94
  orchestration,
92
95
  resourceId: resourceIdValue,
93
96
  outcome: command === '/approved' ? ActivityOutcomeKind.Done : ActivityOutcomeKind.Rejected,
@@ -102,6 +105,7 @@ async function applyIssueReviewSignal(input) {
102
105
  await applyWorkflowSignal({
103
106
  event,
104
107
  resources,
108
+ work,
105
109
  orchestration,
106
110
  resourceId: resourceIdValue,
107
111
  outcome: ActivityOutcomeKind.Rejected,
@@ -112,7 +116,7 @@ async function applyIssueReviewSignal(input) {
112
116
  }
113
117
  async function applyIssueRetrySignal(input) {
114
118
  const { event, resources, work, orchestration, resourceId: resourceIdValue } = input;
115
- if (work === undefined || orchestration === undefined)
119
+ if (orchestration === undefined)
116
120
  return;
117
121
  if (!isReviewAuthorized({
118
122
  actorId: event.payload.actor.id,
@@ -128,14 +132,13 @@ async function applyIssueRetrySignal(input) {
128
132
  if (!workItemIds.includes(workflow.workItemId) ||
129
133
  workflow.parentWorkflowInstanceId !== undefined)
130
134
  continue;
131
- const item = await work.get(workflow.workItemId);
132
- if (item === null || item.deleted || item.frozen || item.state !== WorkStatus.Open)
135
+ if (!(await isEligibleWorkItem(work, workflow.workItemId)))
133
136
  continue;
134
137
  await ignoreIneligibleOperatorRetry(() => orchestration.retryBlockedFailedStage(workflow.workflowInstanceId, commandContext(event)));
135
138
  }
136
139
  }
137
140
  async function applyIssueApprovalSignal(input) {
138
- const { event, command, resources, lookup, orchestration, adapter } = input;
141
+ const { event, command, resources, work, lookup, orchestration, adapter } = input;
139
142
  if (resources === undefined || lookup === undefined || orchestration === undefined)
140
143
  return;
141
144
  const resourceIdValue = await lookup.resourceIdForExternalKey({
@@ -147,6 +150,7 @@ async function applyIssueApprovalSignal(input) {
147
150
  await applyWorkflowSignal({
148
151
  event,
149
152
  resources,
153
+ work,
150
154
  orchestration,
151
155
  resourceId: resourceIdValue,
152
156
  outcome: command === '/approved' ? ActivityOutcomeKind.Done : ActivityOutcomeKind.Rejected,
@@ -154,7 +158,7 @@ async function applyIssueApprovalSignal(input) {
154
158
  });
155
159
  }
156
160
  async function applyPullRequestWorkflowSignal(input) {
157
- const { event, lookup, resources, orchestration, adapter, outcome } = input;
161
+ const { event, lookup, resources, work, orchestration, adapter, outcome } = input;
158
162
  if (event.payload.actor.kind !== ReviewActorKind.Human ||
159
163
  lookup === undefined ||
160
164
  resources === undefined ||
@@ -169,19 +173,22 @@ async function applyPullRequestWorkflowSignal(input) {
169
173
  await applyWorkflowSignal({
170
174
  event,
171
175
  resources,
176
+ work,
172
177
  orchestration,
173
178
  resourceId: resourceIdValue,
174
179
  outcome,
175
180
  });
176
181
  }
177
182
  async function applyWorkflowSignal(input) {
178
- const { event, resources, orchestration, resourceId: resourceIdValue, outcome, acceptWaitingSignal = true, resumeBlockedOnChanges = false, } = input;
183
+ const { event, resources, work, orchestration, resourceId: resourceIdValue, outcome, acceptWaitingSignal = true, resumeBlockedOnChanges = false, } = input;
179
184
  const workItemIds = (await resources.correlations(resourceIdValue))
180
185
  .filter((correlation) => correlation.role === ResourceCorrelationRole.Primary)
181
186
  .map((correlation) => correlation.workItemId);
182
187
  for (const workflow of await orchestration.listAll()) {
183
188
  if (!workItemIds.includes(workflow.workItemId))
184
189
  continue;
190
+ if (!(await isEligibleWorkItem(work, workflow.workItemId)))
191
+ continue;
185
192
  if (workflow.waitingFor !== undefined && acceptWaitingSignal) {
186
193
  await orchestration.acceptSignal(workflow.workflowInstanceId, {
187
194
  kind: workflow.waitingFor.signalKind,
@@ -202,3 +209,7 @@ async function applyWorkflowSignal(input) {
202
209
  }
203
210
  }
204
211
  }
212
+ async function isEligibleWorkItem(work, workItemId) {
213
+ const item = await work.get(workItemId);
214
+ return item?.state === WorkStatus.Open && !item.deleted && !item.frozen;
215
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/wake",
3
- "version": "0.3.48",
3
+ "version": "0.3.49",
4
4
  "description": "Local autonomous agent control plane for software development",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {