feat(plugin): add session agent resolver for subagent_type lookup

This commit is contained in:
YeonGyu-Kim
2026-02-13 12:02:27 +09:00
parent 9c43e10055
commit 923b2fa056
2 changed files with 132 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
import { log } from "../shared"
interface SessionMessage {
info?: {
agent?: string
role?: string
}
}
type SessionClient = {
session: {
messages: (opts: { path: { id: string } }) => Promise<{ data?: SessionMessage[] }>
}
}
export async function resolveSessionAgent(
client: SessionClient,
sessionId: string,
): Promise<string | undefined> {
try {
const messagesResp = await client.session.messages({ path: { id: sessionId } })
const messages = (messagesResp.data ?? []) as SessionMessage[]
for (const msg of messages) {
if (msg.info?.agent) {
return msg.info.agent
}
}
} catch (error) {
log("[session-agent-resolver] Failed to resolve agent from session", {
sessionId,
error: String(error),
})
}
return undefined
}