2026-02-28 00:50:23 +01:00
|
|
|
import type { PluginInput } from "@opencode-ai/plugin"
|
|
|
|
|
import { log, normalizeSDKResponse } from "../../shared"
|
2026-03-01 16:48:12 +01:00
|
|
|
import { hasCouncilResponseTag } from "./council-continuation-enforcer"
|
2026-02-28 00:50:23 +01:00
|
|
|
|
|
|
|
|
type OpencodeClient = PluginInput["client"]
|
|
|
|
|
|
|
|
|
|
export async function sessionHasCouncilResponse(
|
|
|
|
|
client: OpencodeClient,
|
|
|
|
|
sessionID: string,
|
|
|
|
|
): Promise<boolean> {
|
|
|
|
|
try {
|
|
|
|
|
const response = await client.session.messages({
|
|
|
|
|
path: { id: sessionID },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const messages = normalizeSDKResponse(
|
|
|
|
|
response,
|
|
|
|
|
[] as Array<{ info?: { role?: string }; parts?: Array<{ type?: string; text?: string }> }>,
|
|
|
|
|
{ preferResponseOnMissingData: true },
|
|
|
|
|
)
|
|
|
|
|
|
2026-03-01 16:48:12 +01:00
|
|
|
return hasCouncilResponseTag(messages)
|
2026-02-28 00:50:23 +01:00
|
|
|
} catch (error) {
|
|
|
|
|
log("[council-response-checker] Error checking session for response tag:", {
|
|
|
|
|
sessionID,
|
|
|
|
|
error: String(error),
|
|
|
|
|
})
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|