@generacy-ai/generacy 0.0.0-preview-20260304013206

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.
Files changed (244) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +207 -0
  3. package/bin/generacy.js +11 -0
  4. package/dist/agency/index.d.ts +68 -0
  5. package/dist/agency/index.d.ts.map +1 -0
  6. package/dist/agency/index.js +28 -0
  7. package/dist/agency/index.js.map +1 -0
  8. package/dist/agency/network.d.ts +41 -0
  9. package/dist/agency/network.d.ts.map +1 -0
  10. package/dist/agency/network.js +133 -0
  11. package/dist/agency/network.js.map +1 -0
  12. package/dist/agency/subprocess.d.ts +58 -0
  13. package/dist/agency/subprocess.d.ts.map +1 -0
  14. package/dist/agency/subprocess.js +216 -0
  15. package/dist/agency/subprocess.js.map +1 -0
  16. package/dist/cli/commands/agent.d.ts +10 -0
  17. package/dist/cli/commands/agent.d.ts.map +1 -0
  18. package/dist/cli/commands/agent.js +216 -0
  19. package/dist/cli/commands/agent.js.map +1 -0
  20. package/dist/cli/commands/doctor/checks/agency-mcp.d.ts +3 -0
  21. package/dist/cli/commands/doctor/checks/agency-mcp.d.ts.map +1 -0
  22. package/dist/cli/commands/doctor/checks/agency-mcp.js +51 -0
  23. package/dist/cli/commands/doctor/checks/agency-mcp.js.map +1 -0
  24. package/dist/cli/commands/doctor/checks/anthropic-key.d.ts +3 -0
  25. package/dist/cli/commands/doctor/checks/anthropic-key.d.ts.map +1 -0
  26. package/dist/cli/commands/doctor/checks/anthropic-key.js +68 -0
  27. package/dist/cli/commands/doctor/checks/anthropic-key.js.map +1 -0
  28. package/dist/cli/commands/doctor/checks/config.d.ts +3 -0
  29. package/dist/cli/commands/doctor/checks/config.d.ts.map +1 -0
  30. package/dist/cli/commands/doctor/checks/config.js +81 -0
  31. package/dist/cli/commands/doctor/checks/config.js.map +1 -0
  32. package/dist/cli/commands/doctor/checks/devcontainer.d.ts +3 -0
  33. package/dist/cli/commands/doctor/checks/devcontainer.d.ts.map +1 -0
  34. package/dist/cli/commands/doctor/checks/devcontainer.js +58 -0
  35. package/dist/cli/commands/doctor/checks/devcontainer.js.map +1 -0
  36. package/dist/cli/commands/doctor/checks/docker.d.ts +3 -0
  37. package/dist/cli/commands/doctor/checks/docker.d.ts.map +1 -0
  38. package/dist/cli/commands/doctor/checks/docker.js +71 -0
  39. package/dist/cli/commands/doctor/checks/docker.js.map +1 -0
  40. package/dist/cli/commands/doctor/checks/env-file.d.ts +3 -0
  41. package/dist/cli/commands/doctor/checks/env-file.d.ts.map +1 -0
  42. package/dist/cli/commands/doctor/checks/env-file.js +56 -0
  43. package/dist/cli/commands/doctor/checks/env-file.js.map +1 -0
  44. package/dist/cli/commands/doctor/checks/github-token.d.ts +3 -0
  45. package/dist/cli/commands/doctor/checks/github-token.d.ts.map +1 -0
  46. package/dist/cli/commands/doctor/checks/github-token.js +99 -0
  47. package/dist/cli/commands/doctor/checks/github-token.js.map +1 -0
  48. package/dist/cli/commands/doctor/checks/npm-packages.d.ts +3 -0
  49. package/dist/cli/commands/doctor/checks/npm-packages.d.ts.map +1 -0
  50. package/dist/cli/commands/doctor/checks/npm-packages.js +117 -0
  51. package/dist/cli/commands/doctor/checks/npm-packages.js.map +1 -0
  52. package/dist/cli/commands/doctor/formatter.d.ts +27 -0
  53. package/dist/cli/commands/doctor/formatter.d.ts.map +1 -0
  54. package/dist/cli/commands/doctor/formatter.js +162 -0
  55. package/dist/cli/commands/doctor/formatter.js.map +1 -0
  56. package/dist/cli/commands/doctor/index.d.ts +5 -0
  57. package/dist/cli/commands/doctor/index.d.ts.map +1 -0
  58. package/dist/cli/commands/doctor/index.js +8 -0
  59. package/dist/cli/commands/doctor/index.js.map +1 -0
  60. package/dist/cli/commands/doctor/registry.d.ts +48 -0
  61. package/dist/cli/commands/doctor/registry.d.ts.map +1 -0
  62. package/dist/cli/commands/doctor/registry.js +166 -0
  63. package/dist/cli/commands/doctor/registry.js.map +1 -0
  64. package/dist/cli/commands/doctor/runner.d.ts +14 -0
  65. package/dist/cli/commands/doctor/runner.d.ts.map +1 -0
  66. package/dist/cli/commands/doctor/runner.js +257 -0
  67. package/dist/cli/commands/doctor/runner.js.map +1 -0
  68. package/dist/cli/commands/doctor/types.d.ts +87 -0
  69. package/dist/cli/commands/doctor/types.d.ts.map +1 -0
  70. package/dist/cli/commands/doctor/types.js +2 -0
  71. package/dist/cli/commands/doctor/types.js.map +1 -0
  72. package/dist/cli/commands/doctor.d.ts +12 -0
  73. package/dist/cli/commands/doctor.d.ts.map +1 -0
  74. package/dist/cli/commands/doctor.js +97 -0
  75. package/dist/cli/commands/doctor.js.map +1 -0
  76. package/dist/cli/commands/init/conflicts.d.ts +36 -0
  77. package/dist/cli/commands/init/conflicts.d.ts.map +1 -0
  78. package/dist/cli/commands/init/conflicts.js +165 -0
  79. package/dist/cli/commands/init/conflicts.js.map +1 -0
  80. package/dist/cli/commands/init/github.d.ts +32 -0
  81. package/dist/cli/commands/init/github.d.ts.map +1 -0
  82. package/dist/cli/commands/init/github.js +161 -0
  83. package/dist/cli/commands/init/github.js.map +1 -0
  84. package/dist/cli/commands/init/index.d.ts +21 -0
  85. package/dist/cli/commands/init/index.d.ts.map +1 -0
  86. package/dist/cli/commands/init/index.js +175 -0
  87. package/dist/cli/commands/init/index.js.map +1 -0
  88. package/dist/cli/commands/init/prompts.d.ts +15 -0
  89. package/dist/cli/commands/init/prompts.d.ts.map +1 -0
  90. package/dist/cli/commands/init/prompts.js +281 -0
  91. package/dist/cli/commands/init/prompts.js.map +1 -0
  92. package/dist/cli/commands/init/repo-utils.d.ts +32 -0
  93. package/dist/cli/commands/init/repo-utils.d.ts.map +1 -0
  94. package/dist/cli/commands/init/repo-utils.js +112 -0
  95. package/dist/cli/commands/init/repo-utils.js.map +1 -0
  96. package/dist/cli/commands/init/resolver.d.ts +20 -0
  97. package/dist/cli/commands/init/resolver.d.ts.map +1 -0
  98. package/dist/cli/commands/init/resolver.js +273 -0
  99. package/dist/cli/commands/init/resolver.js.map +1 -0
  100. package/dist/cli/commands/init/summary.d.ts +21 -0
  101. package/dist/cli/commands/init/summary.d.ts.map +1 -0
  102. package/dist/cli/commands/init/summary.js +100 -0
  103. package/dist/cli/commands/init/summary.js.map +1 -0
  104. package/dist/cli/commands/init/types.d.ts +53 -0
  105. package/dist/cli/commands/init/types.d.ts.map +1 -0
  106. package/dist/cli/commands/init/types.js +2 -0
  107. package/dist/cli/commands/init/types.js.map +1 -0
  108. package/dist/cli/commands/init/writer.d.ts +22 -0
  109. package/dist/cli/commands/init/writer.d.ts.map +1 -0
  110. package/dist/cli/commands/init/writer.js +96 -0
  111. package/dist/cli/commands/init/writer.js.map +1 -0
  112. package/dist/cli/commands/orchestrator.d.ts +11 -0
  113. package/dist/cli/commands/orchestrator.d.ts.map +1 -0
  114. package/dist/cli/commands/orchestrator.js +291 -0
  115. package/dist/cli/commands/orchestrator.js.map +1 -0
  116. package/dist/cli/commands/run.d.ts +10 -0
  117. package/dist/cli/commands/run.d.ts.map +1 -0
  118. package/dist/cli/commands/run.js +167 -0
  119. package/dist/cli/commands/run.js.map +1 -0
  120. package/dist/cli/commands/setup/auth.d.ts +11 -0
  121. package/dist/cli/commands/setup/auth.d.ts.map +1 -0
  122. package/dist/cli/commands/setup/auth.js +108 -0
  123. package/dist/cli/commands/setup/auth.js.map +1 -0
  124. package/dist/cli/commands/setup/build.d.ts +11 -0
  125. package/dist/cli/commands/setup/build.d.ts.map +1 -0
  126. package/dist/cli/commands/setup/build.js +212 -0
  127. package/dist/cli/commands/setup/build.js.map +1 -0
  128. package/dist/cli/commands/setup/services.d.ts +11 -0
  129. package/dist/cli/commands/setup/services.d.ts.map +1 -0
  130. package/dist/cli/commands/setup/services.js +294 -0
  131. package/dist/cli/commands/setup/services.js.map +1 -0
  132. package/dist/cli/commands/setup/workspace.d.ts +11 -0
  133. package/dist/cli/commands/setup/workspace.d.ts.map +1 -0
  134. package/dist/cli/commands/setup/workspace.js +215 -0
  135. package/dist/cli/commands/setup/workspace.js.map +1 -0
  136. package/dist/cli/commands/setup.d.ts +7 -0
  137. package/dist/cli/commands/setup.d.ts.map +1 -0
  138. package/dist/cli/commands/setup.js +19 -0
  139. package/dist/cli/commands/setup.js.map +1 -0
  140. package/dist/cli/commands/validate.d.ts +10 -0
  141. package/dist/cli/commands/validate.d.ts.map +1 -0
  142. package/dist/cli/commands/validate.js +164 -0
  143. package/dist/cli/commands/validate.js.map +1 -0
  144. package/dist/cli/commands/worker.d.ts +10 -0
  145. package/dist/cli/commands/worker.d.ts.map +1 -0
  146. package/dist/cli/commands/worker.js +224 -0
  147. package/dist/cli/commands/worker.js.map +1 -0
  148. package/dist/cli/index.d.ts +14 -0
  149. package/dist/cli/index.d.ts.map +1 -0
  150. package/dist/cli/index.js +68 -0
  151. package/dist/cli/index.js.map +1 -0
  152. package/dist/cli/utils/config.d.ts +49 -0
  153. package/dist/cli/utils/config.d.ts.map +1 -0
  154. package/dist/cli/utils/config.js +110 -0
  155. package/dist/cli/utils/config.js.map +1 -0
  156. package/dist/cli/utils/exec.d.ts +39 -0
  157. package/dist/cli/utils/exec.d.ts.map +1 -0
  158. package/dist/cli/utils/exec.js +68 -0
  159. package/dist/cli/utils/exec.js.map +1 -0
  160. package/dist/cli/utils/logger.d.ts +47 -0
  161. package/dist/cli/utils/logger.d.ts.map +1 -0
  162. package/dist/cli/utils/logger.js +97 -0
  163. package/dist/cli/utils/logger.js.map +1 -0
  164. package/dist/config/index.d.ts +10 -0
  165. package/dist/config/index.d.ts.map +1 -0
  166. package/dist/config/index.js +13 -0
  167. package/dist/config/index.js.map +1 -0
  168. package/dist/config/loader.d.ts +104 -0
  169. package/dist/config/loader.d.ts.map +1 -0
  170. package/dist/config/loader.js +266 -0
  171. package/dist/config/loader.js.map +1 -0
  172. package/dist/config/schema.d.ts +304 -0
  173. package/dist/config/schema.d.ts.map +1 -0
  174. package/dist/config/schema.js +160 -0
  175. package/dist/config/schema.js.map +1 -0
  176. package/dist/config/validator.d.ts +60 -0
  177. package/dist/config/validator.d.ts.map +1 -0
  178. package/dist/config/validator.js +112 -0
  179. package/dist/config/validator.js.map +1 -0
  180. package/dist/health/server.d.ts +47 -0
  181. package/dist/health/server.d.ts.map +1 -0
  182. package/dist/health/server.js +92 -0
  183. package/dist/health/server.js.map +1 -0
  184. package/dist/index.d.ts +21 -0
  185. package/dist/index.d.ts.map +1 -0
  186. package/dist/index.js +22 -0
  187. package/dist/index.js.map +1 -0
  188. package/dist/orchestrator/async-event-queue.d.ts +28 -0
  189. package/dist/orchestrator/async-event-queue.d.ts.map +1 -0
  190. package/dist/orchestrator/async-event-queue.js +57 -0
  191. package/dist/orchestrator/async-event-queue.js.map +1 -0
  192. package/dist/orchestrator/client.d.ts +110 -0
  193. package/dist/orchestrator/client.d.ts.map +1 -0
  194. package/dist/orchestrator/client.js +288 -0
  195. package/dist/orchestrator/client.js.map +1 -0
  196. package/dist/orchestrator/event-bus.d.ts +195 -0
  197. package/dist/orchestrator/event-bus.d.ts.map +1 -0
  198. package/dist/orchestrator/event-bus.js +557 -0
  199. package/dist/orchestrator/event-bus.js.map +1 -0
  200. package/dist/orchestrator/heartbeat.d.ts +71 -0
  201. package/dist/orchestrator/heartbeat.d.ts.map +1 -0
  202. package/dist/orchestrator/heartbeat.js +116 -0
  203. package/dist/orchestrator/heartbeat.js.map +1 -0
  204. package/dist/orchestrator/index.d.ts +25 -0
  205. package/dist/orchestrator/index.d.ts.map +1 -0
  206. package/dist/orchestrator/index.js +15 -0
  207. package/dist/orchestrator/index.js.map +1 -0
  208. package/dist/orchestrator/job-handler.d.ts +109 -0
  209. package/dist/orchestrator/job-handler.d.ts.map +1 -0
  210. package/dist/orchestrator/job-handler.js +612 -0
  211. package/dist/orchestrator/job-handler.js.map +1 -0
  212. package/dist/orchestrator/job-queue.d.ts +81 -0
  213. package/dist/orchestrator/job-queue.d.ts.map +1 -0
  214. package/dist/orchestrator/job-queue.js +206 -0
  215. package/dist/orchestrator/job-queue.js.map +1 -0
  216. package/dist/orchestrator/label-monitor-bridge.d.ts +25 -0
  217. package/dist/orchestrator/label-monitor-bridge.d.ts.map +1 -0
  218. package/dist/orchestrator/label-monitor-bridge.js +57 -0
  219. package/dist/orchestrator/label-monitor-bridge.js.map +1 -0
  220. package/dist/orchestrator/log-buffer.d.ts +74 -0
  221. package/dist/orchestrator/log-buffer.d.ts.map +1 -0
  222. package/dist/orchestrator/log-buffer.js +104 -0
  223. package/dist/orchestrator/log-buffer.js.map +1 -0
  224. package/dist/orchestrator/redis-job-queue.d.ts +44 -0
  225. package/dist/orchestrator/redis-job-queue.d.ts.map +1 -0
  226. package/dist/orchestrator/redis-job-queue.js +300 -0
  227. package/dist/orchestrator/redis-job-queue.js.map +1 -0
  228. package/dist/orchestrator/router.d.ts +125 -0
  229. package/dist/orchestrator/router.d.ts.map +1 -0
  230. package/dist/orchestrator/router.js +143 -0
  231. package/dist/orchestrator/router.js.map +1 -0
  232. package/dist/orchestrator/server.d.ts +62 -0
  233. package/dist/orchestrator/server.d.ts.map +1 -0
  234. package/dist/orchestrator/server.js +711 -0
  235. package/dist/orchestrator/server.js.map +1 -0
  236. package/dist/orchestrator/types.d.ts +184 -0
  237. package/dist/orchestrator/types.d.ts.map +1 -0
  238. package/dist/orchestrator/types.js +6 -0
  239. package/dist/orchestrator/types.js.map +1 -0
  240. package/dist/orchestrator/worker-registry.d.ts +110 -0
  241. package/dist/orchestrator/worker-registry.d.ts.map +1 -0
  242. package/dist/orchestrator/worker-registry.js +191 -0
  243. package/dist/orchestrator/worker-registry.js.map +1 -0
  244. package/package.json +80 -0
