MCPcopy Create free account
hub / github.com/tiann/hapi / extractSessionId

Function extractSessionId

cli/src/opencode/opencodeLocalLauncher.ts:112–137  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

110}
111
112function extractSessionId(value: unknown): string | null {
113 if (!isObject(value)) {
114 return null;
115 }
116 const record = value as Record<string, unknown>;
117 const direct = getString(record.sessionId)
118 || getString(record.sessionID)
119 || getString(record.session_id)
120 || (isObject(record.session) ? getString((record.session as Record<string, unknown>).id) : null);
121 if (direct) {
122 return direct;
123 }
124 if (isObject(record.part)) {
125 const nested = extractSessionId(record.part);
126 if (nested) {
127 return nested;
128 }
129 }
130 if (isObject(record.info)) {
131 const nested = extractSessionId(record.info);
132 if (nested) {
133 return nested;
134 }
135 }
136 return null;
137}
138
139function unwrapMessage(payload: unknown): Record<string, unknown> | null {
140 if (!isObject(payload)) {

Callers 1

handleHookEventFunction · 0.70

Calls 2

isObjectFunction · 0.85
getStringFunction · 0.70

Tested by

no test coverage detected