()
| 298 | } |
| 299 | |
| 300 | async resume(): Promise<{ warning?: string }> { |
| 301 | await this.skillsReady; |
| 302 | this.log.info('session resume', { app_version: this.options.appVersion }); |
| 303 | const { agents } = await this.readMetadata(); |
| 304 | this.agents.clear(); |
| 305 | // Only the main agent is needed to reopen the session; subagents replay |
| 306 | // lazily when an RPC or Agent(resume=...) call asks for their state. |
| 307 | const { warning } = |
| 308 | agents['main'] === undefined ? { warning: undefined } : await this.resumeAgent('main'); |
| 309 | // A session migrated from an external tool ships a wire without the |
| 310 | // `config.update` bootstrap events a natively-created agent writes, so the |
| 311 | // main agent comes back with an empty system prompt and no tools. Apply the |
| 312 | // default profile so the resumed session is usable. Native sessions always |
| 313 | // replay a non-empty system prompt and never enter this branch. |
| 314 | const main = this.getReadyAgent('main'); |
| 315 | const profile = DEFAULT_AGENT_PROFILES['agent']; |
| 316 | if (main !== undefined && profile !== undefined && main.config.systemPrompt === '') { |
| 317 | await this.bootstrapAgentProfile(main, profile); |
| 318 | } |
| 319 | await this.triggerSessionStart('resume'); |
| 320 | return { warning }; |
| 321 | } |
| 322 | |
| 323 | async close(): Promise<void> { |
| 324 | try { |
no test coverage detected