(
id: string,
stack: readonly string[] = [],
)
| 887 | } |
| 888 | |
| 889 | private async resumePersistedAgent( |
| 890 | id: string, |
| 891 | stack: readonly string[] = [], |
| 892 | ): Promise<ResumedAgent> { |
| 893 | await this.skillsReady; |
| 894 | const meta = this.metadata.agents[id]; |
| 895 | if (meta === undefined) { |
| 896 | throw new KimiError(ErrorCodes.SESSION_STATE_INVALID, `Session agent "${id}" is missing`); |
| 897 | } |
| 898 | |
| 899 | const parentAgentId = meta.parentAgentId ?? null; |
| 900 | const parent = |
| 901 | parentAgentId === null |
| 902 | ? undefined |
| 903 | : await this.resumeAgent(parentAgentId, [...stack, id]); |
| 904 | |
| 905 | try { |
| 906 | const agent = this.instantiateAgent(id, meta.homedir, meta.type, {}, parentAgentId); |
| 907 | const result = await agent.resume(); |
| 908 | this.restoreAgentProfileHandle(agent, meta, parent?.agent); |
| 909 | this.agents.set(id, agent); |
| 910 | return { agent, warning: parent?.warning ?? result.warning }; |
| 911 | } catch (error) { |
| 912 | const entry = this.agents.get(id); |
| 913 | if (entry instanceof Promise) { |
| 914 | this.agents.delete(id); |
| 915 | } |
| 916 | throw error; |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | private restoreAgentProfileHandle( |
| 921 | agent: Agent, |
no test coverage detected