MCPcopy
hub / github.com/anomalyco/opencode / parseCommand

Function parseCommand

packages/desktop/src/main/sidecar.ts:130–146  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

128}
129
130function 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
148function serializeError(error: unknown) {
149 if (error instanceof Error) return { message: error.message, stack: error.stack }

Callers 1

sidecar.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected