import { createDecorator, type ServiceIdentifier } from '#/_base/di/instantiation'; import type { IAgentScopeHandle } from '#/_base/di/scope'; import type { Event } from '#/_base/event'; import type { AgentContext } from '#/agent/agentContext/agentContext'; import type { PermissionMode } from '#/agent/permissionPolicy/types'; import type { BindAgentInput } from '#/agent/profile/profile'; export interface AgentScopeCreatedEvent { readonly context: AgentContext; readonly handle: IAgentScopeHandle; } export const MAIN_AGENT_ID = 'main'; export interface CreateAgentOptions { readonly agentId?: string; readonly binding?: BindAgentInput; readonly runtimeId?: string; readonly forkedFrom?: string; readonly labels?: Readonly>; } export interface ForkAgentOptions { readonly agentId?: string; readonly binding?: Partial; readonly labels?: Readonly>; } export interface AgentListFilter { readonly prefix?: string; } export interface IAgentLifecycleService { readonly _serviceBrand: undefined; readonly onDidCreate: Event; readonly onDidCreateScope: Event; readonly onWillClose: Event; readonly onDidClose: Event; create(opts?: CreateAgentOptions): Promise; fork(source: AgentContext, opts?: ForkAgentOptions): Promise; get(agentId: string): AgentContext | undefined; list(filter?: AgentListFilter): readonly AgentContext[]; broadcastPermissionMode(mode: PermissionMode): void; remove(agent: AgentContext): Promise; handleOf(agentId: string): IAgentScopeHandle | undefined; adopt(handle: IAgentScopeHandle): AgentContext; } export const IAgentLifecycleService: ServiceIdentifier = createDecorator('agentLifecycleService');