MCPcopy
hub / github.com/Dimillian/CodexMonitor / parseCollabAgentStatusesFromMap

Function parseCollabAgentStatusesFromMap

src/utils/threadItems.collab.ts:112–140  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

110}
111
112function parseCollabAgentStatusesFromMap(value: unknown) {
113 if (!value || typeof value !== "object" || Array.isArray(value)) {
114 return [];
115 }
116 return Object.entries(value as Record<string, unknown>)
117 .map(([threadId, state]) => {
118 const stateRecord =
119 state && typeof state === "object"
120 ? (state as Record<string, unknown>)
121 : null;
122 const status = asString(stateRecord?.status ?? state ?? "").trim();
123 if (!status || !threadId) {
124 return null;
125 }
126 return buildCollabAgentStatus(
127 threadId,
128 status,
129 stateRecord?.agentNickname ??
130 stateRecord?.agent_nickname ??
131 stateRecord?.nickname,
132 stateRecord?.agentRole ??
133 stateRecord?.agent_role ??
134 stateRecord?.agentType ??
135 stateRecord?.agent_type ??
136 stateRecord?.role,
137 );
138 })
139 .filter((entry): entry is CollabAgentStatus => Boolean(entry));
140}
141
142function mergeCollabAgentStatuses(...lists: CollabAgentStatus[][]) {
143 const byThreadId = new Map<string, CollabAgentStatus>();

Callers 1

parseCollabToolCallItemFunction · 0.85

Calls 2

asStringFunction · 0.90
buildCollabAgentStatusFunction · 0.85

Tested by

no test coverage detected