import { AGENTS_CORE } from '../manifest.js';
import { resolveAgentRuntimeControlSurfaceForSession } from './providerSessionBackends.js';
export const UNSUPPORTED_AGENT_SESSION_CAPABILITIES = Object.freeze({
    sessionListing: 'unsupported',
    sessionFork: Object.freeze({
        conversation: 'unsupported',
        fromMessage: 'unsupported',
    }),
    sessionRollback: Object.freeze({
        conversation: 'unsupported',
    }),
});
export function getAgentSessionCapabilities(agentId) {
    return AGENTS_CORE[agentId].sessionCapabilities ?? UNSUPPORTED_AGENT_SESSION_CAPABILITIES;
}
export function getAgentSessionCapability(agentId, capability) {
    const capabilities = getAgentSessionCapabilities(agentId);
    switch (capability) {
        case 'sessionListing':
            return capabilities.sessionListing;
        case 'sessionFork.conversation':
            return capabilities.sessionFork.conversation;
        case 'sessionFork.fromMessage':
            return capabilities.sessionFork.fromMessage;
        case 'sessionRollback.conversation':
            return capabilities.sessionRollback.conversation;
    }
}
export function isAgentSessionCapabilitySupported(agentId, capability) {
    return getAgentSessionCapability(agentId, capability) === 'supported';
}
export function evaluateAgentSessionCapabilitySupport(params) {
    const effectiveRuntimeControlSurface = resolveAgentRuntimeControlSurfaceForSession(params);
    const baseSupport = effectiveRuntimeControlSurface
        ? readCapabilityFromSurface(effectiveRuntimeControlSurface.sessionCapabilities, params.capability)
        : getAgentSessionCapability(params.agentId, params.capability);
    if (baseSupport === 'unsupported') {
        return baseSupport;
    }
    return baseSupport;
}
function readCapabilityFromSurface(capabilities, capability) {
    switch (capability) {
        case 'sessionListing':
            return capabilities.sessionListing;
        case 'sessionFork.conversation':
            return capabilities.sessionFork.conversation;
        case 'sessionFork.fromMessage':
            return capabilities.sessionFork.fromMessage;
        case 'sessionRollback.conversation':
            return capabilities.sessionRollback.conversation;
    }
}
//# sourceMappingURL=sessionCapabilities.js.map