feat(council-archive): add shared extraction utility and background task type extensions

- Create council-response-extractor.ts with ported extractCouncilResponse()
- Add writeOutputToFile, outputFilePath, _isCompleting to BackgroundTask
- Add writeOutputToFile to LaunchInput
- 8/8 extraction tests passing
This commit is contained in:
ismeth
2026-02-27 15:03:15 +01:00
committed by YeonGyu-Kim
parent 5a819d0914
commit b7552f13ac
3 changed files with 137 additions and 0 deletions
@@ -0,0 +1,26 @@
export const OPENING_TAG = "<COUNCIL_MEMBER_RESPONSE>"
export const CLOSING_TAG = "</COUNCIL_MEMBER_RESPONSE>"
export interface CouncilResponseExtraction {
has_response: boolean
response_complete: boolean
result: string | null
}
export function extractCouncilResponse(fullText: string): CouncilResponseExtraction {
const lastOpenIdx = fullText.lastIndexOf(OPENING_TAG)
if (lastOpenIdx === -1) {
return { has_response: false, response_complete: false, result: null }
}
const contentStart = lastOpenIdx + OPENING_TAG.length
const closingAfterLastOpen = fullText.indexOf(CLOSING_TAG, contentStart)
if (closingAfterLastOpen === -1) {
const partial = fullText.slice(contentStart).trim()
return { has_response: true, response_complete: false, result: partial || null }
}
const content = fullText.slice(contentStart, closingAfterLastOpen).trim()
return { has_response: true, response_complete: true, result: content }
}