const MAX_ENTRIES = 1000;
const store = new Map();
function getList(workspaceId) {
    let list = store.get(workspaceId);
    if (!list) {
        list = [];
        store.set(workspaceId, list);
    }
    return list;
}
let counter = 0;
export function logGitOperation(workspaceId, operation, input, result, error, duration = 0) {
    const list = getList(workspaceId);
    const entry = {
        id: `${Date.now()}-${++counter}`,
        operation,
        input,
        output: truncateOutput(result),
        error,
        timestamp: new Date().toISOString(),
        duration,
    };
    list.unshift(entry);
    if (list.length > MAX_ENTRIES)
        list.length = MAX_ENTRIES;
}
export function getGitOperations(workspaceId) {
    return getList(workspaceId);
}
function truncateOutput(value) {
    if (value === undefined || value === null)
        return value;
    if (typeof value === 'string')
        return value.length > 5000 ? value.slice(0, 5000) + '...(truncated)' : value;
    const s = JSON.stringify(value);
    if (s && s.length > 5000)
        return JSON.parse(s.slice(0, 5000) + '...(truncated)');
    return value;
}
//# sourceMappingURL=git-operation-log.js.map