* Stateful-session companion to `submitAndWait` — POSTs `body` verbatim * (NO default controls injected), then waits for the terminal event for * the resulting `prompt_id`. Use after `updateSession(sid, {agent_config: * {...}})` to verify the session's shadow drives the next prompt without
(
sid: string,
body: PromptSubmission,
opts: SubmitAndWaitOptions = {},
)
| 637 | * the body needing to redeclare any controls. |
| 638 | */ |
| 639 | async submitAndWaitStateful( |
| 640 | sid: string, |
| 641 | body: PromptSubmission, |
| 642 | opts: SubmitAndWaitOptions = {}, |
| 643 | ): Promise<{ prompt_id: string; user_message_id: string; finalFrame: AnyFrame }> { |
| 644 | const ws = this._requireWs(); |
| 645 | const waitFor = opts.waitFor ?? 'prompt.completed'; |
| 646 | const timeoutMs = opts.timeoutMs ?? DEFAULT_FRAME_TIMEOUT_MS; |
| 647 | const submit = await this.http.submitPrompt(sid, body); |
| 648 | const finalFrame = await ws.waitForFrame((f) => { |
| 649 | if (f.type !== waitFor) return false; |
| 650 | const payload = (f.payload as { promptId?: string; prompt_id?: string } | undefined) ?? {}; |
| 651 | const pid = payload.promptId ?? payload.prompt_id; |
| 652 | return pid === submit.prompt_id; |
| 653 | }, timeoutMs); |
| 654 | return { prompt_id: submit.prompt_id, user_message_id: submit.user_message_id, finalFrame }; |
| 655 | } |
| 656 | |
| 657 | // ── internals ─────────────────────────────────────────────────────────── |
| 658 | private _requireWs(): WsClient { |
no test coverage detected