| 128 | } |
| 129 | |
| 130 | function parseCommand(value: unknown): SidecarCommand | undefined { |
| 131 | if (!value || typeof value !== "object") return |
| 132 | const command = value as Partial<StartCommand | StopCommand> |
| 133 | if (command.type === "stop") return { type: "stop" } |
| 134 | if (command.type !== "start") return |
| 135 | if (typeof command.hostname !== "string") return |
| 136 | if (typeof command.port !== "number") return |
| 137 | if (typeof command.password !== "string") return |
| 138 | if (typeof command.userDataPath !== "string") return |
| 139 | return { |
| 140 | type: "start", |
| 141 | hostname: command.hostname, |
| 142 | port: command.port, |
| 143 | password: command.password, |
| 144 | userDataPath: command.userDataPath, |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | function serializeError(error: unknown) { |
| 149 | if (error instanceof Error) return { message: error.message, stack: error.stack } |