import { DEFAULT_AGENT_ID, DEFAULT_CHANNEL_ACCOUNT_ID, DEFAULT_MAIN_SESSION_SUFFIX, buildAgentSessionKey, buildMainSessionKey, buildChannelAccountOwnerKey, normalizeAgentId, normalizeChannelAccountId, normalizeChannelType, normalizeSessionSuffix, parseChannelAccountOwnerKey, resolveChannelAccountOwner, type AgentSummary, type AgentChannelBinding, type AgentChannelBindingInput, type AgentChannelUnbindingInput, type AgentsSnapshot, } from './agents'; export type ModelSummary = AgentSummary; export const DEFAULT_MODEL_ID = DEFAULT_AGENT_ID; export type ModelsSnapshot = AgentsSnapshot & { models: ModelSummary[]; agents?: ModelSummary[]; }; export interface ParsedSessionKey { sessionKey: string; agentId: string; sessionId: string; isAgentSession: boolean; } export function parseSessionKey(sessionKey: string): ParsedSessionKey { const trimmed = String(sessionKey ?? '').trim(); if (trimmed.startsWith('agent:')) { const parts = trimmed.split(':'); const agentId = normalizeAgentId(parts[1]); const sessionId = normalizeSessionSuffix(parts.slice(2).join(':')); return { sessionKey: buildAgentSessionKey(agentId, sessionId), agentId, sessionId, isAgentSession: true, }; } if (trimmed.startsWith('local:')) { const parts = trimmed.split(':'); const agentId = normalizeAgentId(parts[1]); const sessionId = normalizeSessionSuffix(parts.slice(2).join(':')); return { sessionKey: buildAgentSessionKey(agentId, sessionId), agentId, sessionId, isAgentSession: true, }; } return { sessionKey: trimmed, agentId: DEFAULT_AGENT_ID, sessionId: normalizeSessionSuffix(trimmed), isAgentSession: false, }; } export function normalizeAgentSessionKey(sessionKey: string): string { return parseSessionKey(sessionKey).sessionKey; } export const normalizeModelId = normalizeAgentId; export const buildModelSessionKey = buildAgentSessionKey; export const normalizeModelSessionKey = normalizeAgentSessionKey; export { DEFAULT_AGENT_ID, DEFAULT_CHANNEL_ACCOUNT_ID, DEFAULT_MAIN_SESSION_SUFFIX, buildAgentSessionKey, buildMainSessionKey, buildChannelAccountOwnerKey, normalizeAgentId, normalizeChannelAccountId, normalizeChannelType, normalizeSessionSuffix, parseChannelAccountOwnerKey, resolveChannelAccountOwner, }; export type { AgentSummary, AgentChannelBinding, AgentChannelBindingInput, AgentChannelUnbindingInput, AgentsSnapshot, };