// Copyright (c) 2026 Hellmai Ltd
// SPDX-License-Identifier: AGPL-3.0-only
import { buildKernelEventV2 } from './kernel-event-sync/emitters.js';
export const AGENT_RUNTIME_CHANNEL_ID = 'agent-runtime';
const AGENT_RUNTIME_ENROLLMENT_EVENT_KINDS = {
    AGENT_SESSION_ENROLLED: 'agent-runtime:agent_session_enrolled',
    AGENT_SESSION_ENDED: 'agent-runtime:agent_session_ended',
    AGENT_SESSION_STALLED: 'agent-runtime:agent_session_stalled',
};
const channelSeqCounters = new Map();
export function buildAgentSessionEnrolledEvent(input, options) {
    return buildEnrollmentEvent({
        kind: AGENT_RUNTIME_ENROLLMENT_EVENT_KINDS.AGENT_SESSION_ENROLLED,
        ...input,
    }, options);
}
export function buildAgentSessionEndedEvent(input, options) {
    return buildEnrollmentEvent({
        kind: AGENT_RUNTIME_ENROLLMENT_EVENT_KINDS.AGENT_SESSION_ENDED,
        ...input,
    }, options);
}
export function buildAgentSessionStalledEvent(input, options) {
    return buildEnrollmentEvent({
        kind: AGENT_RUNTIME_ENROLLMENT_EVENT_KINDS.AGENT_SESSION_STALLED,
        ...input,
    }, options);
}
function buildEnrollmentEvent(payload, options) {
    const baseEvent = buildKernelEventV2(payload, options);
    return {
        ...baseEvent,
        ...payload,
        channel_id: AGENT_RUNTIME_CHANNEL_ID,
        seq: nextSeq(AGENT_RUNTIME_CHANNEL_ID),
    };
}
function nextSeq(channelId) {
    const current = channelSeqCounters.get(channelId) ?? 0;
    const next = current + 1;
    channelSeqCounters.set(channelId, next);
    return next;
}
//# sourceMappingURL=agent-runtime-enrollment-events.js.map