import { AGENTS_CORE } from './manifest.js';
function isPlainObject(value) {
    return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
}
function mergeRuntimeOverrides(base, overrides) {
    if (overrides === undefined)
        return base;
    if (Array.isArray(base) || Array.isArray(overrides)) {
        return overrides;
    }
    if (isPlainObject(base) && isPlainObject(overrides)) {
        const merged = { ...base };
        for (const key of Object.keys(overrides)) {
            const overrideValue = overrides[key];
            if (overrideValue === undefined)
                continue;
            merged[key] = key in merged
                ? mergeRuntimeOverrides(merged[key], overrideValue)
                : overrideValue;
        }
        return merged;
    }
    return overrides;
}
function readAgentRuntimeControlSurface(agentId) {
    const entry = AGENTS_CORE[agentId];
    return {
        sessionStorage: entry.sessionStorage,
        sessionCapabilities: entry.sessionCapabilities,
        resume: entry.resume,
        handoff: entry.handoff,
        localControl: entry.localControl ?? null,
        tools: entry.tools,
    };
}
export function getAgentRuntimeKindsManifest(agentId) {
    return AGENTS_CORE[agentId].runtimeKinds ?? null;
}
export function resolveDefaultAgentRuntimeKind(agentId) {
    const manifest = getAgentRuntimeKindsManifest(agentId);
    return manifest?.defaultKind ?? null;
}
export function resolveAgentRuntimeControlSurface(agentId, runtimeKind) {
    const base = readAgentRuntimeControlSurface(agentId);
    const manifest = getAgentRuntimeKindsManifest(agentId);
    if (!manifest || !runtimeKind)
        return base;
    const overrideDefinition = manifest.byKind[runtimeKind];
    return mergeRuntimeOverrides(base, overrideDefinition?.overrides);
}
//# sourceMappingURL=runtimeKinds.js.map