agent-relay-server 0.10.11 → 0.10.13
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/scripts/orchestrator-spawn-smoke.ts +13 -2
- package/src/bus.ts +5 -0
- package/src/routes.ts +1 -1
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ type Orchestrator = {
|
|
|
4
4
|
status: string;
|
|
5
5
|
providers: string[];
|
|
6
6
|
baseDir: string;
|
|
7
|
-
managedAgents?: Array<{ label?: string; tmuxSession: string }>;
|
|
7
|
+
managedAgents?: Array<{ agentId?: string; label?: string; tmuxSession: string }>;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
type Agent = {
|
|
@@ -115,7 +115,7 @@ for (const provider of providers) {
|
|
|
115
115
|
});
|
|
116
116
|
console.log(`registered ${provider}: ${agent.id}`);
|
|
117
117
|
|
|
118
|
-
await waitFor(`waiting for ${provider} managed session`, async () => {
|
|
118
|
+
const managed = await waitFor(`waiting for ${provider} managed session`, async () => {
|
|
119
119
|
const latest = (await api<Orchestrator[]>("GET", "/orchestrators")).find((orch) => orch.id === orchestrator.id);
|
|
120
120
|
return latest?.managedAgents?.find((entry) => entry.label === label || entry.tmuxSession.includes(label)) || null;
|
|
121
121
|
});
|
|
@@ -127,6 +127,17 @@ for (const provider of providers) {
|
|
|
127
127
|
const current = await apiOptional<Agent>("GET", `/agents/${encodeURIComponent(agent.id)}`);
|
|
128
128
|
return current ? null : true;
|
|
129
129
|
});
|
|
130
|
+
await api("POST", `/orchestrators/${encodeURIComponent(orchestrator.id)}/actions`, {
|
|
131
|
+
action: "shutdown",
|
|
132
|
+
agentId: agent.id,
|
|
133
|
+
tmuxSession: managed.tmuxSession,
|
|
134
|
+
reason: "smoke-cleanup",
|
|
135
|
+
});
|
|
136
|
+
await waitFor(`waiting for ${provider} managed session cleanup`, async () => {
|
|
137
|
+
const latest = (await api<Orchestrator[]>("GET", "/orchestrators")).find((orch) => orch.id === orchestrator.id);
|
|
138
|
+
const stillManaged = latest?.managedAgents?.some((entry) => entry.tmuxSession === managed.tmuxSession || entry.agentId === agent.id);
|
|
139
|
+
return stillManaged ? null : true;
|
|
140
|
+
});
|
|
130
141
|
console.log(`shutdown ${provider}: ${label}`);
|
|
131
142
|
}
|
|
132
143
|
|
package/src/bus.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { getAgent, getDb, heartbeat, markReady, orphanTasksForAgent, setStatus,
|
|
|
3
3
|
import { getOldestOutboxCursor, getOutboxCursor, replayEvents, type BusEvent } from "./bus-outbox";
|
|
4
4
|
import { emitRelayEvent, subscribeRelayEvents, type RelayEvent } from "./events";
|
|
5
5
|
import { createCommand, getCommand, updateCommand } from "./commands-db";
|
|
6
|
+
import { getLifecycleManager } from "./lifecycle-manager";
|
|
6
7
|
import { applyCommandToRecipe } from "./recipe-runner";
|
|
7
8
|
import {
|
|
8
9
|
BusProtocolError,
|
|
@@ -230,6 +231,10 @@ function handleRegister(ws: BusWebSocket, frame: RegisterFrame): void {
|
|
|
230
231
|
meta: payload.meta,
|
|
231
232
|
});
|
|
232
233
|
epoch = agent.epoch;
|
|
234
|
+
getLifecycleManager().onAgentRegistered(agent.id, {
|
|
235
|
+
policyName: stringMeta(payload.meta, "policyName"),
|
|
236
|
+
spawnRequestId: stringMeta(payload.meta, "spawnRequestId"),
|
|
237
|
+
});
|
|
233
238
|
emitAgentStatusEvent(agent.id);
|
|
234
239
|
}
|
|
235
240
|
|
package/src/routes.ts
CHANGED
|
@@ -1552,7 +1552,7 @@ const postOrchestratorAction: Handler = async (req, params) => {
|
|
|
1552
1552
|
const command = createCommand({
|
|
1553
1553
|
type: action === "restart" ? "agent.restart" : "agent.shutdown",
|
|
1554
1554
|
source: "system",
|
|
1555
|
-
target:
|
|
1555
|
+
target: orch.agentId,
|
|
1556
1556
|
correlationId: spawnRequestId,
|
|
1557
1557
|
params: { action, agentId, policyName, spawnRequestId, tmuxSession, reason, requestedBy: "dashboard", requestedAt: Date.now(), orchestratorId: orch.id },
|
|
1558
1558
|
});
|