agent-relay-runner 0.10.4 → 0.10.6
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
|
@@ -172,6 +172,7 @@ export class AgentRunner {
|
|
|
172
172
|
if (target !== this.agentId && target !== this.options.runnerId) return;
|
|
173
173
|
if (type !== "agent.shutdown" && type !== "agent.restart" && type !== "agent.kill") return;
|
|
174
174
|
|
|
175
|
+
const exitAfterCommand = type !== "agent.restart";
|
|
175
176
|
this.claims.startClaim("command", commandId);
|
|
176
177
|
this.publishStatus();
|
|
177
178
|
await this.updateCommand(commandId, "accepted");
|
|
@@ -180,12 +181,18 @@ export class AgentRunner {
|
|
|
180
181
|
if (type === "agent.restart") await this.restartProvider();
|
|
181
182
|
else await this.shutdownProvider(type === "agent.kill");
|
|
182
183
|
await this.updateCommand(commandId, "succeeded", { action: type, agentId: this.agentId, runnerId: this.options.runnerId });
|
|
183
|
-
if (type !== "agent.restart") setTimeout(() => void this.stop().finally(() => process.exit(0)), 10);
|
|
184
184
|
} catch (error) {
|
|
185
|
-
await this.updateCommand(commandId, "failed", undefined, error instanceof Error ? error.message : String(error));
|
|
185
|
+
await this.updateCommand(commandId, "failed", undefined, error instanceof Error ? error.message : String(error)).catch(() => {});
|
|
186
186
|
} finally {
|
|
187
187
|
this.claims.finishClaim("command", commandId);
|
|
188
|
-
if (
|
|
188
|
+
if (exitAfterCommand) {
|
|
189
|
+
await this.http.deleteAgent(this.agentId).catch(() => {});
|
|
190
|
+
setTimeout(() => void this.stop().catch((error) => {
|
|
191
|
+
console.error(`[runner] stop after command failed: ${error}`);
|
|
192
|
+
}).finally(() => process.exit(0)), 10);
|
|
193
|
+
} else if (!this.stopped) {
|
|
194
|
+
this.publishStatus();
|
|
195
|
+
}
|
|
189
196
|
}
|
|
190
197
|
}
|
|
191
198
|
|
|
@@ -210,7 +217,6 @@ export class AgentRunner {
|
|
|
210
217
|
}
|
|
211
218
|
this.claims.setTerminalStatus("offline");
|
|
212
219
|
this.publishStatus();
|
|
213
|
-
await this.http.deleteAgent(this.agentId).catch(() => {});
|
|
214
220
|
this.stopped = true;
|
|
215
221
|
}
|
|
216
222
|
|