patchrelay 0.31.0 → 0.32.1

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.
@@ -1,5 +1,6 @@
1
1
  import { buildAgentSessionPlanForIssue, } from "./agent-session-plan.js";
2
2
  import { buildAgentSessionExternalUrls } from "./agent-session-presentation.js";
3
+ import { TERMINAL_STATES } from "./factory-state.js";
3
4
  import { buildAlreadyRunningThought, buildDelegationThought, buildPromptDeliveredThought, buildStopConfirmationActivity, } from "./linear-session-reporting.js";
4
5
  import { resolveProject, triggerEventAllowed, trustedActorAllowed } from "./project-resolution.js";
5
6
  import { normalizeWebhook } from "./webhooks.js";
@@ -161,8 +162,9 @@ export class WebhookHandler {
161
162
  const hydratedIssue = await this.syncIssueDependencies(project.id, normalizedIssue);
162
163
  const unresolvedBlockers = this.db.countUnresolvedBlockers(project.id, normalizedIssue.id);
163
164
  const pendingRunContextJson = mergePendingImplementationContext(existingIssue?.pendingRunContextJson, normalized);
165
+ const terminalForAutomation = isTerminalDelegationState(existingIssue, hydratedIssue);
164
166
  let pendingRunType;
165
- if (delegated && triggerAllowed && unresolvedBlockers === 0 && !activeRun && !existingIssue?.pendingRunType) {
167
+ if (delegated && triggerAllowed && unresolvedBlockers === 0 && !activeRun && !existingIssue?.pendingRunType && !terminalForAutomation) {
166
168
  pendingRunType = "implementation";
167
169
  }
168
170
  const clearPendingImplementation = unresolvedBlockers > 0 && existingIssue?.pendingRunType === "implementation" && !activeRun;
@@ -537,6 +539,18 @@ export class WebhookHandler {
537
539
  return undefined;
538
540
  }
539
541
  }
542
+ function isResolvedLinearState(stateType, stateName) {
543
+ return stateType === "completed" || stateName?.trim().toLowerCase() === "done";
544
+ }
545
+ function isTerminalDelegationState(existingIssue, hydratedIssue) {
546
+ if (existingIssue?.prState === "merged") {
547
+ return true;
548
+ }
549
+ if (existingIssue?.factoryState && TERMINAL_STATES.has(existingIssue.factoryState)) {
550
+ return true;
551
+ }
552
+ return isResolvedLinearState(hydratedIssue.stateType, hydratedIssue.stateName);
553
+ }
540
554
  function hasCompleteIssueContext(issue) {
541
555
  return Boolean(issue.stateName && issue.delegateId && issue.teamId && issue.teamKey);
542
556
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "patchrelay",
3
- "version": "0.31.0",
3
+ "version": "0.32.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {
@@ -33,8 +33,8 @@
33
33
  "prepack": "npm run build",
34
34
  "start": "node dist/index.js serve",
35
35
  "doctor": "node dist/index.js doctor",
36
- "restart": "node dist/index.js restart-service",
37
- "deploy": "npm run build && npm install -g . && node dist/index.js restart-service",
36
+ "restart": "node dist/index.js service restart",
37
+ "deploy": "npm run build && npm install -g . && node dist/index.js service restart",
38
38
  "lint": "eslint .",
39
39
  "typecheck": "tsc -p tsconfig.json --noEmit",
40
40
  "check": "npm run typecheck",