MCPcopy
hub / github.com/callstack/agent-device / readRemoteConnectionState

Function readRemoteConnectionState

src/remote/remote-connection-state.ts:56–74  ·  view source on GitHub ↗
(options: {
  stateDir: string;
  session: string;
})

Source from the content-addressed store, hash-verified

54};
55
56export function readRemoteConnectionState(options: {
57 stateDir: string;
58 session: string;
59}): RemoteConnectionState | null {
60 const statePath = remoteConnectionStatePath(options);
61 if (!fs.existsSync(statePath)) return null;
62 let parsed: unknown;
63 try {
64 parsed = JSON.parse(fs.readFileSync(statePath, 'utf8'));
65 } catch (error) {
66 removeInvalidRemoteConnectionState(options, error);
67 return null;
68 }
69 if (!isRemoteConnectionState(parsed)) {
70 removeInvalidRemoteConnectionState(options);
71 return null;
72 }
73 return parsed;
74}
75
76export function writeRemoteConnectionState(options: {
77 stateDir: string;

Calls 4

isRemoteConnectionStateFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected