agent-relay-orchestrator 0.10.1 → 0.10.3
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/package.json +1 -1
- package/src/index.ts +3 -7
- package/src/recovery.ts +22 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { loadConfig, initConfigFile } from "./config";
|
|
3
3
|
import { createRelayClient } from "./relay";
|
|
4
4
|
import { createControlHandler } from "./control";
|
|
5
|
-
import {
|
|
5
|
+
import { hasSession } from "./tmux";
|
|
6
6
|
import { startApiServer } from "./api";
|
|
7
|
+
import { recoverManagedAgents } from "./recovery";
|
|
7
8
|
|
|
8
9
|
const args = process.argv.slice(2);
|
|
9
10
|
|
|
@@ -62,12 +63,7 @@ async function startup(): Promise<void> {
|
|
|
62
63
|
relay.startHeartbeatLoop();
|
|
63
64
|
|
|
64
65
|
// Recover existing tmux sessions
|
|
65
|
-
|
|
66
|
-
if (recovered.length > 0) {
|
|
67
|
-
console.error(`[orchestrator] Recovered ${recovered.length} existing session(s)`);
|
|
68
|
-
control.setManagedAgents(recovered);
|
|
69
|
-
await relay.updateManagedAgents(recovered);
|
|
70
|
-
}
|
|
66
|
+
await recoverManagedAgents(config, control, relay);
|
|
71
67
|
|
|
72
68
|
// Start polling for command requests
|
|
73
69
|
startPolling();
|
package/src/recovery.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { OrchestratorConfig } from "./config";
|
|
2
|
+
import type { ManagedAgentReport, RelayClient } from "./relay";
|
|
3
|
+
import { recoverExistingSessions } from "./tmux";
|
|
4
|
+
|
|
5
|
+
interface ManagedAgentControl {
|
|
6
|
+
setManagedAgents(agents: ManagedAgentReport[]): void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function recoverManagedAgents(
|
|
10
|
+
config: OrchestratorConfig,
|
|
11
|
+
control: ManagedAgentControl,
|
|
12
|
+
relay: Pick<RelayClient, "updateManagedAgents">,
|
|
13
|
+
recover: (config: OrchestratorConfig) => Promise<ManagedAgentReport[]> = recoverExistingSessions,
|
|
14
|
+
): Promise<ManagedAgentReport[]> {
|
|
15
|
+
const recovered = await recover(config);
|
|
16
|
+
if (recovered.length > 0) {
|
|
17
|
+
console.error(`[orchestrator] Recovered ${recovered.length} existing session(s)`);
|
|
18
|
+
}
|
|
19
|
+
control.setManagedAgents(recovered);
|
|
20
|
+
await relay.updateManagedAgents(recovered);
|
|
21
|
+
return recovered;
|
|
22
|
+
}
|