mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import { Writable } from "node:stream";
|
|
|
|
import type { GatewayService } from "../../daemon/service.js";
|
|
import { defaultRuntime } from "../../runtime.js";
|
|
|
|
export type DaemonAction = "install" | "uninstall" | "start" | "stop" | "restart";
|
|
|
|
export type DaemonActionResponse = {
|
|
ok: boolean;
|
|
action: DaemonAction;
|
|
result?: string;
|
|
message?: string;
|
|
error?: string;
|
|
hints?: string[];
|
|
warnings?: string[];
|
|
service?: {
|
|
label: string;
|
|
loaded: boolean;
|
|
loadedText: string;
|
|
notLoadedText: string;
|
|
};
|
|
};
|
|
|
|
export function emitDaemonActionJson(payload: DaemonActionResponse) {
|
|
defaultRuntime.log(JSON.stringify(payload, null, 2));
|
|
}
|
|
|
|
export function buildDaemonServiceSnapshot(service: GatewayService, loaded: boolean) {
|
|
return {
|
|
label: service.label,
|
|
loaded,
|
|
loadedText: service.loadedText,
|
|
notLoadedText: service.notLoadedText,
|
|
};
|
|
}
|
|
|
|
export function createNullWriter(): Writable {
|
|
return new Writable({
|
|
write(_chunk, _encoding, callback) {
|
|
callback();
|
|
},
|
|
});
|
|
}
|