feat: support claude agent SDK-style structured outputs in the OpenCode SDK (#8161)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Dax Raad <d@ironbay.co>
This commit is contained in:
@@ -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" },
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user