fix(web): accept unknown stream payload when binding spoken prompts
Publish next build failed because the spoken-bind helper required result/output on chunk payload, which the runner stream type does not have. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -48,12 +48,15 @@ export function readOpenQuestionPrompt(value: unknown): string | null {
|
||||
|
||||
export function openQuestionPromptFromToolResult(chunk: {
|
||||
type?: string;
|
||||
payload?: { result?: unknown; output?: unknown };
|
||||
payload?: unknown;
|
||||
object?: unknown;
|
||||
}): string | null {
|
||||
if (chunk.type !== "tool-result") return null;
|
||||
return readOpenQuestionPrompt(chunk.payload?.result)
|
||||
?? readOpenQuestionPrompt(chunk.payload?.output)
|
||||
const payload = chunk.payload && typeof chunk.payload === "object" && !Array.isArray(chunk.payload)
|
||||
? chunk.payload as Record<string, unknown>
|
||||
: null;
|
||||
return readOpenQuestionPrompt(payload?.result)
|
||||
?? readOpenQuestionPrompt(payload?.output)
|
||||
?? readOpenQuestionPrompt(chunk.object)
|
||||
?? readOpenQuestionPrompt(chunk.payload);
|
||||
}
|
||||
|
||||
@@ -245,6 +245,11 @@ test("usage completes or releases without hiding settlement failures", () => {
|
||||
assert.match(run, /if \(!answerText\.trim\(\)\) \{[\s\S]*composeRectificationTurnNarration/);
|
||||
assert.match(run, /bindSpokenToOpenQuestion/);
|
||||
assert.match(run, /openQuestionPromptFromToolResult/);
|
||||
const narration = readFileSync(
|
||||
new URL("../src/lib/rectification-agentic/v9/turn-narration.ts", import.meta.url),
|
||||
"utf8",
|
||||
);
|
||||
assert.match(narration, /payload\?: unknown/);
|
||||
assert.doesNotMatch(run, /splitRectificationSpokenAndThinking/);
|
||||
assert.match(run, /emit\(event: PublicStreamEvent\): Promise<void> \| void;/);
|
||||
assert.match(run, /agentGenerationSettings\(options\.generationModel, \{[\s\S]*thinking: "enabled"/);
|
||||
|
||||
@@ -1371,7 +1371,7 @@ test("persisted choice prompt replaces a competing model follow-up without a top
|
||||
);
|
||||
assert.equal(openQuestionPromptFromToolResult({
|
||||
type: "tool-result",
|
||||
payload: { result: { open_question: { prompt } } },
|
||||
payload: { toolName: "rectification-record-evidence-batch", result: { open_question: { prompt } } },
|
||||
}), prompt);
|
||||
|
||||
const { options, emitted } = runOptions({
|
||||
|
||||
Reference in New Issue
Block a user