agent-relay-runner 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
CHANGED
package/src/runner.ts
CHANGED
|
@@ -88,9 +88,10 @@ export class AgentRunner {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
async stop(): Promise<void> {
|
|
91
|
+
const alreadyStopped = this.stopped;
|
|
91
92
|
this.stopped = true;
|
|
92
|
-
await this.bus.statusAsync({ agentStatus: "offline", ready: false });
|
|
93
|
-
if (this.process) {
|
|
93
|
+
if (!alreadyStopped) await this.bus.statusAsync({ agentStatus: "offline", ready: false });
|
|
94
|
+
if (this.process && !alreadyStopped) {
|
|
94
95
|
await this.options.adapter.shutdown(this.process, {
|
|
95
96
|
graceful: true,
|
|
96
97
|
timeoutMs: this.options.providerConfig.headless.shutdownTimeoutMs,
|
|
@@ -183,7 +184,7 @@ export class AgentRunner {
|
|
|
183
184
|
await this.updateCommand(commandId, "failed", undefined, error instanceof Error ? error.message : String(error));
|
|
184
185
|
} finally {
|
|
185
186
|
this.claims.finishClaim("command", commandId);
|
|
186
|
-
this.publishStatus();
|
|
187
|
+
if (!this.stopped) this.publishStatus();
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
|
|
@@ -225,12 +226,14 @@ export class AgentRunner {
|
|
|
225
226
|
|
|
226
227
|
private publishStatus(): void {
|
|
227
228
|
const status = this.claims.currentStatus();
|
|
229
|
+
const agentStatus = runnerAgentStatus(status);
|
|
228
230
|
this.bus.setSemanticStatus(status === "offline" || status === "error" ? "idle" : status);
|
|
229
231
|
this.bus.status({
|
|
230
|
-
agentStatus
|
|
231
|
-
ready:
|
|
232
|
+
agentStatus,
|
|
233
|
+
ready: agentStatus !== "offline" && !this.stopped,
|
|
232
234
|
meta: {
|
|
233
235
|
runnerId: this.options.runnerId,
|
|
236
|
+
...(status === "error" ? { terminalStatus: "error" } : {}),
|
|
234
237
|
busyReasons: this.claims.reasons(),
|
|
235
238
|
transport: this.bus.transportState,
|
|
236
239
|
},
|
|
@@ -264,6 +267,10 @@ function relayBusUrl(relayUrl: string): string {
|
|
|
264
267
|
return url.toString();
|
|
265
268
|
}
|
|
266
269
|
|
|
270
|
+
export function runnerAgentStatus(status: "idle" | "busy" | "offline" | "error"): "idle" | "busy" | "offline" {
|
|
271
|
+
return status === "error" ? "offline" : status;
|
|
272
|
+
}
|
|
273
|
+
|
|
267
274
|
function lifecycleCapabilities(): Record<string, true> {
|
|
268
275
|
return {
|
|
269
276
|
shutdownHard: true,
|