MCPcopy Create free account
hub / github.com/BUPT-GAMMA/MASFactory / parseSessions

Function parseSessions

masfactory-visualizer/src/shared/runtimeProtocol.ts:177–201  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

175}
176
177function parseSessions(value: unknown): VisualizerSession[] {
178 if (!Array.isArray(value)) {return [];}
179 const out: VisualizerSession[] = [];
180 for (const it of value) {
181 if (!isRecord(it)) {continue;}
182 const id = asString(it.id);
183 if (!id) {continue;}
184 const pid = it.pid === null ? null : asNumber(it.pid);
185 const graphName = typeof it.graphName === 'string' ? it.graphName : it.graphName === null ? null : null;
186 const connectedAt = asRequiredNumber(it.connectedAt);
187 const lastSeenAt = asRequiredNumber(it.lastSeenAt);
188 const subscribed = typeof it.subscribed === 'boolean' ? it.subscribed : false;
189 if (connectedAt === null || lastSeenAt === null) {continue;}
190 out.push({
191 id,
192 pid,
193 graphName,
194 mode: asMode(it.mode),
195 connectedAt,
196 lastSeenAt,
197 subscribed
198 });
199 }
200 return out;
201}
202
203function parseDebugLocation(value: unknown): DebugLocation | undefined {
204 if (!isRecord(value)) {return undefined;}

Callers 1

parseRuntimeMessageFunction · 0.85

Calls 6

asRequiredNumberFunction · 0.85
pushMethod · 0.80
isRecordFunction · 0.70
asStringFunction · 0.70
asNumberFunction · 0.70
asModeFunction · 0.70

Tested by

no test coverage detected