| 359 | } |
| 360 | |
| 361 | async function injectSessionPrompt( |
| 362 | client: OpenCodeClient, |
| 363 | sessionId: string | undefined, |
| 364 | text: string, |
| 365 | options?: { agent?: string; noReply?: boolean }, |
| 366 | ): Promise<void> { |
| 367 | if (!sessionId || !text.trim()) return; |
| 368 | try { |
| 369 | await client.session?.prompt?.({ |
| 370 | path: { id: sessionId }, |
| 371 | body: { |
| 372 | ...(options?.agent && { agent: options.agent }), |
| 373 | ...(options?.noReply && { noReply: true }), |
| 374 | parts: [{ type: "text", text }], |
| 375 | }, |
| 376 | }); |
| 377 | } catch { |
| 378 | // Session may be unavailable or busy. |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | export async function getRecentAssistantMessages( |
| 383 | client: OpenCodeClient, |