@@ -0,0 +1,612 @@
1
+ /**
2
+ * Job handler.
3
+ * Handles job polling, execution, and result reporting.
4
+ */
5
+ import { existsSync, readdirSync } from 'node:fs';
6
+ import { resolve, isAbsolute } from 'node:path';
7
+ import { execSync } from 'node:child_process';
8
+ import { loadWorkflowFromString, loadWorkflowWithExtends, prepareWorkflow, WorkflowExecutor, getActionHandlerByType, createGitHubClient, registerWorkflow, resolveRegisteredWorkflow, } from '@generacy-ai/workflow-engine';
9
+ /**
10
+ * Mapping from YAML phase names to completed:* label suffixes.
11
+ * When a phase completes, we add `completed:{suffix}` to the issue.
12
+ * When resolving startPhase on requeue, we check for these labels to skip phases.
13
+ */
14
+ const PHASE_TO_LABEL_SUFFIX = {
15
+ // setup is intentionally excluded — it always runs (handles branch checkout)
16
+ specification: 'specify',
17
+ clarification: 'clarify',
18
+ planning: 'plan',
19
+ 'task-generation': 'tasks',
20
+ implementation: 'implement',
21
+ verification: 'validate',
22
+ };
23
+ /**
24
+ * Ordered list of YAML phase names for resolving which phases to skip.
25
+ * setup is excluded — it must always run.
26
+ */
27
+ const PHASE_ORDER = [
28
+ 'specification',
29
+ 'clarification',
30
+ 'planning',
31
+ 'task-generation',
32
+ 'implementation',
33
+ 'verification',
34
+ ];
35
+ /**
36
+ * Phase gates: phases that should pause the workflow and wait for developer input.
37
+ * Maps YAML phase name → waiting-for label to add when the gate is hit.
38
+ */
39
+ const PHASE_GATES = {
40
+ clarification: 'waiting-for:clarification',
41
+ };
42
+ /**
43
+ * Map executor event types to orchestrator JobEventType.
44
+ * Returns undefined for events we don't forward (execution:*, phase:error, step:error, action:start/complete).
45
+ * Includes log:append for stdout/stderr streaming (#178).
46
+ */
47
+ const EVENT_TYPE_MAP = {
48
+ 'phase:start': 'phase:start',
49
+ 'phase:complete': 'phase:complete',
50
+ 'step:start': 'step:start',
51
+ 'step:complete': 'step:complete',
52
+ 'step:output': 'step:output',
53
+ 'action:error': 'action:error',
54
+ 'action:retry': 'action:error',
55
+ 'log:append': 'log:append',
56
+ };
57
+ /**
58
+ * Create an event forwarder that enqueues events and drains them sequentially
59
+ * via the orchestrator client's publishEvent method.
60
+ *
61
+ * - enqueue() is synchronous (fire-and-forget drain) so the executor callback is never blocked.
62
+ * - drain() processes one event at a time, awaiting each publishEvent call, guaranteeing ordering.
63
+ * - Errors are swallowed (non-blocking): first failure per sequence logs at warn, subsequent at debug.
64
+ * - stop() prevents further enqueueing and clears the queue.
65
+ */
66
+ function createEventForwarder(client, jobId, logger) {
67
+ const queue = [];
68
+ let draining = false;
69
+ let stopped = false;
70
+ let hasLoggedFailure = false;
71
+ async function drain() {
72
+ if (draining)
73
+ return;
74
+ draining = true;
75
+ try {
76
+ while (queue.length > 0 && !stopped) {
77
+ const event = queue.shift();
78
+ try {
79
+ await client.publishEvent(jobId, event);
80
+ hasLoggedFailure = false; // Reset on success
81
+ }
82
+ catch (error) {
83
+ // Non-blocking: log and continue
84
+ const msg = error instanceof Error ? error.message : String(error);
85
+ if (!hasLoggedFailure) {
86
+ logger.warn(`Event forwarding failed for job ${jobId}: ${msg}`);
87
+ hasLoggedFailure = true;
88
+ }
89
+ else {
90
+ logger.debug(`Event forwarding failed for job ${jobId}: ${msg}`);
91
+ }
92
+ }
93
+ }
94
+ }
95
+ finally {
96
+ draining = false;
97
+ }
98
+ }
99
+ return {
100
+ enqueue(event) {
101
+ if (stopped)
102
+ return;
103
+ queue.push(event);
104
+ void drain();
105
+ },
106
+ async flush() {
107
+ await drain();
108
+ },
109
+ stop() {
110
+ stopped = true;
111
+ queue.length = 0;
112
+ },
113
+ };
114
+ }
115
+ /**
116
+ * Register built-in workflow files from the generacy package's .generacy/ directory.
117
+ * This is a temporary bridge until plugins (e.g., agency-plugin-spec-kit) bundle
118
+ * and register their own workflows (see agency#244).
119
+ *
120
+ * Uses a lazy-init guard so registration only happens once, following the same
121
+ * pattern as ensureActionsRegistered() in the workflow executor.
122
+ */
123
+ let builtinWorkflowsRegistered = false;
124
+ function registerBuiltinWorkflows() {
125
+ if (builtinWorkflowsRegistered)
126
+ return;
127
+ builtinWorkflowsRegistered = true;
128
+ // Resolve the .generacy/ directory relative to this source file's package root.
129
+ // From src/orchestrator/ (or dist/orchestrator/), go up to the monorepo root.
130
+ const workflowDir = resolve(import.meta.dirname, '..', '..', '..', '..', '.generacy');
131
+ if (!existsSync(workflowDir))
132
+ return;
133
+ try {
134
+ const entries = readdirSync(workflowDir);
135
+ for (const entry of entries) {
136
+ if (!entry.endsWith('.yaml') && !entry.endsWith('.yml'))
137
+ continue;
138
+ const name = entry.replace(/\.ya?ml$/, '');
139
+ const filePath = resolve(workflowDir, entry);
140
+ try {
141
+ registerWorkflow(name, filePath);
142
+ }
143
+ catch {
144
+ // registerWorkflow throws if file doesn't exist; skip silently
145
+ }
146
+ }
147
+ }
148
+ catch {
149
+ // Directory not readable; skip silently
150
+ }
151
+ }
152
+ /**
153
+ * Handles job polling and execution
154
+ */
155
+ export class JobHandler {
156
+ client;
157
+ workerId;
158
+ pollInterval;
159
+ logger;
160
+ workdir;
161
+ capabilities;
162
+ onJobStart;
163
+ onJobComplete;
164
+ onError;
165
+ pollTimer = null;
166
+ currentJob = null;
167
+ abortController = null;
168
+ isRunning = false;
169
+ shouldStop = false;
170
+ humanDecisionHandler;
171
+ constructor(options) {
172
+ registerBuiltinWorkflows();
173
+ this.client = options.client;
174
+ this.workerId = options.workerId;
175
+ this.pollInterval = options.pollInterval ?? 5000;
176
+ this.logger = options.logger;
177
+ this.workdir = options.workdir ?? process.cwd();
178
+ this.capabilities = options.capabilities ?? [];
179
+ this.onJobStart = options.onJobStart;
180
+ this.onJobComplete = options.onJobComplete;
181
+ this.onError = options.onError;
182
+ this.humanDecisionHandler = options.humanDecisionHandler;
183
+ }
184
+ /**
185
+ * Start the job polling loop
186
+ */
187
+ start() {
188
+ if (this.isRunning) {
189
+ return;
190
+ }
191
+ this.isRunning = true;
192
+ this.shouldStop = false;
193
+ this.poll();
194
+ }
195
+ /**
196
+ * Stop the job polling loop
197
+ */
198
+ stop() {
199
+ this.shouldStop = true;
200
+ if (this.pollTimer) {
201
+ clearTimeout(this.pollTimer);
202
+ this.pollTimer = null;
203
+ }
204
+ this.isRunning = false;
205
+ }
206
+ /**
207
+ * Cancel the current job
208
+ */
209
+ cancelCurrentJob() {
210
+ if (this.abortController) {
211
+ this.abortController.abort();
212
+ }
213
+ }
214
+ /**
215
+ * Get the currently executing job
216
+ */
217
+ getCurrentJob() {
218
+ return this.currentJob;
219
+ }
220
+ /**
221
+ * Check if currently executing a job
222
+ */
223
+ isBusy() {
224
+ return this.currentJob !== null;
225
+ }
226
+ /**
227
+ * Poll for and process jobs
228
+ */
229
+ async poll() {
230
+ if (this.shouldStop || this.currentJob) {
231
+ return;
232
+ }
233
+ try {
234
+ const response = await this.client.pollForJob(this.workerId, this.capabilities);
235
+ if (response.job) {
236
+ await this.executeJob(response.job);
237
+ }
238
+ // Schedule next poll
239
+ if (!this.shouldStop && this.isRunning) {
240
+ const delay = response.retryAfter ?? this.pollInterval;
241
+ this.pollTimer = setTimeout(() => this.poll(), delay);
242
+ }
243
+ }
244
+ catch (error) {
245
+ this.onError?.(error instanceof Error ? error : new Error(String(error)));
246
+ // Continue polling after error with backoff
247
+ if (!this.shouldStop && this.isRunning) {
248
+ this.pollTimer = setTimeout(() => this.poll(), this.pollInterval * 2);
249
+ }
250
+ }
251
+ }
252
+ /**
253
+ * Execute a job
254
+ */
255
+ async executeJob(job) {
256
+ this.currentJob = job;
257
+ this.abortController = new AbortController();
258
+ const startTime = Date.now();
259
+ const jobWorkdir = this.resolveJobWorkdir(job);
260
+ // Record the current branch so we can restore it after the job
261
+ let originalBranch;
262
+ try {
263
+ originalBranch = execSync('git rev-parse --abbrev-ref HEAD', {
264
+ cwd: jobWorkdir, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'],
265
+ }).trim() || undefined;
266
+ }
267
+ catch {
268
+ // Not a git repo or git not available - skip branch tracking
269
+ }
270
+ this.logger.info(`Starting job: ${job.id} (${job.name})`);
271
+ this.onJobStart?.(job);
272
+ let forwarder;
273
+ let forwarderSubscription;
274
+ try {
275
+ // Update job status to running
276
+ await this.client.updateJobStatus(job.id, 'running', {
277
+ startedAt: new Date().toISOString(),
278
+ });
279
+ // Load workflow
280
+ let definition;
281
+ if (typeof job.workflow === 'string') {
282
+ // Could be a path or YAML content
283
+ if (job.workflow.includes('\n') || job.workflow.startsWith('name:')) {
284
+ definition = await loadWorkflowFromString(job.workflow);
285
+ }
286
+ else {
287
+ const resolvedPath = this.resolveWorkflowPath(job.workflow, jobWorkdir);
288
+ const resolver = (name, excludePath) => this.resolveWorkflowPath(name, jobWorkdir, excludePath);
289
+ definition = await loadWorkflowWithExtends(resolvedPath, resolver);
290
+ }
291
+ }
292
+ else {
293
+ // Already a workflow object
294
+ definition = job.workflow;
295
+ }
296
+ const workflow = prepareWorkflow(definition, job.inputs);
297
+ // Remove already-completed phases (but never remove setup — it handles branch checkout)
298
+ const completedPhases = await this.resolveCompletedPhases(job);
299
+ if (completedPhases.size > 0) {
300
+ this.logger.info(`Skipping completed phases: ${[...completedPhases].join(', ')}`);
301
+ workflow.phases = workflow.phases.filter(p => !completedPhases.has(p.name));
302
+ }
303
+ // Create executor (this also registers builtin actions)
304
+ const executor = new WorkflowExecutor({
305
+ logger: this.logger,
306
+ });
307
+ // Inject human decision handler AFTER executor creation, since the executor's
308
+ // ensureActionsRegistered() may re-register action handlers
309
+ if (this.humanDecisionHandler) {
310
+ const reviewAction = getActionHandlerByType('humancy.request_review');
311
+ if (reviewAction) {
312
+ reviewAction.setHumanHandler(this.humanDecisionHandler);
313
+ }
314
+ }
315
+ // --- Event forwarding to orchestrator ---
316
+ const totalSteps = workflow.phases.reduce((sum, p) => sum + p.steps.length, 0);
317
+ let completedSteps = 0;
318
+ forwarder = createEventForwarder(this.client, job.id, this.logger);
319
+ forwarderSubscription = executor.addEventListener((event) => {
320
+ const mappedType = EVENT_TYPE_MAP[event.type];
321
+ if (!mappedType)
322
+ return;
323
+ const data = {
324
+ workflowName: event.workflowName,
325
+ };
326
+ if (event.phaseName)
327
+ data.phaseName = event.phaseName;
328
+ if (event.stepName)
329
+ data.stepName = event.stepName;
330
+ if (event.message)
331
+ data.message = event.message;
332
+ if (event.data !== undefined)
333
+ data.detail = event.data;
334
+ if (event.type === 'step:complete') {
335
+ completedSteps++;
336
+ data.progress = totalSteps > 0 ? Math.round((completedSteps / totalSteps) * 100) : 0;
337
+ }
338
+ forwarder.enqueue({
339
+ type: mappedType,
340
+ data,
341
+ timestamp: event.timestamp,
342
+ });
343
+ });
344
+ // Listen for phase completions: add labels and handle gates
345
+ const owner = job.inputs?.owner;
346
+ const repo = job.inputs?.repo;
347
+ const issueNumber = job.inputs?.issue_number;
348
+ let shouldPauseForGate = false;
349
+ let gatedPhaseName;
350
+ const phasesWithFailedSteps = new Set();
351
+ executor.addEventListener((event) => {
352
+ // Track step failures so we can label phases accurately
353
+ if (event.type === 'step:error' && event.phaseName) {
354
+ phasesWithFailedSteps.add(event.phaseName);
355
+ }
356
+ if (!owner || !repo || !issueNumber)
357
+ return;
358
+ if (event.type !== 'phase:complete' || !event.phaseName)
359
+ return;
360
+ const gateLabel = PHASE_GATES[event.phaseName];
361
+ if (gateLabel) {
362
+ // Check if the gated phase posted questions (needs developer input)
363
+ const stepOutput = executor.getExecutionContext()?.getStepOutput('clarify');
364
+ const parsed = stepOutput?.parsed;
365
+ const postedQuestions = parsed?.posted_to_issue === true
366
+ && parsed?.questions_count > 0;
367
+ if (postedQuestions) {
368
+ shouldPauseForGate = true;
369
+ gatedPhaseName = event.phaseName;
370
+ executor.cancel(); // stops before next phase starts
371
+ return; // don't add completed label for gated phase
372
+ }
373
+ }
374
+ // Add completed:* or failed:* label based on whether steps had errors
375
+ const hasFailed = phasesWithFailedSteps.has(event.phaseName);
376
+ void this.addPhaseLabel(owner, repo, issueNumber, event.phaseName, !hasFailed);
377
+ });
378
+ // Execute workflow
379
+ const result = await executor.execute(workflow, {
380
+ mode: 'normal',
381
+ cwd: jobWorkdir,
382
+ env: process.env,
383
+ }, job.inputs);
384
+ // Handle gate pause: add waiting label and mark agent as paused
385
+ if (shouldPauseForGate && gatedPhaseName && owner && repo && issueNumber) {
386
+ const gateLabel = PHASE_GATES[gatedPhaseName];
387
+ try {
388
+ const github = createGitHubClient();
389
+ await github.addLabels(owner, repo, issueNumber, [gateLabel, 'agent:paused']);
390
+ try {
391
+ await github.removeLabels(owner, repo, issueNumber, ['agent:in-progress']);
392
+ }
393
+ catch { /* may not exist */ }
394
+ this.logger.info(`Paused at gate: ${gatedPhaseName}, added ${gateLabel}`);
395
+ }
396
+ catch (error) {
397
+ this.logger.warn(`Failed to add gate label: ${error}`);
398
+ }
399
+ }
400
+ // Build job result (treat gate-pause cancellation as success)
401
+ const jobResult = this.buildJobResult(job, result, startTime, shouldPauseForGate);
402
+ // Report result
403
+ await this.client.reportJobResult(jobResult);
404
+ this.logger.info(`Job completed: ${job.id} (${jobResult.status})`);
405
+ this.onJobComplete?.(job, jobResult);
406
+ }
407
+ catch (error) {
408
+ const errorMessage = error instanceof Error ? error.message : String(error);
409
+ const errorStack = error instanceof Error ? error.stack : undefined;
410
+ this.logger.error(`Job failed: ${job.id} - ${errorMessage}`);
411
+ this.onError?.(error instanceof Error ? error : new Error(errorMessage), job);
412
+ // Report failure
413
+ const failureResult = {
414
+ jobId: job.id,
415
+ status: this.abortController?.signal.aborted ? 'cancelled' : 'failed',
416
+ error: errorMessage,
417
+ errorStack,
418
+ duration: Date.now() - startTime,
419
+ };
420
+ try {
421
+ await this.client.reportJobResult(failureResult);
422
+ }
423
+ catch (reportError) {
424
+ this.logger.error(`Failed to report job result: ${reportError}`);
425
+ }
426
+ this.onJobComplete?.(job, failureResult);
427
+ }
428
+ finally {
429
+ // Stop event forwarding and unsubscribe
430
+ forwarder?.stop();
431
+ forwarderSubscription?.dispose();
432
+ // Restore the original branch so the repo is clean for the next job
433
+ if (originalBranch) {
434
+ try {
435
+ const currentBranch = execSync('git rev-parse --abbrev-ref HEAD', {
436
+ cwd: jobWorkdir, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'],
437
+ }).trim();
438
+ if (currentBranch !== originalBranch) {
439
+ this.logger.info(`Restoring branch: ${originalBranch}`);
440
+ execSync(`git checkout --force ${originalBranch}`, {
441
+ cwd: jobWorkdir, stdio: ['pipe', 'pipe', 'pipe'],
442
+ });
443
+ }
444
+ }
445
+ catch (restoreError) {
446
+ this.logger.warn(`Failed to restore branch ${originalBranch}: ${restoreError}`);
447
+ }
448
+ }
449
+ this.currentJob = null;
450
+ this.abortController = null;
451
+ // Resume polling
452
+ if (!this.shouldStop && this.isRunning) {
453
+ this.pollTimer = setTimeout(() => this.poll(), this.pollInterval);
454
+ }
455
+ }
456
+ }
457
+ /**
458
+ * Resolve the working directory for a job.
459
+ * Uses MONITORED_REPOS env var to map owner/repo to local workspace paths.
460
+ * Falls back to job.workdir, then this.workdir.
461
+ */
462
+ resolveJobWorkdir(job) {
463
+ if (job.workdir)
464
+ return job.workdir;
465
+ const owner = job.inputs?.owner;
466
+ const repo = job.inputs?.repo;
467
+ if (owner && repo) {
468
+ const fullName = `${owner}/${repo}`;
469
+ const monitoredRepos = process.env['MONITORED_REPOS'] ?? '';
470
+ const repos = monitoredRepos.split(',').map(r => r.trim()).filter(Boolean);
471
+ for (const entry of repos) {
472
+ if (entry === fullName) {
473
+ // Derive workspace path from the repo name portion
474
+ const repoName = entry.split('/')[1];
475
+ if (repoName) {
476
+ const repoWorkdir = `/workspaces/${repoName}`;
477
+ if (existsSync(repoWorkdir)) {
478
+ this.logger.info(`Using repo workdir: ${repoWorkdir} (from MONITORED_REPOS)`);
479
+ return repoWorkdir;
480
+ }
481
+ }
482
+ }
483
+ }
484
+ }
485
+ return this.workdir;
486
+ }
487
+ /**
488
+ * Resolve a workflow name or path to an absolute file path.
489
+ * Searches: absolute path, relative to workdir, .generacy/ directory, plugin registry.
490
+ *
491
+ * @param workflow - Workflow name or path to resolve
492
+ * @param jobWorkdir - Job working directory for relative resolution
493
+ * @param excludePath - Optional resolved path to skip (used by extends to avoid self-resolution)
494
+ */
495
+ resolveWorkflowPath(workflow, jobWorkdir, excludePath) {
496
+ // 1. Absolute path (if exists and not excluded)
497
+ if (isAbsolute(workflow) && existsSync(workflow) && resolve(workflow) !== excludePath) {
498
+ return workflow;
499
+ }
500
+ const searchDir = jobWorkdir ?? this.workdir;
501
+ // 2. Relative to workdir
502
+ const direct = resolve(searchDir, workflow);
503
+ if (existsSync(direct) && resolve(direct) !== excludePath)
504
+ return direct;
505
+ // 3. .generacy/ in workdir (repo-local override — highest priority)
506
+ for (const ext of ['', '.yaml', '.yml']) {
507
+ const candidate = resolve(searchDir, '.generacy', `${workflow}${ext}`);
508
+ if (existsSync(candidate) && resolve(candidate) !== excludePath)
509
+ return candidate;
510
+ }
511
+ // 4. Plugin-provided workflows (WorkflowRegistry)
512
+ const registered = resolveRegisteredWorkflow(workflow);
513
+ if (registered && registered !== excludePath)
514
+ return registered;
515
+ // Fallback: return original string (will produce a clear "file not found" error)
516
+ return workflow;
517
+ }
518
+ /**
519
+ * Resolve which phases have already been attempted based on issue labels.
520
+ * Recognises both `completed:*` and `failed:*` labels so that phases are
521
+ * not re-run on retry (failed verification still means the phase executed).
522
+ * Returns a set of YAML phase names to skip. Setup is never included.
523
+ */
524
+ async resolveCompletedPhases(job) {
525
+ const owner = job.inputs?.owner;
526
+ const repo = job.inputs?.repo;
527
+ const issueNumber = job.inputs?.issue_number;
528
+ if (!owner || !repo || !issueNumber) {
529
+ return new Set();
530
+ }
531
+ try {
532
+ const github = createGitHubClient();
533
+ const issue = await github.getIssue(owner, repo, issueNumber);
534
+ const labelNames = issue.labels.map(l => typeof l === 'string' ? l : l.name);
535
+ // Find completed:* and failed:* labels (both indicate the phase has run)
536
+ const attemptedSuffixes = new Set(labelNames
537
+ .filter(n => n.startsWith('completed:') || n.startsWith('failed:'))
538
+ .map(n => n.replace(/^(completed|failed):/, '')));
539
+ if (attemptedSuffixes.size === 0) {
540
+ return new Set();
541
+ }
542
+ this.logger.info(`Found phase labels: ${[...attemptedSuffixes].join(', ')}`);
543
+ // Map label suffixes back to YAML phase names
544
+ const completed = new Set();
545
+ for (const phaseName of PHASE_ORDER) {
546
+ const suffix = PHASE_TO_LABEL_SUFFIX[phaseName];
547
+ if (suffix && attemptedSuffixes.has(suffix)) {
548
+ completed.add(phaseName);
549
+ }
550
+ }
551
+ return completed;
552
+ }
553
+ catch (error) {
554
+ this.logger.warn(`Failed to resolve completed phases from labels: ${error}`);
555
+ return new Set();
556
+ }
557
+ }
558
+ /**
559
+ * Add a completed:* or failed:* label to the issue after a phase finishes.
560
+ * Uses `completed:` prefix when the phase succeeded, `failed:` when any step errored.
561
+ */
562
+ async addPhaseLabel(owner, repo, issueNumber, phaseName, success) {
563
+ const suffix = PHASE_TO_LABEL_SUFFIX[phaseName];
564
+ if (!suffix)
565
+ return;
566
+ const prefix = success ? 'completed' : 'failed';
567
+ const label = `${prefix}:${suffix}`;
568
+ try {
569
+ const github = createGitHubClient();
570
+ await github.addLabels(owner, repo, issueNumber, [label]);
571
+ this.logger.info(`Added label ${label} to ${owner}/${repo}#${issueNumber}`);
572
+ }
573
+ catch (error) {
574
+ this.logger.warn(`Failed to add label ${label}: ${error}`);
575
+ }
576
+ }
577
+ /**
578
+ * Build job result from execution result
579
+ */
580
+ buildJobResult(job, result, startTime, gatePaused) {
581
+ // Find the first error from failed phases/steps
582
+ let errorMessage;
583
+ const failedPhase = result.phaseResults.find((p) => p.status === 'failed');
584
+ if (failedPhase) {
585
+ const failedStep = failedPhase.stepResults.find(s => s.status === 'failed');
586
+ if (failedStep?.error) {
587
+ errorMessage = failedStep.error;
588
+ }
589
+ }
590
+ return {
591
+ jobId: job.id,
592
+ // Gate-paused cancellation is intentional — report as completed so the worker is freed
593
+ status: gatePaused ? 'completed' :
594
+ result.status === 'completed' ? 'completed' :
595
+ result.status === 'cancelled' ? 'cancelled' : 'failed',
596
+ error: errorMessage,
597
+ duration: Date.now() - startTime,
598
+ phases: result.phaseResults.map((phase) => ({
599
+ name: phase.phaseName,
600
+ status: phase.status,
601
+ duration: phase.duration ?? 0,
602
+ })),
603
+ steps: result.phaseResults.flatMap((phase) => phase.stepResults.map(step => ({
604
+ name: step.stepName,
605
+ status: step.status,
606
+ duration: step.duration ?? 0,
607
+ error: step.error,
608
+ }))),
609
+ };
610
+ }
611
+ }
612
+ //# sourceMappingURL=job-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-handler.js","sourceRoot":"","sources":["../../src/orchestrator/job-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EAEtB,kBAAkB,EAClB,gBAAgB,EAChB,yBAAyB,GAQ1B,MAAM,8BAA8B,CAAC;AAItC;;;;GAIG;AACH,MAAM,qBAAqB,GAA2B;IACpD,6EAA6E;IAC7E,aAAa,EAAE,SAAS;IACxB,aAAa,EAAE,SAAS;IACxB,QAAQ,EAAE,MAAM;IAChB,iBAAiB,EAAE,OAAO;IAC1B,cAAc,EAAE,WAAW;IAC3B,YAAY,EAAE,UAAU;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,GAAG;IAClB,eAAe;IACf,eAAe;IACf,UAAU;IACV,iBAAiB;IACjB,gBAAgB;IAChB,cAAc;CACf,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,GAA2B;IAC1C,aAAa,EAAE,2BAA2B;CAC3C,CAAC;AAEF;;;;GAIG;AACH,MAAM,cAAc,GAA0C;IAC5D,aAAa,EAAE,aAAa;IAC5B,gBAAgB,EAAE,gBAAgB;IAClC,YAAY,EAAE,YAAY;IAC1B,eAAe,EAAE,eAAe;IAChC,aAAa,EAAE,aAAa;IAC5B,cAAc,EAAE,cAAc;IAC9B,cAAc,EAAE,cAAc;IAC9B,YAAY,EAAE,YAAY;CAC3B,CAAC;AAaF;;;;;;;;GAQG;AACH,SAAS,oBAAoB,CAC3B,MAA0B,EAC1B,KAAa,EACb,MAAc;IAEd,MAA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