import { createHash } from "node:crypto";
/**
 * Stable `turn_key` values for GitHub-backed issue thread messages.
 *
 * `conversation_message` uses schema `canonical_name_fields: ["turn_key"]`.
 * Without `turn_key`, resolution falls back to sorted-field heuristics and can
 * collapse distinct GitHub comments that share the same `author` string.
 */
function githubIssueThreadPrefix(repo, issueNumber) {
    return `github:${repo.trim()}#${issueNumber}`;
}
function shortHash(value) {
    return createHash("sha256").update(value).digest("hex").slice(0, 16);
}
export function localIssueId(repo, title, createdAt) {
    return `local:${repo.trim()}:${shortHash(`${repo.trim()}\n${createdAt}\n${title.trim()}`)}`;
}
function localIssueThreadPrefix(repo, issueId) {
    return `local:${repo.trim()}:${issueId.trim()}`;
}
export function githubIssueBodyTurnKey(repo, issueNumber) {
    return `${githubIssueThreadPrefix(repo, issueNumber)}:issue-body`;
}
export function githubIssueCommentTurnKey(repo, issueNumber, commentId) {
    return `${githubIssueThreadPrefix(repo, issueNumber)}:comment:${String(commentId).trim()}`;
}
export function localIssueBodyTurnKey(repo, issueId) {
    return `${localIssueThreadPrefix(repo, issueId)}:issue-body`;
}
/** Stable `turn_key` for follow-up messages on Neotoma-local issue threads (no GitHub number). */
export function localIssueCommentTurnKey(repo, issueId, commentKey) {
    return `${localIssueThreadPrefix(repo, issueId)}:comment:${String(commentKey).trim()}`;
}
//# sourceMappingURL=github_thread_keys.js.map