summaryrefslogtreecommitdiffhomepage
path: root/packages/sdk/js/src
diff options
context:
space:
mode:
authorDax <[email protected]>2026-01-07 22:29:42 -0500
committerGitHub <[email protected]>2026-01-07 22:29:42 -0500
commite37fd9c1056ad461577948d4e968daed1ece8398 (patch)
tree85999d77608fc44dd07fbc6e74c3b5af2333cc3a /packages/sdk/js/src
parent2e4fe973c966af45ea67c1d9ff8fd3b6251e960f (diff)
downloadopencode-e37fd9c1056ad461577948d4e968daed1ece8398.tar.gz
opencode-e37fd9c1056ad461577948d4e968daed1ece8398.zip
core: add interactive question tool for gathering user preferences and clarifying instructions (#7268)
Diffstat (limited to 'packages/sdk/js/src')
-rw-r--r--packages/sdk/js/src/v2/gen/sdk.gen.ts95
-rw-r--r--packages/sdk/js/src/v2/gen/types.gen.ts150
2 files changed, 245 insertions, 0 deletions
diff --git a/packages/sdk/js/src/v2/gen/sdk.gen.ts b/packages/sdk/js/src/v2/gen/sdk.gen.ts
index a26cefb17..dae865a7c 100644
--- a/packages/sdk/js/src/v2/gen/sdk.gen.ts
+++ b/packages/sdk/js/src/v2/gen/sdk.gen.ts
@@ -84,6 +84,11 @@ import type {
PtyRemoveResponses,
PtyUpdateErrors,
PtyUpdateResponses,
+ QuestionListResponses,
+ QuestionRejectErrors,
+ QuestionRejectResponses,
+ QuestionReplyErrors,
+ QuestionReplyResponses,
SessionAbortErrors,
SessionAbortResponses,
SessionChildrenErrors,
@@ -1781,6 +1786,94 @@ export class Permission extends HeyApiClient {
}
}
+export class Question extends HeyApiClient {
+ /**
+ * List pending questions
+ *
+ * Get all pending question requests across all sessions.
+ */
+ public list<ThrowOnError extends boolean = false>(
+ parameters?: {
+ directory?: string
+ },
+ options?: Options<never, ThrowOnError>,
+ ) {
+ const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "directory" }] }])
+ return (options?.client ?? this.client).get<QuestionListResponses, unknown, ThrowOnError>({
+ url: "/question",
+ ...options,
+ ...params,
+ })
+ }
+
+ /**
+ * Reply to question request
+ *
+ * Provide answers to a question request from the AI assistant.
+ */
+ public reply<ThrowOnError extends boolean = false>(
+ parameters: {
+ requestID: string
+ directory?: string
+ answers?: Array<string>
+ },
+ options?: Options<never, ThrowOnError>,
+ ) {
+ const params = buildClientParams(
+ [parameters],
+ [
+ {
+ args: [
+ { in: "path", key: "requestID" },
+ { in: "query", key: "directory" },
+ { in: "body", key: "answers" },
+ ],
+ },
+ ],
+ )
+ return (options?.client ?? this.client).post<QuestionReplyResponses, QuestionReplyErrors, ThrowOnError>({
+ url: "/question/{requestID}/reply",
+ ...options,
+ ...params,
+ headers: {
+ "Content-Type": "application/json",
+ ...options?.headers,
+ ...params.headers,
+ },
+ })
+ }
+
+ /**
+ * Reject question request
+ *
+ * Reject a question request from the AI assistant.
+ */
+ public reject<ThrowOnError extends boolean = false>(
+ parameters: {
+ requestID: string
+ directory?: string
+ },
+ options?: Options<never, ThrowOnError>,
+ ) {
+ const params = buildClientParams(
+ [parameters],
+ [
+ {
+ args: [
+ { in: "path", key: "requestID" },
+ { in: "query", key: "directory" },
+ ],
+ },
+ ],
+ )
+ return (options?.client ?? this.client).post<QuestionRejectResponses, QuestionRejectErrors, ThrowOnError>({
+ url: "/question/{requestID}/reject",
+ ...options,
+ ...params,
+ })
+ }
+}
+
export class Command extends HeyApiClient {
/**
* List commands
@@ -2912,6 +3005,8 @@ export class OpencodeClient extends HeyApiClient {
permission = new Permission({ client: this.client })
+ question = new Question({ client: this.client })
+
command = new Command({ client: this.client })
provider = new Provider({ client: this.client })
diff --git a/packages/sdk/js/src/v2/gen/types.gen.ts b/packages/sdk/js/src/v2/gen/types.gen.ts
index 97a695162..d42e7d176 100644
--- a/packages/sdk/js/src/v2/gen/types.gen.ts
+++ b/packages/sdk/js/src/v2/gen/types.gen.ts
@@ -524,6 +524,67 @@ export type EventSessionCompacted = {
}
}
+export type QuestionOption = {
+ /**
+ * Display text (1-5 words, concise)
+ */
+ label: string
+ /**
+ * Explanation of choice
+ */
+ description: string
+}
+
+export type QuestionInfo = {
+ /**
+ * Complete question
+ */
+ question: string
+ /**
+ * Very short label (max 12 chars)
+ */
+ header: string
+ /**
+ * Available choices
+ */
+ options: Array<QuestionOption>
+}
+
+export type QuestionRequest = {
+ id: string
+ sessionID: string
+ /**
+ * Questions to ask
+ */
+ questions: Array<QuestionInfo>
+ tool?: {
+ messageID: string
+ callID: string
+ }
+}
+
+export type EventQuestionAsked = {
+ type: "question.asked"
+ properties: QuestionRequest
+}
+
+export type EventQuestionReplied = {
+ type: "question.replied"
+ properties: {
+ sessionID: string
+ requestID: string
+ answers: Array<string>
+ }
+}
+
+export type EventQuestionRejected = {
+ type: "question.rejected"
+ properties: {
+ sessionID: string
+ requestID: string
+ }
+}
+
export type EventFileEdited = {
type: "file.edited"
properties: {
@@ -789,6 +850,9 @@ export type Event =
| EventSessionStatus
| EventSessionIdle
| EventSessionCompacted
+ | EventQuestionAsked
+ | EventQuestionReplied
+ | EventQuestionRejected
| EventFileEdited
| EventTodoUpdated
| EventTuiPromptAppend
@@ -3545,6 +3609,92 @@ export type PermissionListResponses = {
export type PermissionListResponse = PermissionListResponses[keyof PermissionListResponses]
+export type QuestionListData = {
+ body?: never
+ path?: never
+ query?: {
+ directory?: string
+ }
+ url: "/question"
+}
+
+export type QuestionListResponses = {
+ /**
+ * List of pending questions
+ */
+ 200: Array<QuestionRequest>
+}
+
+export type QuestionListResponse = QuestionListResponses[keyof QuestionListResponses]
+
+export type QuestionReplyData = {
+ body?: {
+ answers: Array<string>
+ }
+ path: {
+ requestID: string
+ }
+ query?: {
+ directory?: string
+ }
+ url: "/question/{requestID}/reply"
+}
+
+export type QuestionReplyErrors = {
+ /**
+ * Bad request
+ */
+ 400: BadRequestError
+ /**
+ * Not found
+ */
+ 404: NotFoundError
+}
+
+export type QuestionReplyError = QuestionReplyErrors[keyof QuestionReplyErrors]
+
+export type QuestionReplyResponses = {
+ /**
+ * Question answered successfully
+ */
+ 200: boolean
+}
+
+export type QuestionReplyResponse = QuestionReplyResponses[keyof QuestionReplyResponses]
+
+export type QuestionRejectData = {
+ body?: never
+ path: {
+ requestID: string
+ }
+ query?: {
+ directory?: string
+ }
+ url: "/question/{requestID}/reject"
+}
+
+export type QuestionRejectErrors = {
+ /**
+ * Bad request
+ */
+ 400: BadRequestError
+ /**
+ * Not found
+ */
+ 404: NotFoundError
+}
+
+export type QuestionRejectError = QuestionRejectErrors[keyof QuestionRejectErrors]
+
+export type QuestionRejectResponses = {
+ /**
+ * Question rejected successfully
+ */
+ 200: boolean
+}
+
+export type QuestionRejectResponse = QuestionRejectResponses[keyof QuestionRejectResponses]
+
export type CommandListData = {
body?: never
path?: never