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

Function parseRecord

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

Source from the content-addressed store, hash-verified

132 });
133
134const parseRecord = (raw: string): DaemonRecord | null => {
135 let parsed: unknown;
136 try {
137 parsed = JSON.parse(raw);
138 } catch {
139 return null;
140 }
141
142 if (
143 typeof parsed !== "object" ||
144 parsed === null ||
145 !("version" in parsed) ||
146 (parsed as { version?: unknown }).version !== 1
147 ) {
148 return null;
149 }
150
151 const r = parsed as Record<string, unknown>;
152 if (
153 typeof r.hostname !== "string" ||
154 typeof r.port !== "number" ||
155 typeof r.pid !== "number" ||
156 typeof r.startedAt !== "string" ||
157 !(typeof r.scopeDir === "string" || r.scopeDir === null)
158 ) {
159 return null;
160 }
161
162 return {
163 version: 1,
164 hostname: canonicalDaemonHost(r.hostname),
165 port: r.port,
166 pid: r.pid,
167 startedAt: r.startedAt,
168 scopeDir: r.scopeDir,
169 };
170};
171
172const parsePointer = (raw: string): DaemonPointer | null => {
173 let parsed: unknown;

Callers 1

readDaemonRecordFunction · 0.85

Calls 1

canonicalDaemonHostFunction · 0.85

Tested by

no test coverage detected