File size: 562 Bytes
4e23b01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import {
  ensureMainAgent as ensureMainAgentContext,
  IAgentLifecycleService,
  MAIN_AGENT_ID,
  type IAgentScopeHandle,
  type ISessionScopeHandle,
} from '@moonshot-ai/agent-core-v2';

export { MAIN_AGENT_ID };

export async function ensureMainAgent(session: ISessionScopeHandle): Promise<IAgentScopeHandle> {
  const context = await ensureMainAgentContext(session);
  const handle = session.accessor.get(IAgentLifecycleService).handleOf(context.agentId);
  if (handle === undefined) {
    throw new Error('Main agent was not found');
  }
  return handle;
}