MCPcopy Index your code
hub / github.com/Dimillian/CodexMonitor / getSubagentKind

Function getSubagentKind

src/features/threads/utils/threadRpc.ts:36–78  ·  view source on GitHub ↗
(source: unknown)

Source from the content-addressed store, hash-verified

34}
35
36function getSubagentKind(source: unknown): string | null {
37 if (typeof source === "string") {
38 const normalized = normalizeSubagentKind(source);
39 return normalized || null;
40 }
41
42 const sourceRecord = asRecord(source);
43 if (!sourceRecord) {
44 return null;
45 }
46
47 const subAgentRaw =
48 sourceRecord.subAgent ?? sourceRecord.sub_agent ?? sourceRecord.subagent;
49 if (typeof subAgentRaw === "string") {
50 const normalized = normalizeSubagentKind(subAgentRaw);
51 return normalized || null;
52 }
53
54 const subAgentRecord = asRecord(subAgentRaw);
55 if (!subAgentRecord) {
56 return null;
57 }
58
59 const explicitKind = asString(
60 subAgentRecord.kind ??
61 subAgentRecord.type ??
62 subAgentRecord.name ??
63 subAgentRecord.id,
64 );
65 if (explicitKind) {
66 const normalized = normalizeSubagentKind(explicitKind);
67 return normalized || null;
68 }
69
70 const candidateKeys = Object.keys(subAgentRecord).filter(
71 (key) => key !== "thread_spawn" && key !== "threadSpawn",
72 );
73 if (candidateKeys.length !== 1) {
74 return null;
75 }
76 const normalized = normalizeSubagentKind(candidateKeys[0] ?? "");
77 return normalized || null;
78}
79
80export function isSubagentThreadSource(source: unknown): boolean {
81 if (typeof source === "string") {

Callers 1

Calls 3

asStringFunction · 0.90
normalizeSubagentKindFunction · 0.85
asRecordFunction · 0.70

Tested by

no test coverage detected