@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.
- package/LICENSE +191 -0
- package/README.md +207 -0
- package/bin/generacy.js +11 -0
- package/dist/agency/index.d.ts +68 -0
- package/dist/agency/index.d.ts.map +1 -0
- package/dist/agency/index.js +28 -0
- package/dist/agency/index.js.map +1 -0
- package/dist/agency/network.d.ts +41 -0
- package/dist/agency/network.d.ts.map +1 -0
- package/dist/agency/network.js +133 -0
- package/dist/agency/network.js.map +1 -0
- package/dist/agency/subprocess.d.ts +58 -0
- package/dist/agency/subprocess.d.ts.map +1 -0
- package/dist/agency/subprocess.js +216 -0
- package/dist/agency/subprocess.js.map +1 -0
- package/dist/cli/commands/agent.d.ts +10 -0
- package/dist/cli/commands/agent.d.ts.map +1 -0
- package/dist/cli/commands/agent.js +216 -0
- package/dist/cli/commands/agent.js.map +1 -0
- package/dist/cli/commands/doctor/checks/agency-mcp.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/agency-mcp.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/agency-mcp.js +51 -0
- package/dist/cli/commands/doctor/checks/agency-mcp.js.map +1 -0
- package/dist/cli/commands/doctor/checks/anthropic-key.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/anthropic-key.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/anthropic-key.js +68 -0
- package/dist/cli/commands/doctor/checks/anthropic-key.js.map +1 -0
- package/dist/cli/commands/doctor/checks/config.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/config.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/config.js +81 -0
- package/dist/cli/commands/doctor/checks/config.js.map +1 -0
- package/dist/cli/commands/doctor/checks/devcontainer.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/devcontainer.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/devcontainer.js +58 -0
- package/dist/cli/commands/doctor/checks/devcontainer.js.map +1 -0
- package/dist/cli/commands/doctor/checks/docker.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/docker.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/docker.js +71 -0
- package/dist/cli/commands/doctor/checks/docker.js.map +1 -0
- package/dist/cli/commands/doctor/checks/env-file.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/env-file.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/env-file.js +56 -0
- package/dist/cli/commands/doctor/checks/env-file.js.map +1 -0
- package/dist/cli/commands/doctor/checks/github-token.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/github-token.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/github-token.js +99 -0
- package/dist/cli/commands/doctor/checks/github-token.js.map +1 -0
- package/dist/cli/commands/doctor/checks/npm-packages.d.ts +3 -0
- package/dist/cli/commands/doctor/checks/npm-packages.d.ts.map +1 -0
- package/dist/cli/commands/doctor/checks/npm-packages.js +117 -0
- package/dist/cli/commands/doctor/checks/npm-packages.js.map +1 -0
- package/dist/cli/commands/doctor/formatter.d.ts +27 -0
- package/dist/cli/commands/doctor/formatter.d.ts.map +1 -0
- package/dist/cli/commands/doctor/formatter.js +162 -0
- package/dist/cli/commands/doctor/formatter.js.map +1 -0
- package/dist/cli/commands/doctor/index.d.ts +5 -0
- package/dist/cli/commands/doctor/index.d.ts.map +1 -0
- package/dist/cli/commands/doctor/index.js +8 -0
- package/dist/cli/commands/doctor/index.js.map +1 -0
- package/dist/cli/commands/doctor/registry.d.ts +48 -0
- package/dist/cli/commands/doctor/registry.d.ts.map +1 -0
- package/dist/cli/commands/doctor/registry.js +166 -0
- package/dist/cli/commands/doctor/registry.js.map +1 -0
- package/dist/cli/commands/doctor/runner.d.ts +14 -0
- package/dist/cli/commands/doctor/runner.d.ts.map +1 -0
- package/dist/cli/commands/doctor/runner.js +257 -0
- package/dist/cli/commands/doctor/runner.js.map +1 -0
- package/dist/cli/commands/doctor/types.d.ts +87 -0
- package/dist/cli/commands/doctor/types.d.ts.map +1 -0
- package/dist/cli/commands/doctor/types.js +2 -0
- package/dist/cli/commands/doctor/types.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +12 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +97 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/init/conflicts.d.ts +36 -0
- package/dist/cli/commands/init/conflicts.d.ts.map +1 -0
- package/dist/cli/commands/init/conflicts.js +165 -0
- package/dist/cli/commands/init/conflicts.js.map +1 -0
- package/dist/cli/commands/init/github.d.ts +32 -0
- package/dist/cli/commands/init/github.d.ts.map +1 -0
- package/dist/cli/commands/init/github.js +161 -0
- package/dist/cli/commands/init/github.js.map +1 -0
- package/dist/cli/commands/init/index.d.ts +21 -0
- package/dist/cli/commands/init/index.d.ts.map +1 -0
- package/dist/cli/commands/init/index.js +175 -0
- package/dist/cli/commands/init/index.js.map +1 -0
- package/dist/cli/commands/init/prompts.d.ts +15 -0
- package/dist/cli/commands/init/prompts.d.ts.map +1 -0
- package/dist/cli/commands/init/prompts.js +281 -0
- package/dist/cli/commands/init/prompts.js.map +1 -0
- package/dist/cli/commands/init/repo-utils.d.ts +32 -0
- package/dist/cli/commands/init/repo-utils.d.ts.map +1 -0
- package/dist/cli/commands/init/repo-utils.js +112 -0
- package/dist/cli/commands/init/repo-utils.js.map +1 -0
- package/dist/cli/commands/init/resolver.d.ts +20 -0
- package/dist/cli/commands/init/resolver.d.ts.map +1 -0
- package/dist/cli/commands/init/resolver.js +273 -0
- package/dist/cli/commands/init/resolver.js.map +1 -0
- package/dist/cli/commands/init/summary.d.ts +21 -0
- package/dist/cli/commands/init/summary.d.ts.map +1 -0
- package/dist/cli/commands/init/summary.js +100 -0
- package/dist/cli/commands/init/summary.js.map +1 -0
- package/dist/cli/commands/init/types.d.ts +53 -0
- package/dist/cli/commands/init/types.d.ts.map +1 -0
- package/dist/cli/commands/init/types.js +2 -0
- package/dist/cli/commands/init/types.js.map +1 -0
- package/dist/cli/commands/init/writer.d.ts +22 -0
- package/dist/cli/commands/init/writer.d.ts.map +1 -0
- package/dist/cli/commands/init/writer.js +96 -0
- package/dist/cli/commands/init/writer.js.map +1 -0
- package/dist/cli/commands/orchestrator.d.ts +11 -0
- package/dist/cli/commands/orchestrator.d.ts.map +1 -0
- package/dist/cli/commands/orchestrator.js +291 -0
- package/dist/cli/commands/orchestrator.js.map +1 -0
- package/dist/cli/commands/run.d.ts +10 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +167 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/setup/auth.d.ts +11 -0
- package/dist/cli/commands/setup/auth.d.ts.map +1 -0
- package/dist/cli/commands/setup/auth.js +108 -0
- package/dist/cli/commands/setup/auth.js.map +1 -0
- package/dist/cli/commands/setup/build.d.ts +11 -0
- package/dist/cli/commands/setup/build.d.ts.map +1 -0
- package/dist/cli/commands/setup/build.js +212 -0
- package/dist/cli/commands/setup/build.js.map +1 -0
- package/dist/cli/commands/setup/services.d.ts +11 -0
- package/dist/cli/commands/setup/services.d.ts.map +1 -0
- package/dist/cli/commands/setup/services.js +294 -0
- package/dist/cli/commands/setup/services.js.map +1 -0
- package/dist/cli/commands/setup/workspace.d.ts +11 -0
- package/dist/cli/commands/setup/workspace.d.ts.map +1 -0
- package/dist/cli/commands/setup/workspace.js +215 -0
- package/dist/cli/commands/setup/workspace.js.map +1 -0
- package/dist/cli/commands/setup.d.ts +7 -0
- package/dist/cli/commands/setup.d.ts.map +1 -0
- package/dist/cli/commands/setup.js +19 -0
- package/dist/cli/commands/setup.js.map +1 -0
- package/dist/cli/commands/validate.d.ts +10 -0
- package/dist/cli/commands/validate.d.ts.map +1 -0
- package/dist/cli/commands/validate.js +164 -0
- package/dist/cli/commands/validate.js.map +1 -0
- package/dist/cli/commands/worker.d.ts +10 -0
- package/dist/cli/commands/worker.d.ts.map +1 -0
- package/dist/cli/commands/worker.js +224 -0
- package/dist/cli/commands/worker.js.map +1 -0
- package/dist/cli/index.d.ts +14 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +68 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/config.d.ts +49 -0
- package/dist/cli/utils/config.d.ts.map +1 -0
- package/dist/cli/utils/config.js +110 -0
- package/dist/cli/utils/config.js.map +1 -0
- package/dist/cli/utils/exec.d.ts +39 -0
- package/dist/cli/utils/exec.d.ts.map +1 -0
- package/dist/cli/utils/exec.js +68 -0
- package/dist/cli/utils/exec.js.map +1 -0
- package/dist/cli/utils/logger.d.ts +47 -0
- package/dist/cli/utils/logger.d.ts.map +1 -0
- package/dist/cli/utils/logger.js +97 -0
- package/dist/cli/utils/logger.js.map +1 -0
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +13 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +104 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +266 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +304 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +160 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/validator.d.ts +60 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/config/validator.js +112 -0
- package/dist/config/validator.js.map +1 -0
- package/dist/health/server.d.ts +47 -0
- package/dist/health/server.d.ts.map +1 -0
- package/dist/health/server.js +92 -0
- package/dist/health/server.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/orchestrator/async-event-queue.d.ts +28 -0
- package/dist/orchestrator/async-event-queue.d.ts.map +1 -0
- package/dist/orchestrator/async-event-queue.js +57 -0
- package/dist/orchestrator/async-event-queue.js.map +1 -0
- package/dist/orchestrator/client.d.ts +110 -0
- package/dist/orchestrator/client.d.ts.map +1 -0
- package/dist/orchestrator/client.js +288 -0
- package/dist/orchestrator/client.js.map +1 -0
- package/dist/orchestrator/event-bus.d.ts +195 -0
- package/dist/orchestrator/event-bus.d.ts.map +1 -0
- package/dist/orchestrator/event-bus.js +557 -0
- package/dist/orchestrator/event-bus.js.map +1 -0
- package/dist/orchestrator/heartbeat.d.ts +71 -0
- package/dist/orchestrator/heartbeat.d.ts.map +1 -0
- package/dist/orchestrator/heartbeat.js +116 -0
- package/dist/orchestrator/heartbeat.js.map +1 -0
- package/dist/orchestrator/index.d.ts +25 -0
- package/dist/orchestrator/index.d.ts.map +1 -0
- package/dist/orchestrator/index.js +15 -0
- package/dist/orchestrator/index.js.map +1 -0
- package/dist/orchestrator/job-handler.d.ts +109 -0
- package/dist/orchestrator/job-handler.d.ts.map +1 -0
- package/dist/orchestrator/job-handler.js +612 -0
- package/dist/orchestrator/job-handler.js.map +1 -0
- package/dist/orchestrator/job-queue.d.ts +81 -0
- package/dist/orchestrator/job-queue.d.ts.map +1 -0
- package/dist/orchestrator/job-queue.js +206 -0
- package/dist/orchestrator/job-queue.js.map +1 -0
- package/dist/orchestrator/label-monitor-bridge.d.ts +25 -0
- package/dist/orchestrator/label-monitor-bridge.d.ts.map +1 -0
- package/dist/orchestrator/label-monitor-bridge.js +57 -0
- package/dist/orchestrator/label-monitor-bridge.js.map +1 -0
- package/dist/orchestrator/log-buffer.d.ts +74 -0
- package/dist/orchestrator/log-buffer.d.ts.map +1 -0
- package/dist/orchestrator/log-buffer.js +104 -0
- package/dist/orchestrator/log-buffer.js.map +1 -0
- package/dist/orchestrator/redis-job-queue.d.ts +44 -0
- package/dist/orchestrator/redis-job-queue.d.ts.map +1 -0
- package/dist/orchestrator/redis-job-queue.js +300 -0
- package/dist/orchestrator/redis-job-queue.js.map +1 -0
- package/dist/orchestrator/router.d.ts +125 -0
- package/dist/orchestrator/router.d.ts.map +1 -0
- package/dist/orchestrator/router.js +143 -0
- package/dist/orchestrator/router.js.map +1 -0
- package/dist/orchestrator/server.d.ts +62 -0
- package/dist/orchestrator/server.d.ts.map +1 -0
- package/dist/orchestrator/server.js +711 -0
- package/dist/orchestrator/server.js.map +1 -0
- package/dist/orchestrator/types.d.ts +184 -0
- package/dist/orchestrator/types.d.ts.map +1 -0
- package/dist/orchestrator/types.js +6 -0
- package/dist/orchestrator/types.js.map +1 -0
- package/dist/orchestrator/worker-registry.d.ts +110 -0
- package/dist/orchestrator/worker-registry.d.ts.map +1 -0
- package/dist/orchestrator/worker-registry.js +191 -0
- package/dist/orchestrator/worker-registry.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Heartbeat manager.
|
|
3
|
+
* Handles periodic heartbeat to orchestrator.
|
|
4
|
+
*/
|
|
5
|
+
import { totalmem } from 'os';
|
|
6
|
+
/**
|
|
7
|
+
* Manages periodic heartbeat to orchestrator
|
|
8
|
+
*/
|
|
9
|
+
export class HeartbeatManager {
|
|
10
|
+
client;
|
|
11
|
+
workerId;
|
|
12
|
+
interval;
|
|
13
|
+
onCommand;
|
|
14
|
+
onError;
|
|
15
|
+
timer = null;
|
|
16
|
+
status = 'idle';
|
|
17
|
+
currentJob;
|
|
18
|
+
progress;
|
|
19
|
+
startTime = Date.now();
|
|
20
|
+
lastHeartbeat;
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this.client = options.client;
|
|
23
|
+
this.workerId = options.workerId;
|
|
24
|
+
this.interval = options.interval ?? 30000;
|
|
25
|
+
this.onCommand = options.onCommand;
|
|
26
|
+
this.onError = options.onError;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Start the heartbeat loop
|
|
30
|
+
*/
|
|
31
|
+
start() {
|
|
32
|
+
if (this.timer) {
|
|
33
|
+
return; // Already running
|
|
34
|
+
}
|
|
35
|
+
// Send initial heartbeat
|
|
36
|
+
this.sendHeartbeat();
|
|
37
|
+
// Start periodic heartbeats
|
|
38
|
+
this.timer = setInterval(() => {
|
|
39
|
+
this.sendHeartbeat();
|
|
40
|
+
}, this.interval);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Stop the heartbeat loop
|
|
44
|
+
*/
|
|
45
|
+
stop() {
|
|
46
|
+
if (this.timer) {
|
|
47
|
+
clearInterval(this.timer);
|
|
48
|
+
this.timer = null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Update worker status
|
|
53
|
+
*/
|
|
54
|
+
setStatus(status) {
|
|
55
|
+
this.status = status;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Set current job information
|
|
59
|
+
*/
|
|
60
|
+
setCurrentJob(jobId, progress) {
|
|
61
|
+
this.currentJob = jobId;
|
|
62
|
+
this.progress = progress;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get last successful heartbeat time
|
|
66
|
+
*/
|
|
67
|
+
getLastHeartbeat() {
|
|
68
|
+
return this.lastHeartbeat;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get uptime in milliseconds
|
|
72
|
+
*/
|
|
73
|
+
getUptime() {
|
|
74
|
+
return Date.now() - this.startTime;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Send a heartbeat to the orchestrator
|
|
78
|
+
*/
|
|
79
|
+
async sendHeartbeat() {
|
|
80
|
+
try {
|
|
81
|
+
const heartbeat = {
|
|
82
|
+
workerId: this.workerId,
|
|
83
|
+
status: this.status,
|
|
84
|
+
currentJob: this.currentJob,
|
|
85
|
+
progress: this.progress,
|
|
86
|
+
metrics: this.collectMetrics(),
|
|
87
|
+
timestamp: new Date().toISOString(),
|
|
88
|
+
};
|
|
89
|
+
const response = await this.client.heartbeat(heartbeat);
|
|
90
|
+
this.lastHeartbeat = new Date();
|
|
91
|
+
// Process any commands from orchestrator
|
|
92
|
+
if (response.commands && response.commands.length > 0) {
|
|
93
|
+
for (const command of response.commands) {
|
|
94
|
+
this.onCommand?.(command);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
this.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Collect system metrics
|
|
104
|
+
*/
|
|
105
|
+
collectMetrics() {
|
|
106
|
+
// Get memory usage
|
|
107
|
+
const memUsage = process.memoryUsage();
|
|
108
|
+
const totalMem = totalmem?.() ?? 0;
|
|
109
|
+
const memoryUsage = totalMem > 0 ? (memUsage.rss / totalMem) * 100 : 0;
|
|
110
|
+
return {
|
|
111
|
+
memoryUsage: Math.round(memoryUsage * 100) / 100,
|
|
112
|
+
uptime: this.getUptime(),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=heartbeat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"heartbeat.js","sourceRoot":"","sources":["../../src/orchestrator/heartbeat.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AA6B9B;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACV,MAAM,CAAqB;IAC3B,QAAQ,CAAS;IACjB,QAAQ,CAAS;IACjB,SAAS,CAAuC;IAChD,OAAO,CAA0B;IAE1C,KAAK,GAA0B,IAAI,CAAC;IACpC,MAAM,GAAiB,MAAM,CAAC;IAC9B,UAAU,CAAU;IACpB,QAAQ,CAAU;IAClB,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,aAAa,CAAQ;IAE7B,YAAY,OAAgC;QAC1C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,KAAK,CA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|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrator module exports
|
|
3
|
+
*/
|
|
4
|
+
export { OrchestratorClient, OrchestratorClientError } from './client.js';
|
|
5
|
+
export type { OrchestratorClientOptions } from './client.js';
|
|
6
|
+
export { HeartbeatManager } from './heartbeat.js';
|
|
7
|
+
export type { HeartbeatManagerOptions, WorkerStatus } from './heartbeat.js';
|
|
8
|
+
export { JobHandler } from './job-handler.js';
|
|
9
|
+
export type { JobHandlerOptions } from './job-handler.js';
|
|
10
|
+
export { WorkerRegistry } from './worker-registry.js';
|
|
11
|
+
export type { RegisteredWorker, WorkerRegistryOptions, IWorkerRegistry } from './worker-registry.js';
|
|
12
|
+
export { createRouter, pathToRegex, parseJsonBody, sendJson, sendError, } from './router.js';
|
|
13
|
+
export type { Route, RouteMatch, PathToRegexResult, Router } from './router.js';
|
|
14
|
+
export { InMemoryJobQueue } from './job-queue.js';
|
|
15
|
+
export type { JobQueue } from './job-queue.js';
|
|
16
|
+
export { RedisJobQueue, createJobQueue } from './redis-job-queue.js';
|
|
17
|
+
export { createOrchestratorServer } from './server.js';
|
|
18
|
+
export type { OrchestratorServer, OrchestratorServerOptions } from './server.js';
|
|
19
|
+
export { EventBus } from './event-bus.js';
|
|
20
|
+
export type { EventBusOptions } from './event-bus.js';
|
|
21
|
+
export { LogBuffer, LogBufferManager } from './log-buffer.js';
|
|
22
|
+
export type { LogEntry } from './log-buffer.js';
|
|
23
|
+
export { AsyncEventQueue } from './async-event-queue.js';
|
|
24
|
+
export type { Job, JobStatus, JobPriority, JobResult, WorkerRegistration, Heartbeat, HeartbeatResponse, PollResponse, OrchestratorError, JobEventType, JobEvent, EventFilters, } from './types.js';
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/orchestrator/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EA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EACT,WAAW,EACX,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACR,YAAY,GACb,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrator module exports
|
|
3
|
+
*/
|
|
4
|
+
export { OrchestratorClient, OrchestratorClientError } from './client.js';
|
|
5
|
+
export { HeartbeatManager } from './heartbeat.js';
|
|
6
|
+
export { JobHandler } from './job-handler.js';
|
|
7
|
+
export { WorkerRegistry } from './worker-registry.js';
|
|
8
|
+
export { createRouter, pathToRegex, parseJsonBody, sendJson, sendError, } from './router.js';
|
|
9
|
+
export { InMemoryJobQueue } from './job-queue.js';
|
|
10
|
+
export { RedisJobQueue, createJobQueue } from './redis-job-queue.js';
|
|
11
|
+
export { createOrchestratorServer } from './server.js';
|
|
12
|
+
export { EventBus } from './event-bus.js';
|
|
13
|
+
export { LogBuffer, LogBufferManager } from './log-buffer.js';
|
|
14
|
+
export { AsyncEventQueue } from './async-event-queue.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/orchestrator/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAG1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EACL,YAAY,EACZ,WAAW,EACX,aAAa,EACb,QAAQ,EACR,SAAS,GACV,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type HumanDecisionHandler, type Logger } from '@generacy-ai/workflow-engine';
|
|
2
|
+
import type { OrchestratorClient } from './client.js';
|
|
3
|
+
import type { Job, JobResult } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Job handler options
|
|
6
|
+
*/
|
|
7
|
+
export interface JobHandlerOptions {
|
|
8
|
+
/** Orchestrator client */
|
|
9
|
+
client: OrchestratorClient;
|
|
10
|
+
/** Worker ID */
|
|
11
|
+
workerId: string;
|
|
12
|
+
/** Poll interval in milliseconds */
|
|
13
|
+
pollInterval?: number;
|
|
14
|
+
/** Logger instance */
|
|
15
|
+
logger: Logger;
|
|
16
|
+
/** Working directory for job execution */
|
|
17
|
+
workdir?: string;
|
|
18
|
+
/** Worker capabilities for job matching */
|
|
19
|
+
capabilities?: string[];
|
|
20
|
+
/** Callback when job starts */
|
|
21
|
+
onJobStart?: (job: Job) => void;
|
|
22
|
+
/** Callback when job completes */
|
|
23
|
+
onJobComplete?: (job: Job, result: JobResult) => void;
|
|
24
|
+
/** Callback for errors */
|
|
25
|
+
onError?: (error: Error, job?: Job) => void;
|
|
26
|
+
/** Human decision handler for real human-in-the-loop review */
|
|
27
|
+
humanDecisionHandler?: HumanDecisionHandler;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Handles job polling and execution
|
|
31
|
+
*/
|
|
32
|
+
export declare class JobHandler {
|
|
33
|
+
private readonly client;
|
|
34
|
+
private readonly workerId;
|
|
35
|
+
private readonly pollInterval;
|
|
36
|
+
private readonly logger;
|
|
37
|
+
private readonly workdir;
|
|
38
|
+
private readonly capabilities;
|
|
39
|
+
private readonly onJobStart?;
|
|
40
|
+
private readonly onJobComplete?;
|
|
41
|
+
private readonly onError?;
|
|
42
|
+
private pollTimer;
|
|
43
|
+
private currentJob;
|
|
44
|
+
private abortController;
|
|
45
|
+
private isRunning;
|
|
46
|
+
private shouldStop;
|
|
47
|
+
private readonly humanDecisionHandler?;
|
|
48
|
+
constructor(options: JobHandlerOptions);
|
|
49
|
+
/**
|
|
50
|
+
* Start the job polling loop
|
|
51
|
+
*/
|
|
52
|
+
start(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Stop the job polling loop
|
|
55
|
+
*/
|
|
56
|
+
stop(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Cancel the current job
|
|
59
|
+
*/
|
|
60
|
+
cancelCurrentJob(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Get the currently executing job
|
|
63
|
+
*/
|
|
64
|
+
getCurrentJob(): Job | null;
|
|
65
|
+
/**
|
|
66
|
+
* Check if currently executing a job
|
|
67
|
+
*/
|
|
68
|
+
isBusy(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Poll for and process jobs
|
|
71
|
+
*/
|
|
72
|
+
private poll;
|
|
73
|
+
/**
|
|
74
|
+
* Execute a job
|
|
75
|
+
*/
|
|
76
|
+
private executeJob;
|
|
77
|
+
/**
|
|
78
|
+
* Resolve the working directory for a job.
|
|
79
|
+
* Uses MONITORED_REPOS env var to map owner/repo to local workspace paths.
|
|
80
|
+
* Falls back to job.workdir, then this.workdir.
|
|
81
|
+
*/
|
|
82
|
+
private resolveJobWorkdir;
|
|
83
|
+
/**
|
|
84
|
+
* Resolve a workflow name or path to an absolute file path.
|
|
85
|
+
* Searches: absolute path, relative to workdir, .generacy/ directory, plugin registry.
|
|
86
|
+
*
|
|
87
|
+
* @param workflow - Workflow name or path to resolve
|
|
88
|
+
* @param jobWorkdir - Job working directory for relative resolution
|
|
89
|
+
* @param excludePath - Optional resolved path to skip (used by extends to avoid self-resolution)
|
|
90
|
+
*/
|
|
91
|
+
private resolveWorkflowPath;
|
|
92
|
+
/**
|
|
93
|
+
* Resolve which phases have already been attempted based on issue labels.
|
|
94
|
+
* Recognises both `completed:*` and `failed:*` labels so that phases are
|
|
95
|
+
* not re-run on retry (failed verification still means the phase executed).
|
|
96
|
+
* Returns a set of YAML phase names to skip. Setup is never included.
|
|
97
|
+
*/
|
|
98
|
+
private resolveCompletedPhases;
|
|
99
|
+
/**
|
|
100
|
+
* Add a completed:* or failed:* label to the issue after a phase finishes.
|
|
101
|
+
* Uses `completed:` prefix when the phase succeeded, `failed:` when any step errored.
|
|
102
|
+
*/
|
|
103
|
+
private addPhaseLabel;
|
|
104
|
+
/**
|
|
105
|
+
* Build job result from execution result
|
|
106
|
+
*/
|
|
107
|
+
private buildJobResult;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=job-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-handler.d.ts","sourceRoot":"","sources":["../../src/orchestrator/job-handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAWL,KAAK,oBAAoB,EAGzB,KAAK,MAAM,EAGZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,GAAG,EAAgB,SAAS,EAAE,MAAM,YAAY,CAAC;AAiK/D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0BAA0B;IAC1B,MAAM,EAAE,kBAAkB,CAAC;IAE3B,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IAEjB,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IAEf,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,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