MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / parsePointer

Function parsePointer

apps/cli/src/daemon-state.ts:172–212  ·  view source on GitHub ↗
(raw: string)

Source from the content-addressed store, hash-verified

170};
171
172const parsePointer = (raw: string): DaemonPointer | null => {
173 let parsed: unknown;
174 try {
175 parsed = JSON.parse(raw);
176 } catch {
177 return null;
178 }
179
180 if (
181 typeof parsed !== "object" ||
182 parsed === null ||
183 !("version" in parsed) ||
184 (parsed as { version?: unknown }).version !== 1
185 ) {
186 return null;
187 }
188
189 const r = parsed as Record<string, unknown>;
190 if (
191 typeof r.hostname !== "string" ||
192 typeof r.port !== "number" ||
193 typeof r.pid !== "number" ||
194 typeof r.startedAt !== "string" ||
195 typeof r.scopeId !== "string" ||
196 !(typeof r.scopeDir === "string" || r.scopeDir === null) ||
197 typeof r.token !== "string"
198 ) {
199 return null;
200 }
201
202 return {
203 version: 1,
204 hostname: canonicalDaemonHost(r.hostname),
205 port: r.port,
206 pid: r.pid,
207 startedAt: r.startedAt,
208 scopeId: r.scopeId,
209 scopeDir: r.scopeDir,
210 token: r.token,
211 };
212};
213
214export const readDaemonRecord = (input: {
215 hostname: string;

Callers 1

readDaemonPointerFunction · 0.85

Calls 1

canonicalDaemonHostFunction · 0.85

Tested by

no test coverage detected