MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / submitAndWaitStateful

Method submitAndWaitStateful

packages/server-e2e/src/client.ts:639–655  ·  view source on GitHub ↗

* 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 = {},
  )

Source from the content-addressed store, hash-verified

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 {

Callers 1

mainFunction · 0.95

Calls 3

_requireWsMethod · 0.95
submitPromptMethod · 0.65
waitForFrameMethod · 0.45

Tested by

no test coverage detected