| 49 | type AgentScopedPayload<T> = T & { agentId: string }; |
| 50 | |
| 51 | export class SessionAPIImpl implements PromisableMethods<SessionAPI> { |
| 52 | constructor(protected readonly session: Session) {} |
| 53 | |
| 54 | async renameSession(payload: RenameSessionPayload): Promise<void> { |
| 55 | const title = payload.title.trim(); |
| 56 | if (title.length === 0) { |
| 57 | throw new KimiError(ErrorCodes.SESSION_TITLE_EMPTY, 'Session title cannot be empty'); |
| 58 | } |
| 59 | this.session.metadata = { |
| 60 | ...this.session.metadata, |
| 61 | title, |
| 62 | isCustomTitle: true, |
| 63 | updatedAt: new Date().toISOString(), |
| 64 | }; |
| 65 | await this.session.writeMetadata(); |
| 66 | } |
| 67 | |
| 68 | async updateSessionMetadata(payload: UpdateSessionMetadataPayload): Promise<void> { |
| 69 | this.session.metadata = { |
| 70 | ...this.session.metadata, |
| 71 | ...payload.metadata, |
| 72 | agents: this.session.metadata.agents, |
| 73 | }; |
| 74 | await this.session.writeMetadata(); |
| 75 | } |
| 76 | |
| 77 | getSessionMetadata(_payload: EmptyPayload): SessionMeta { |
| 78 | return this.session.metadata; |
| 79 | } |
| 80 | |
| 81 | listSkills(_payload: EmptyPayload): Promise<readonly SkillSummary[]> { |
| 82 | return this.session.listSkills(); |
| 83 | } |
| 84 | |
| 85 | listPluginCommands(_payload: EmptyPayload): readonly PluginCommandDef[] { |
| 86 | return this.session.listPluginCommands(); |
| 87 | } |
| 88 | |
| 89 | listMcpServers(_payload: EmptyPayload): readonly McpServerInfo[] { |
| 90 | return this.session.mcp.list(); |
| 91 | } |
| 92 | |
| 93 | async getMcpStartupMetrics(_payload: EmptyPayload): Promise<McpStartupMetrics> { |
| 94 | await this.session.mcp.waitForInitialLoad(); |
| 95 | return { durationMs: this.session.mcp.initialLoadDurationMs() }; |
| 96 | } |
| 97 | |
| 98 | async reconnectMcpServer(payload: ReconnectMcpServerPayload): Promise<void> { |
| 99 | await this.session.mcp.reconnect(payload.name); |
| 100 | } |
| 101 | |
| 102 | generateAgentsMd(_payload: EmptyPayload): Promise<void> { |
| 103 | return this.session.generateAgentsMd(); |
| 104 | } |
| 105 | |
| 106 | getSessionWarnings(_payload: EmptyPayload): Promise<readonly SessionWarning[]> { |
| 107 | return this.session.getSessionWarnings(); |
| 108 | } |
nothing calls this directly
no outgoing calls
no test coverage detected