diff options
| author | Kyle Mistele <[email protected]> | 2026-02-11 20:54:05 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-02-12 04:54:05 +0000 |
| commit | e269788a8feb987a579b8700726dd8b02bf2e7f1 (patch) | |
| tree | c143523b2d8d84806986a441ef7d13dd87fd3f26 /packages/sdk/js | |
| parent | 66780195dc9ea5c79a4015f17771f53c19b37dcb (diff) | |
| download | opencode-e269788a8feb987a579b8700726dd8b02bf2e7f1.tar.gz opencode-e269788a8feb987a579b8700726dd8b02bf2e7f1.zip | |
feat: support claude agent SDK-style structured outputs in the OpenCode SDK (#8161)
Co-authored-by: Claude Opus 4.5 <[email protected]>
Co-authored-by: Dax Raad <[email protected]>
Diffstat (limited to 'packages/sdk/js')
| -rw-r--r-- | packages/sdk/js/src/v2/gen/sdk.gen.ts | 5 | ||||
| -rw-r--r-- | packages/sdk/js/src/v2/gen/types.gen.ts | 30 |
2 files changed, 35 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 b757b7535..af79c44a1 100644 --- a/packages/sdk/js/src/v2/gen/sdk.gen.ts +++ b/packages/sdk/js/src/v2/gen/sdk.gen.ts @@ -57,6 +57,7 @@ import type { McpLocalConfig, McpRemoteConfig, McpStatusResponses, + OutputFormat, Part as Part2, PartDeleteErrors, PartDeleteResponses, @@ -1473,6 +1474,7 @@ export class Session extends HeyApiClient { tools?: { [key: string]: boolean } + format?: OutputFormat system?: string variant?: string parts?: Array<TextPartInput | FilePartInput | AgentPartInput | SubtaskPartInput> @@ -1491,6 +1493,7 @@ export class Session extends HeyApiClient { { in: "body", key: "agent" }, { in: "body", key: "noReply" }, { in: "body", key: "tools" }, + { in: "body", key: "format" }, { in: "body", key: "system" }, { in: "body", key: "variant" }, { in: "body", key: "parts" }, @@ -1561,6 +1564,7 @@ export class Session extends HeyApiClient { tools?: { [key: string]: boolean } + format?: OutputFormat system?: string variant?: string parts?: Array<TextPartInput | FilePartInput | AgentPartInput | SubtaskPartInput> @@ -1579,6 +1583,7 @@ export class Session extends HeyApiClient { { in: "body", key: "agent" }, { in: "body", key: "noReply" }, { in: "body", key: "tools" }, + { in: "body", key: "format" }, { in: "body", key: "system" }, { in: "body", key: "variant" }, { in: "body", key: "parts" }, diff --git a/packages/sdk/js/src/v2/gen/types.gen.ts b/packages/sdk/js/src/v2/gen/types.gen.ts index 985d550a3..26a3bd20e 100644 --- a/packages/sdk/js/src/v2/gen/types.gen.ts +++ b/packages/sdk/js/src/v2/gen/types.gen.ts @@ -90,6 +90,22 @@ export type EventFileEdited = { } } +export type OutputFormatText = { + type: "text" +} + +export type JsonSchema = { + [key: string]: unknown +} + +export type OutputFormatJsonSchema = { + type: "json_schema" + schema: JsonSchema + retryCount?: number +} + +export type OutputFormat = OutputFormatText | OutputFormatJsonSchema + export type FileDiff = { file: string before: string @@ -106,6 +122,7 @@ export type UserMessage = { time: { created: number } + format?: OutputFormat summary?: { title?: string body?: string @@ -152,6 +169,14 @@ export type MessageAbortedError = { } } +export type StructuredOutputError = { + name: "StructuredOutputError" + data: { + message: string + retries: number + } +} + export type ContextOverflowError = { name: "ContextOverflowError" data: { @@ -189,6 +214,7 @@ export type AssistantMessage = { | UnknownError | MessageOutputLengthError | MessageAbortedError + | StructuredOutputError | ContextOverflowError | ApiError parentID: string @@ -212,6 +238,7 @@ export type AssistantMessage = { write: number } } + structured?: unknown variant?: string finish?: string } @@ -841,6 +868,7 @@ export type EventSessionError = { | UnknownError | MessageOutputLengthError | MessageAbortedError + | StructuredOutputError | ContextOverflowError | ApiError } @@ -3403,6 +3431,7 @@ export type SessionPromptData = { tools?: { [key: string]: boolean } + format?: OutputFormat system?: string variant?: string parts: Array<TextPartInput | FilePartInput | AgentPartInput | SubtaskPartInput> @@ -3590,6 +3619,7 @@ export type SessionPromptAsyncData = { tools?: { [key: string]: boolean } + format?: OutputFormat system?: string variant?: string parts: Array<TextPartInput | FilePartInput | AgentPartInput | SubtaskPartInput> |
