export const INITIAL_PROMPT_PREFIX = "TASK_AGENT_INITIAL_PROMPT:";
const LEGACY_PROFILE_ID_PREFIX = "TASK_AGENT_PROFILE_ID:";
export const DEFAULT_INITIAL_PROMPT = "Read the task description first and start working on this task.";
export function getStoredPrompt(resultData) {
    if (!resultData)
        return "";
    const markerIndex = resultData.lastIndexOf(INITIAL_PROMPT_PREFIX);
    if (markerIndex === -1)
        return "";
    return resultData.slice(markerIndex + INITIAL_PROMPT_PREFIX.length).trim();
}
export function mergeAgentConfigIntoResultData(resultData, prompt, _profileId) {
    const promptIndex = resultData?.lastIndexOf(INITIAL_PROMPT_PREFIX) ?? -1;
    const profileIndex = resultData?.lastIndexOf(LEGACY_PROFILE_ID_PREFIX) ?? -1;
    const firstMarkerIndex = [promptIndex, profileIndex]
        .filter((index) => index >= 0)
        .sort((a, b) => a - b)[0] ?? -1;
    const base = firstMarkerIndex >= 0 ? resultData.slice(0, firstMarkerIndex).trim() : resultData?.trim() || "";
    const metadata = `${INITIAL_PROMPT_PREFIX}${prompt.trim()}`;
    return base ? `${base}\n\n${metadata}` : metadata;
}
export function stripAgentConfigFromResultData(resultData) {
    if (!resultData)
        return null;
    const promptIndex = resultData.lastIndexOf(INITIAL_PROMPT_PREFIX);
    const profileIndex = resultData.lastIndexOf(LEGACY_PROFILE_ID_PREFIX);
    const firstMarkerIndex = [promptIndex, profileIndex]
        .filter((index) => index >= 0)
        .sort((a, b) => a - b)[0] ?? -1;
    const base = firstMarkerIndex >= 0 ? resultData.slice(0, firstMarkerIndex).trim() : resultData.trim();
    return base || null;
}
//# sourceMappingURL=taskAgentConfig.js.map