Skip to content

Commit 3cf7c75

Browse files
authored
fix(question): restore flat reply sdk shape (#22487)
1 parent 85674f4 commit 3cf7c75

4 files changed

Lines changed: 23 additions & 14 deletions

File tree

packages/opencode/src/server/instance/httpapi/question.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import { HttpApi, HttpApiBuilder, HttpApiEndpoint, HttpApiGroup, OpenApi } from
99
import type { Handler } from "hono"
1010

1111
const root = "/experimental/httpapi/question"
12+
const Reply = Schema.Struct({
13+
answers: Schema.Array(Question.Answer).annotate({
14+
description: "User answers in order of questions (each answer is an array of selected labels)",
15+
}),
16+
})
1217

1318
const Api = HttpApi.make("question")
1419
.add(
@@ -25,7 +30,7 @@ const Api = HttpApi.make("question")
2530
),
2631
HttpApiEndpoint.post("reply", `${root}/:requestID/reply`, {
2732
params: { requestID: QuestionID },
28-
payload: Question.Reply,
33+
payload: Reply,
2934
success: Schema.Boolean,
3035
}).annotateMerge(
3136
OpenApi.annotations({
@@ -62,7 +67,7 @@ const QuestionLive = HttpApiBuilder.group(
6267

6368
const reply = Effect.fn("QuestionHttpApi.reply")(function* (ctx: {
6469
params: { requestID: QuestionID }
65-
payload: Question.Reply
70+
payload: Schema.Schema.Type<typeof Reply>
6671
}) {
6772
yield* svc.reply({
6873
requestID: ctx.params.requestID,

packages/opencode/src/server/instance/question.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import z from "zod"
88
import { errors } from "../error"
99
import { lazy } from "../../util/lazy"
1010

11+
const Reply = z.object({
12+
answers: Question.Answer.zod
13+
.array()
14+
.describe("User answers in order of questions (each answer is an array of selected labels)"),
15+
})
16+
1117
export const QuestionRoutes = lazy(() =>
1218
new Hono()
1319
.get(
@@ -56,7 +62,7 @@ export const QuestionRoutes = lazy(() =>
5662
requestID: QuestionID.zod,
5763
}),
5864
),
59-
validator("json", Question.Reply.zod),
65+
validator("json", Reply),
6066
async (c) => {
6167
const params = c.req.valid("param")
6268
const json = c.req.valid("json")

packages/sdk/js/src/v2/gen/sdk.gen.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ import type {
105105
PtyRemoveResponses,
106106
PtyUpdateErrors,
107107
PtyUpdateResponses,
108+
QuestionAnswer,
108109
QuestionListResponses,
109110
QuestionRejectErrors,
110111
QuestionRejectResponses,
111-
QuestionReply,
112112
QuestionReplyErrors,
113113
QuestionReplyResponses,
114114
SessionAbortErrors,
@@ -2738,7 +2738,7 @@ export class Question extends HeyApiClient {
27382738
requestID: string
27392739
directory?: string
27402740
workspace?: string
2741-
questionReply?: QuestionReply
2741+
answers?: Array<QuestionAnswer>
27422742
},
27432743
options?: Options<never, ThrowOnError>,
27442744
) {
@@ -2750,7 +2750,7 @@ export class Question extends HeyApiClient {
27502750
{ in: "path", key: "requestID" },
27512751
{ in: "query", key: "directory" },
27522752
{ in: "query", key: "workspace" },
2753-
{ key: "questionReply", map: "body" },
2753+
{ in: "body", key: "answers" },
27542754
],
27552755
},
27562756
],

packages/sdk/js/src/v2/gen/types.gen.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,13 +1925,6 @@ export type SubtaskPartInput = {
19251925
command?: string
19261926
}
19271927

1928-
export type QuestionReply = {
1929-
/**
1930-
* User answers in order of questions (each answer is an array of selected labels)
1931-
*/
1932-
answers: Array<QuestionAnswer>
1933-
}
1934-
19351928
export type ProviderAuthMethod = {
19361929
type: "oauth" | "api"
19371930
label: string
@@ -4259,7 +4252,12 @@ export type QuestionListResponses = {
42594252
export type QuestionListResponse = QuestionListResponses[keyof QuestionListResponses]
42604253

42614254
export type QuestionReplyData = {
4262-
body?: QuestionReply
4255+
body?: {
4256+
/**
4257+
* User answers in order of questions (each answer is an array of selected labels)
4258+
*/
4259+
answers: Array<QuestionAnswer>
4260+
}
42634261
path: {
42644262
requestID: string
42654263
}

0 commit comments

Comments
 (0)