The open source coding agent.
TypeScript
rework types
Dax Raad33a831d2be1f
diff --git a/js/src/app/config.ts b/js/src/app/config.tsindex 1f149154089..348eb77c39b 100644--- a/js/src/app/config.ts+++ b/js/src/app/config.ts@@ -1,11 +1,16 @@import path from "path";import { Log } from "../util/log";import { z } from "zod";-import { LLM } from "../llm/llm";+import { App } from ".";export namespace Config {const log = Log.create({ service: "config" });+ export const state = App.state("config", async (app) => {+ const result = await load(app.root);+ return result;+ });+export const Model = z.object({name: z.string().optional(),cost: z.object({@@ -35,7 +40,11 @@ export namespace Config {export type Info = z.output<typeof Info>;- export async function load(directory: string) {+ export function get() {+ return state();+ }++ async function load(directory: string) {let result: Info = {};for (const file of ["opencode.jsonc", "opencode.json"]) {const resolved = path.join(directory, file);diff --git a/js/src/app/index.ts b/js/src/app/index.tsindex f0d371a34f5..0c6260bc718 100644--- a/js/src/app/index.ts+++ b/js/src/app/index.ts@@ -2,7 +2,6 @@ import fs from "fs/promises";import { AppPath } from "./path";import { Log } from "../util/log";import { Context } from "../util/context";-import { Config } from "./config";export namespace App {const log = Log.create({ service: "app" });@@ -16,10 +15,6 @@ export namespace App {await fs.mkdir(dataDir, { recursive: true });await Log.file(input.directory);- log.info("creating");-- const config = await Config.load(input.directory);-log.info("created", { path: dataDir });const services = new Map<@@ -34,9 +29,6 @@ export namespace App {get services() {return services;},- get config() {- return config;- },get root() {return input.directory;},diff --git a/js/src/bus/index.ts b/js/src/bus/index.tsindex 15d2b110713..82bc614e042 100644--- a/js/src/bus/index.ts+++ b/js/src/bus/index.ts@@ -30,6 +30,17 @@ export namespace Bus {return result;}+ export function payloads() {+ return registry+ .entries()+ .map(([type, def]) =>+ z.object({+ type: z.string("hey"),+ }),+ )+ .toArray();+ }+export function specs() {const children = {} as any;for (const [type, def] of registry.entries()) {diff --git a/js/src/index.ts b/js/src/index.tsindex 9ba9535a1e6..d5b388166c9 100644--- a/js/src/index.ts+++ b/js/src/index.ts@@ -15,6 +15,13 @@ cli.command("", "Start the opencode in interactive mode").action(async () => {await App.provide({ directory: process.cwd() }, async () => {await Share.init();Server.listen();++ Bun.spawnSync({+ stderr: "inherit",+ stdout: "inherit",+ stdin: "inherit",+ cmd: ["go", "run", "cmd/main.go"],+ });});});diff --git a/js/src/llm/llm.ts b/js/src/llm/llm.tsindex 9c409c60492..e6230584a2c 100644--- a/js/src/llm/llm.ts+++ b/js/src/llm/llm.ts@@ -5,7 +5,7 @@ import path from "path";import type { LanguageModel, Provider } from "ai";import { NoSuchModelError } from "ai";-import type { Config } from "../app/config";+import { Config } from "../app/config";import { BunProc } from "../bun";import { Global } from "../global";@@ -25,8 +25,8 @@ export namespace LLM {name: "Claude 4 Sonnet",cost: {input: 3.0 / 1_000_000,- inputCached: 3.75 / 1_000_000,output: 15.0 / 1_000_000,+ inputCached: 3.75 / 1_000_000,outputCached: 0.3 / 1_000_000,},contextWindow: 200000,@@ -77,6 +77,7 @@ export namespace LLM {};const state = App.state("llm", async (app) => {+ const config = await Config.get();const providers: Record<string,{@@ -89,11 +90,11 @@ export namespace LLM {{ info: Config.Model; instance: LanguageModel }>();- const list = mergeDeep(NATIVE_PROVIDERS, app.config.providers ?? {});+ const list = mergeDeep(NATIVE_PROVIDERS, config.providers ?? {});for (const [providerID, providerInfo] of Object.entries(list)) {if (- !app.config.providers?.[providerID] &&+ !config.providers?.[providerID] &&!AUTODETECT[providerID]?.some((env) => process.env[env]))continue;diff --git a/js/src/server/message.ts b/js/src/server/message.tsdeleted file mode 100644index 4ad301a358f..00000000000--- a/js/src/server/message.ts+++ /dev/null@@ -1,135 +0,0 @@-import z from "zod";--const ToolCall = z- .object({- state: z.literal("call"),- step: z.number().optional(),- toolCallId: z.string(),- toolName: z.string(),- args: z.record(z.string(), z.any()),- })- .openapi({- ref: "Session.Message.ToolInvocation.ToolCall",- });--const ToolPartialCall = z- .object({- state: z.literal("partial-call"),- step: z.number().optional(),- toolCallId: z.string(),- toolName: z.string(),- args: z.record(z.string(), z.any()),- })- .openapi({- ref: "Session.Message.ToolInvocation.ToolPartialCall",- });--const ToolResult = z- .object({- state: z.literal("result"),- step: z.number().optional(),- toolCallId: z.string(),- toolName: z.string(),- args: z.record(z.string(), z.any()),- result: z.string(),- })- .openapi({- ref: "Session.Message.ToolInvocation.ToolResult",- });--const ToolInvocation = z- .discriminatedUnion("state", [ToolCall, ToolPartialCall, ToolResult])- .openapi({- ref: "Session.Message.ToolInvocation",- });-export type ToolInvocation = z.infer<typeof ToolInvocation>;--const TextPart = z- .object({- type: z.literal("text"),- text: z.string(),- })- .openapi({- ref: "Session.Message.Part.Text",- });--const ReasoningPart = z- .object({- type: z.literal("reasoning"),- text: z.string(),- providerMetadata: z.record(z.any()).optional(),- })- .openapi({- ref: "Session.Message.Part.Reasoning",- });--const ToolInvocationPart = z- .object({- type: z.literal("tool-invocation"),- toolInvocation: ToolInvocation,- })- .openapi({- ref: "Session.Message.Part.ToolInvocation",- });--const SourceUrlPart = z- .object({- type: z.literal("source-url"),- sourceId: z.string(),- url: z.string(),- title: z.string().optional(),- providerMetadata: z.record(z.any()).optional(),- })- .openapi({- ref: "Session.Message.Part.SourceUrl",- });--const FilePart = z- .object({- type: z.literal("file"),- mediaType: z.string(),- filename: z.string().optional(),- url: z.string(),- })- .openapi({- ref: "Session.Message.Part.File",- });--const StepStartPart = z- .object({- type: z.literal("step-start"),- })- .openapi({- ref: "Session.Message.Part.StepStart",- });--const Part = z- .discriminatedUnion("type", [- TextPart,- ReasoningPart,- ToolInvocationPart,- SourceUrlPart,- FilePart,- StepStartPart,- ])- .openapi({- ref: "Session.Message.Part",- });--export const SessionMessage = z- .object({- id: z.string(),- role: z.enum(["system", "user", "assistant"]),- parts: z.array(Part),- metadata: z.object({- time: z.object({- created: z.number(),- completed: z.number().optional(),- }),- sessionID: z.string(),- tool: z.record(z.string(), z.any()),- }),- })- .openapi({- ref: "Session.Message",- });diff --git a/js/src/server/server.ts b/js/src/server/server.tsindex 5fb0dfe62ce..2f388a183a2 100644--- a/js/src/server/server.ts+++ b/js/src/server/server.ts@@ -9,7 +9,7 @@ import { z } from "zod";import "zod-openapi/extend";import { Config } from "../app/config";import { LLM } from "../llm/llm";-import { SessionMessage } from "./message";+import { Message } from "../session/message";const SessionInfo = Session.Info.openapi({ref: "Session.Info",@@ -40,6 +40,7 @@ export namespace Server {version: "1.0.0",description: "opencode api",},+ openapi: "3.0.0",},}),)@@ -120,7 +121,7 @@ export namespace Server {description: "Successfully created session",content: {"application/json": {- schema: resolver(SessionMessage.array()),+ schema: resolver(Message.Info.array()),},},},@@ -194,7 +195,7 @@ export namespace Server {description: "Chat with a model",content: {"application/json": {- schema: resolver(SessionMessage),+ schema: resolver(Message.Info),},},},@@ -206,7 +207,7 @@ export namespace Server {sessionID: z.string(),providerID: z.string(),modelID: z.string(),- parts: SessionMessage.shape.parts,+ parts: Message.Part.array(),}),),async (c) => {@@ -252,6 +253,7 @@ export namespace Server {version: "1.0.0",description: "opencode api",},+ openapi: "3.0.0",},});return result;diff --git a/js/src/session/message.ts b/js/src/session/message.tsnew file mode 100644index 00000000000..75c22ef0b60--- /dev/null+++ b/js/src/session/message.ts@@ -0,0 +1,160 @@+import z from "zod";++export namespace Message {+ export const ToolCall = z+ .object({+ state: z.literal("call"),+ step: z.number().optional(),+ toolCallId: z.string(),+ toolName: z.string(),+ args: z.custom<Required<unknown>>(),+ })+ .openapi({+ ref: "Message.ToolInvocation.ToolCall",+ });+ export type ToolCall = z.infer<typeof ToolCall>;++ export const ToolPartialCall = z+ .object({+ state: z.literal("partial-call"),+ step: z.number().optional(),+ toolCallId: z.string(),+ toolName: z.string(),+ args: z.custom<Required<unknown>>(),+ })+ .openapi({+ ref: "Message.ToolInvocation.ToolPartialCall",+ });+ export type ToolPartialCall = z.infer<typeof ToolPartialCall>;++ export const ToolResult = z+ .object({+ state: z.literal("result"),+ step: z.number().optional(),+ toolCallId: z.string(),+ toolName: z.string(),+ args: z.custom<Required<unknown>>(),+ result: z.string(),+ })+ .openapi({+ ref: "Message.ToolInvocation.ToolResult",+ });+ export type ToolResult = z.infer<typeof ToolResult>;++ export const ToolInvocation = z+ .discriminatedUnion("state", [ToolCall, ToolPartialCall, ToolResult])+ .openapi({+ ref: "Message.ToolInvocation",+ });+ export type ToolInvocation = z.infer<typeof ToolInvocation>;++ export const TextPart = z+ .object({+ type: z.literal("text"),+ text: z.string(),+ })+ .openapi({+ ref: "Message.Part.Text",+ });+ export type TextPart = z.infer<typeof TextPart>;++ export const ReasoningPart = z+ .object({+ type: z.literal("reasoning"),+ text: z.string(),+ providerMetadata: z.record(z.any()).optional(),+ })+ .openapi({+ ref: "Message.Part.Reasoning",+ });+ export type ReasoningPart = z.infer<typeof ReasoningPart>;++ export const ToolInvocationPart = z+ .object({+ type: z.literal("tool-invocation"),+ toolInvocation: ToolInvocation,+ })+ .openapi({+ ref: "Message.Part.ToolInvocation",+ });+ export type ToolInvocationPart = z.infer<typeof ToolInvocationPart>;++ export const SourceUrlPart = z+ .object({+ type: z.literal("source-url"),+ sourceId: z.string(),+ url: z.string(),+ title: z.string().optional(),+ providerMetadata: z.record(z.any()).optional(),+ })+ .openapi({+ ref: "Message.Part.SourceUrl",+ });+ export type SourceUrlPart = z.infer<typeof SourceUrlPart>;++ export const FilePart = z+ .object({+ type: z.literal("file"),+ mediaType: z.string(),+ filename: z.string().optional(),+ url: z.string(),+ })+ .openapi({+ ref: "Message.Part.File",+ });+ export type FilePart = z.infer<typeof FilePart>;++ export const StepStartPart = z+ .object({+ type: z.literal("step-start"),+ })+ .openapi({+ ref: "Message.Part.StepStart",+ });+ export type StepStartPart = z.infer<typeof StepStartPart>;++ export const Part = z+ .discriminatedUnion("type", [+ TextPart,+ ReasoningPart,+ ToolInvocationPart,+ SourceUrlPart,+ FilePart,+ StepStartPart,+ ])+ .openapi({+ ref: "Message.Part",+ });+ export type Part = z.infer<typeof Part>;++ export const Info = z+ .object({+ id: z.string(),+ role: z.enum(["system", "user", "assistant"]),+ parts: z.array(Part),+ metadata: z.object({+ time: z.object({+ created: z.number(),+ completed: z.number().optional(),+ }),+ sessionID: z.string(),+ tool: z.record(z.string(), z.any()),+ assistant: z+ .object({+ modelID: z.string(),+ providerID: z.string(),+ cost: z.number(),+ tokens: z.object({+ input: z.number(),+ output: z.number(),+ reasoning: z.number(),+ }),+ })+ .optional(),+ }),+ })+ .openapi({+ ref: "Message.Info",+ });+ export type Info = z.infer<typeof Info>;+}diff --git a/js/src/session/session.ts b/js/src/session/session.tsindex 110315619ca..abeb29842f5 100644--- a/js/src/session/session.ts+++ b/js/src/session/session.ts@@ -9,11 +9,6 @@ import {generateText,stepCountIs,streamText,- type TextUIPart,- type ToolInvocationUIPart,- type UIDataTypes,- type UIMessage,- type UIMessagePart,} from "ai";import { z } from "zod";import * as tools from "../tool";@@ -22,8 +17,8 @@ import { Decimal } from "decimal.js";import PROMPT_ANTHROPIC from "./prompt/anthropic.txt";import PROMPT_TITLE from "./prompt/title.txt";-import type { Tool } from "../tool/tool";import { Share } from "../share/share";+import type { Message } from "./message";export namespace Session {const log = Log.create({ service: "session" });@@ -35,28 +30,9 @@ export namespace Session {});export type Info = z.output<typeof Info>;- export type Message = UIMessage<{- assistant?: {- modelID: string;- providerID: string;- cost: number;- tokens: {- input: number;- output: number;- reasoning: number;- };- };- time: {- created: number;- completed?: number;- };- sessionID: string;- tool: Record<string, Tool.Metadata>;- }>;-const state = App.state("session", () => {const sessions = new Map<string, Info>();- const messages = new Map<string, Message[]>();+ const messages = new Map<string, Message.Info[]>();return {sessions,@@ -112,10 +88,10 @@ export namespace Session {if (match) {return match;}- const result = [] as Message[];+ const result = [] as Message.Info[];const list = Storage.list("session/message/" + sessionID);for await (const p of list) {- const read = await Storage.readJSON<Message>(p);+ const read = await Storage.readJSON<Message.Info>(p);result.push(read);}state().messages.set(sessionID, result);@@ -143,13 +119,13 @@ export namespace Session {sessionID: string;providerID: string;modelID: string;- parts: UIMessagePart<UIDataTypes>[];+ parts: Message.Part[];}) {const l = log.clone().tag("session", input.sessionID);l.info("chatting");const model = await LLM.findModel(input.providerID, input.modelID);const msgs = await messages(input.sessionID);- async function write(msg: Message) {+ async function write(msg: Message.Info) {return Storage.writeJSON("session/message/" + input.sessionID + "/" + msg.id,msg,@@ -157,7 +133,7 @@ export namespace Session {}const app = await App.use();if (msgs.length === 0) {- const system: Message = {+ const system: Message.Info = {id: Identifier.ascending("message"),role: "system",parts: [@@ -208,7 +184,7 @@ export namespace Session {});await write(system);}- const msg: Message = {+ const msg: Message.Info = {role: "user",id: Identifier.ascending("message"),parts: input.parts,@@ -223,7 +199,7 @@ export namespace Session {msgs.push(msg);await write(msg);- const next: Message = {+ const next: Message.Info = {id: Identifier.ascending("message"),role: "assistant",parts: [],@@ -269,7 +245,7 @@ export namespace Session {});msgs.push(next);- let text: TextUIPart | undefined;+ let text: Message.TextPart | undefined;const reader = result.toUIMessageStream().getReader();while (true) {const result = await reader.read().catch((e) => {@@ -308,6 +284,8 @@ export namespace Session {toolInvocation: {state: "call",...value,+ // hack until zod v4+ args: value.args as any,},});break;@@ -317,8 +295,8 @@ export namespace Session {(p) =>p.type === "tool-invocation" &&p.toolInvocation.toolCallId === value.toolCallId,- ) as ToolInvocationUIPart | undefined;- if (match) {+ );+ if (match && match.type === "tool-invocation") {const { output, metadata } = value.result as any;next.metadata!.tool[value.toolCallId] = metadata;match.toolInvocation = {diff --git a/pkg/client/client.go b/pkg/client/client.goindex 98a49a0d949..fba38c008c0 100644--- a/pkg/client/client.go+++ b/pkg/client/client.go@@ -1,5 +1,5 @@package client//go:generate bun run ../../js/src/index.ts generate-//go:generate go tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --package=client --generate=types,client -o generated-client.go ./gen/openapi.json+//go:generate go tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --package=client --generate=types,client,models -o generated-client.go ./gen/openapi.json//go:generate go tool github.com/atombender/go-jsonschema -p client -o generated-event.go ./gen/event.jsondiff --git a/pkg/client/gen/openapi.json b/pkg/client/gen/openapi.jsonindex 3480a1130d8..395ff5614fc 100644--- a/pkg/client/gen/openapi.json+++ b/pkg/client/gen/openapi.json@@ -1,5 +1,5 @@{- "openapi": "3.1.0",+ "openapi": "3.0.0","info": {"title": "opencode","description": "opencode api",@@ -71,7 +71,7 @@"schema": {"type": "array","items": {- "$ref": "#/components/schemas/Session.Message"+ "$ref": "#/components/schemas/Message.Info"}}}@@ -182,7 +182,7 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/Session.Message"+ "$ref": "#/components/schemas/Message.Info"}}}@@ -209,7 +209,7 @@"parts": {"type": "array","items": {- "$ref": "#/components/schemas/Session.Message.Part"+ "$ref": "#/components/schemas/Message.Part"}}},@@ -269,7 +269,7 @@"title"]},- "Session.Message": {+ "Message.Info": {"type": "object","properties": {"id": {@@ -286,7 +286,7 @@"parts": {"type": "array","items": {- "$ref": "#/components/schemas/Session.Message.Part"+ "$ref": "#/components/schemas/Message.Part"}},"metadata": {@@ -312,6 +312,45 @@"tool": {"type": "object","additionalProperties": {}+ },+ "assistant": {+ "type": "object",+ "properties": {+ "modelID": {+ "type": "string"+ },+ "providerID": {+ "type": "string"+ },+ "cost": {+ "type": "number"+ },+ "tokens": {+ "type": "object",+ "properties": {+ "input": {+ "type": "number"+ },+ "output": {+ "type": "number"+ },+ "reasoning": {+ "type": "number"+ }+ },+ "required": [+ "input",+ "output",+ "reasoning"+ ]+ }+ },+ "required": [+ "modelID",+ "providerID",+ "cost",+ "tokens"+ ]}},"required": [@@ -328,40 +367,40 @@"metadata"]},- "Session.Message.Part": {+ "Message.Part": {"oneOf": [{- "$ref": "#/components/schemas/Session.Message.Part.Text"+ "$ref": "#/components/schemas/Message.Part.Text"},{- "$ref": "#/components/schemas/Session.Message.Part.Reasoning"+ "$ref": "#/components/schemas/Message.Part.Reasoning"},{- "$ref": "#/components/schemas/Session.Message.Part.ToolInvocation"+ "$ref": "#/components/schemas/Message.Part.ToolInvocation"},{- "$ref": "#/components/schemas/Session.Message.Part.SourceUrl"+ "$ref": "#/components/schemas/Message.Part.SourceUrl"},{- "$ref": "#/components/schemas/Session.Message.Part.File"+ "$ref": "#/components/schemas/Message.Part.File"},{- "$ref": "#/components/schemas/Session.Message.Part.StepStart"+ "$ref": "#/components/schemas/Message.Part.StepStart"}],"discriminator": {"propertyName": "type","mapping": {- "text": "#/components/schemas/Session.Message.Part.Text",- "reasoning": "#/components/schemas/Session.Message.Part.Reasoning",- "tool-invocation": "#/components/schemas/Session.Message.Part.ToolInvocation",- "source-url": "#/components/schemas/Session.Message.Part.SourceUrl",- "file": "#/components/schemas/Session.Message.Part.File",- "step-start": "#/components/schemas/Session.Message.Part.StepStart"+ "text": "#/components/schemas/Message.Part.Text",+ "reasoning": "#/components/schemas/Message.Part.Reasoning",+ "tool-invocation": "#/components/schemas/Message.Part.ToolInvocation",+ "source-url": "#/components/schemas/Message.Part.SourceUrl",+ "file": "#/components/schemas/Message.Part.File",+ "step-start": "#/components/schemas/Message.Part.StepStart"}}},- "Session.Message.Part.Text": {+ "Message.Part.Text": {"type": "object","properties": {"type": {@@ -377,7 +416,7 @@"text"]},- "Session.Message.Part.Reasoning": {+ "Message.Part.Reasoning": {"type": "object","properties": {"type": {@@ -397,7 +436,7 @@"text"]},- "Session.Message.Part.ToolInvocation": {+ "Message.Part.ToolInvocation": {"type": "object","properties": {"type": {@@ -405,7 +444,7 @@"const": "tool-invocation"},"toolInvocation": {- "$ref": "#/components/schemas/Session.Message.ToolInvocation"+ "$ref": "#/components/schemas/Message.ToolInvocation"}},"required": [@@ -413,28 +452,28 @@"toolInvocation"]},- "Session.Message.ToolInvocation": {+ "Message.ToolInvocation": {"oneOf": [{- "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolCall"+ "$ref": "#/components/schemas/Message.ToolInvocation.ToolCall"},{- "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolPartialCall"+ "$ref": "#/components/schemas/Message.ToolInvocation.ToolPartialCall"},{- "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolResult"+ "$ref": "#/components/schemas/Message.ToolInvocation.ToolResult"}],"discriminator": {"propertyName": "state","mapping": {- "call": "#/components/schemas/Session.Message.ToolInvocation.ToolCall",- "partial-call": "#/components/schemas/Session.Message.ToolInvocation.ToolPartialCall",- "result": "#/components/schemas/Session.Message.ToolInvocation.ToolResult"+ "call": "#/components/schemas/Message.ToolInvocation.ToolCall",+ "partial-call": "#/components/schemas/Message.ToolInvocation.ToolPartialCall",+ "result": "#/components/schemas/Message.ToolInvocation.ToolResult"}}},- "Session.Message.ToolInvocation.ToolCall": {+ "Message.ToolInvocation.ToolCall": {"type": "object","properties": {"state": {@@ -450,19 +489,15 @@"toolName": {"type": "string"},- "args": {- "type": "object",- "additionalProperties": {}- }+ "args": {}},"required": ["state","toolCallId",- "toolName",- "args"+ "toolName"]},- "Session.Message.ToolInvocation.ToolPartialCall": {+ "Message.ToolInvocation.ToolPartialCall": {"type": "object","properties": {"state": {@@ -478,19 +513,15 @@"toolName": {"type": "string"},- "args": {- "type": "object",- "additionalProperties": {}- }+ "args": {}},"required": ["state","toolCallId",- "toolName",- "args"+ "toolName"]},- "Session.Message.ToolInvocation.ToolResult": {+ "Message.ToolInvocation.ToolResult": {"type": "object","properties": {"state": {@@ -506,10 +537,7 @@"toolName": {"type": "string"},- "args": {- "type": "object",- "additionalProperties": {}- },+ "args": {},"result": {"type": "string"}@@ -518,11 +546,10 @@"state","toolCallId","toolName",- "args","result"]},- "Session.Message.Part.SourceUrl": {+ "Message.Part.SourceUrl": {"type": "object","properties": {"type": {@@ -549,7 +576,7 @@"url"]},- "Session.Message.Part.File": {+ "Message.Part.File": {"type": "object","properties": {"type": {@@ -572,7 +599,7 @@"url"]},- "Session.Message.Part.StepStart": {+ "Message.Part.StepStart": {"type": "object","properties": {"type": {diff --git a/pkg/client/generated-client.go b/pkg/client/generated-client.goindex 45b4762d3ce..5901cb1c0d9 100644--- a/pkg/client/generated-client.go+++ b/pkg/client/generated-client.go@@ -17,42 +17,27 @@ import ("github.com/oapi-codegen/runtime")-// Defines values for SessionMessageRole.+// Defines values for MessageInfoRole.const (- Assistant SessionMessageRole = "assistant"- System SessionMessageRole = "system"- User SessionMessageRole = "user"+ Assistant MessageInfoRole = "assistant"+ System MessageInfoRole = "system"+ User MessageInfoRole = "user")-// ProviderInfo defines model for Provider.Info.-type ProviderInfo struct {- Models map[string]struct {- Attachment bool `json:"attachment"`- ContextWindow float32 `json:"contextWindow"`- Cost struct {- Input float32 `json:"input"`- InputCached float32 `json:"inputCached"`- Output float32 `json:"output"`- OutputCached float32 `json:"outputCached"`- } `json:"cost"`- MaxTokens *float32 `json:"maxTokens,omitempty"`- Name *string `json:"name,omitempty"`- Reasoning *bool `json:"reasoning,omitempty"`- } `json:"models"`- Options *map[string]interface{} `json:"options,omitempty"`-}--// SessionInfo defines model for Session.Info.-type SessionInfo struct {- Id string `json:"id"`- ShareID *string `json:"shareID,omitempty"`- Title string `json:"title"`-}--// SessionMessage defines model for Session.Message.-type SessionMessage struct {+// MessageInfo defines model for Message.Info.+type MessageInfo struct {Id string `json:"id"`Metadata struct {+ Assistant *struct {+ Cost float32 `json:"cost"`+ ModelID string `json:"modelID"`+ ProviderID string `json:"providerID"`+ Tokens struct {+ Input float32 `json:"input"`+ Output float32 `json:"output"`+ Reasoning float32 `json:"reasoning"`+ } `json:"tokens"`+ } `json:"assistant,omitempty"`SessionID string `json:"sessionID"`Time struct {Completed *float32 `json:"completed,omitempty"`@@ -60,35 +45,35 @@ type SessionMessage struct {} `json:"time"`Tool map[string]interface{} `json:"tool"`} `json:"metadata"`- Parts []SessionMessagePart `json:"parts"`- Role SessionMessageRole `json:"role"`+ Parts []MessagePart `json:"parts"`+ Role MessageInfoRole `json:"role"`}-// SessionMessageRole defines model for SessionMessage.Role.-type SessionMessageRole string+// MessageInfoRole defines model for MessageInfo.Role.+type MessageInfoRole string-// SessionMessagePart defines model for Session.Message.Part.-type SessionMessagePart struct {+// MessagePart defines model for Message.Part.+type MessagePart struct {union json.RawMessage}-// SessionMessagePartFile defines model for Session.Message.Part.File.-type SessionMessagePartFile struct {+// MessagePartFile defines model for Message.Part.File.+type MessagePartFile struct {Filename *string `json:"filename,omitempty"`MediaType string `json:"mediaType"`Type string `json:"type"`Url string `json:"url"`}-// SessionMessagePartReasoning defines model for Session.Message.Part.Reasoning.-type SessionMessagePartReasoning struct {+// MessagePartReasoning defines model for Message.Part.Reasoning.+type MessagePartReasoning struct {ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`Text string `json:"text"`Type string `json:"type"`}-// SessionMessagePartSourceUrl defines model for Session.Message.Part.SourceUrl.-type SessionMessagePartSourceUrl struct {+// MessagePartSourceUrl defines model for Message.Part.SourceUrl.+type MessagePartSourceUrl struct {ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`SourceId string `json:"sourceId"`Title *string `json:"title,omitempty"`@@ -96,54 +81,79 @@ type SessionMessagePartSourceUrl struct {Url string `json:"url"`}-// SessionMessagePartStepStart defines model for Session.Message.Part.StepStart.-type SessionMessagePartStepStart struct {+// MessagePartStepStart defines model for Message.Part.StepStart.+type MessagePartStepStart struct {Type string `json:"type"`}-// SessionMessagePartText defines model for Session.Message.Part.Text.-type SessionMessagePartText struct {+// MessagePartText defines model for Message.Part.Text.+type MessagePartText struct {Text string `json:"text"`Type string `json:"type"`}-// SessionMessagePartToolInvocation defines model for Session.Message.Part.ToolInvocation.-type SessionMessagePartToolInvocation struct {- ToolInvocation SessionMessageToolInvocation `json:"toolInvocation"`- Type string `json:"type"`+// MessagePartToolInvocation defines model for Message.Part.ToolInvocation.+type MessagePartToolInvocation struct {+ ToolInvocation MessageToolInvocation `json:"toolInvocation"`+ Type string `json:"type"`}-// SessionMessageToolInvocation defines model for Session.Message.ToolInvocation.-type SessionMessageToolInvocation struct {+// MessageToolInvocation defines model for Message.ToolInvocation.+type MessageToolInvocation struct {union json.RawMessage}-// SessionMessageToolInvocationToolCall defines model for Session.Message.ToolInvocation.ToolCall.-type SessionMessageToolInvocationToolCall struct {- Args map[string]interface{} `json:"args"`- State string `json:"state"`- Step *float32 `json:"step,omitempty"`- ToolCallId string `json:"toolCallId"`- ToolName string `json:"toolName"`+// MessageToolInvocationToolCall defines model for Message.ToolInvocation.ToolCall.+type MessageToolInvocationToolCall struct {+ Args *interface{} `json:"args,omitempty"`+ State string `json:"state"`+ Step *float32 `json:"step,omitempty"`+ ToolCallId string `json:"toolCallId"`+ ToolName string `json:"toolName"`}-// SessionMessageToolInvocationToolPartialCall defines model for Session.Message.ToolInvocation.ToolPartialCall.-type SessionMessageToolInvocationToolPartialCall struct {- Args map[string]interface{} `json:"args"`- State string `json:"state"`- Step *float32 `json:"step,omitempty"`- ToolCallId string `json:"toolCallId"`- ToolName string `json:"toolName"`+// MessageToolInvocationToolPartialCall defines model for Message.ToolInvocation.ToolPartialCall.+type MessageToolInvocationToolPartialCall struct {+ Args *interface{} `json:"args,omitempty"`+ State string `json:"state"`+ Step *float32 `json:"step,omitempty"`+ ToolCallId string `json:"toolCallId"`+ ToolName string `json:"toolName"`}-// SessionMessageToolInvocationToolResult defines model for Session.Message.ToolInvocation.ToolResult.-type SessionMessageToolInvocationToolResult struct {- Args map[string]interface{} `json:"args"`- Result string `json:"result"`- State string `json:"state"`- Step *float32 `json:"step,omitempty"`- ToolCallId string `json:"toolCallId"`- ToolName string `json:"toolName"`+// MessageToolInvocationToolResult defines model for Message.ToolInvocation.ToolResult.+type MessageToolInvocationToolResult struct {+ Args *interface{} `json:"args,omitempty"`+ Result string `json:"result"`+ State string `json:"state"`+ Step *float32 `json:"step,omitempty"`+ ToolCallId string `json:"toolCallId"`+ ToolName string `json:"toolName"`+}++// ProviderInfo defines model for Provider.Info.+type ProviderInfo struct {+ Models map[string]struct {+ Attachment bool `json:"attachment"`+ ContextWindow float32 `json:"contextWindow"`+ Cost struct {+ Input float32 `json:"input"`+ InputCached float32 `json:"inputCached"`+ Output float32 `json:"output"`+ OutputCached float32 `json:"outputCached"`+ } `json:"cost"`+ MaxTokens *float32 `json:"maxTokens,omitempty"`+ Name *string `json:"name,omitempty"`+ Reasoning *bool `json:"reasoning,omitempty"`+ } `json:"models"`+ Options *map[string]interface{} `json:"options,omitempty"`+}++// SessionInfo defines model for Session.Info.+type SessionInfo struct {+ Id string `json:"id"`+ ShareID *string `json:"shareID,omitempty"`+ Title string `json:"title"`}// PostSessionAbortJSONBody defines parameters for PostSessionAbort.@@ -153,10 +163,10 @@ type PostSessionAbortJSONBody struct {// PostSessionChatJSONBody defines parameters for PostSessionChat.type PostSessionChatJSONBody struct {- ModelID string `json:"modelID"`- Parts []SessionMessagePart `json:"parts"`- ProviderID string `json:"providerID"`- SessionID string `json:"sessionID"`+ ModelID string `json:"modelID"`+ Parts []MessagePart `json:"parts"`+ ProviderID string `json:"providerID"`+ SessionID string `json:"sessionID"`}// PostSessionMessagesJSONBody defines parameters for PostSessionMessages.@@ -181,23 +191,23 @@ type PostSessionMessagesJSONRequestBody PostSessionMessagesJSONBody// PostSessionShareJSONRequestBody defines body for PostSessionShare for application/json ContentType.type PostSessionShareJSONRequestBody PostSessionShareJSONBody-// AsSessionMessagePartText returns the union data inside the SessionMessagePart as a SessionMessagePartText-func (t SessionMessagePart) AsSessionMessagePartText() (SessionMessagePartText, error) {- var body SessionMessagePartText+// AsMessagePartText returns the union data inside the MessagePart as a MessagePartText+func (t MessagePart) AsMessagePartText() (MessagePartText, error) {+ var body MessagePartTexterr := json.Unmarshal(t.union, &body)return body, err}-// FromSessionMessagePartText overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartText-func (t *SessionMessagePart) FromSessionMessagePartText(v SessionMessagePartText) error {+// FromMessagePartText overwrites any union data inside the MessagePart as the provided MessagePartText+func (t *MessagePart) FromMessagePartText(v MessagePartText) error {v.Type = "text"b, err := json.Marshal(v)t.union = breturn err}-// MergeSessionMessagePartText performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartText-func (t *SessionMessagePart) MergeSessionMessagePartText(v SessionMessagePartText) error {+// MergeMessagePartText performs a merge with any union data inside the MessagePart, using the provided MessagePartText+func (t *MessagePart) MergeMessagePartText(v MessagePartText) error {v.Type = "text"b, err := json.Marshal(v)if err != nil {@@ -209,23 +219,23 @@ func (t *SessionMessagePart) MergeSessionMessagePartText(v SessionMessagePartTexreturn err}-// AsSessionMessagePartReasoning returns the union data inside the SessionMessagePart as a SessionMessagePartReasoning-func (t SessionMessagePart) AsSessionMessagePartReasoning() (SessionMessagePartReasoning, error) {- var body SessionMessagePartReasoning+// AsMessagePartReasoning returns the union data inside the MessagePart as a MessagePartReasoning+func (t MessagePart) AsMessagePartReasoning() (MessagePartReasoning, error) {+ var body MessagePartReasoningerr := json.Unmarshal(t.union, &body)return body, err}-// FromSessionMessagePartReasoning overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartReasoning-func (t *SessionMessagePart) FromSessionMessagePartReasoning(v SessionMessagePartReasoning) error {+// FromMessagePartReasoning overwrites any union data inside the MessagePart as the provided MessagePartReasoning+func (t *MessagePart) FromMessagePartReasoning(v MessagePartReasoning) error {v.Type = "reasoning"b, err := json.Marshal(v)t.union = breturn err}-// MergeSessionMessagePartReasoning performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartReasoning-func (t *SessionMessagePart) MergeSessionMessagePartReasoning(v SessionMessagePartReasoning) error {+// MergeMessagePartReasoning performs a merge with any union data inside the MessagePart, using the provided MessagePartReasoning+func (t *MessagePart) MergeMessagePartReasoning(v MessagePartReasoning) error {v.Type = "reasoning"b, err := json.Marshal(v)if err != nil {@@ -237,23 +247,23 @@ func (t *SessionMessagePart) MergeSessionMessagePartReasoning(v SessionMessagePareturn err}-// AsSessionMessagePartToolInvocation returns the union data inside the SessionMessagePart as a SessionMessagePartToolInvocation-func (t SessionMessagePart) AsSessionMessagePartToolInvocation() (SessionMessagePartToolInvocation, error) {- var body SessionMessagePartToolInvocation+// AsMessagePartToolInvocation returns the union data inside the MessagePart as a MessagePartToolInvocation+func (t MessagePart) AsMessagePartToolInvocation() (MessagePartToolInvocation, error) {+ var body MessagePartToolInvocationerr := json.Unmarshal(t.union, &body)return body, err}-// FromSessionMessagePartToolInvocation overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartToolInvocation-func (t *SessionMessagePart) FromSessionMessagePartToolInvocation(v SessionMessagePartToolInvocation) error {+// FromMessagePartToolInvocation overwrites any union data inside the MessagePart as the provided MessagePartToolInvocation+func (t *MessagePart) FromMessagePartToolInvocation(v MessagePartToolInvocation) error {v.Type = "tool-invocation"b, err := json.Marshal(v)t.union = breturn err}-// MergeSessionMessagePartToolInvocation performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartToolInvocation-func (t *SessionMessagePart) MergeSessionMessagePartToolInvocation(v SessionMessagePartToolInvocation) error {+// MergeMessagePartToolInvocation performs a merge with any union data inside the MessagePart, using the provided MessagePartToolInvocation+func (t *MessagePart) MergeMessagePartToolInvocation(v MessagePartToolInvocation) error {v.Type = "tool-invocation"b, err := json.Marshal(v)if err != nil {@@ -265,23 +275,23 @@ func (t *SessionMessagePart) MergeSessionMessagePartToolInvocation(v SessionMessreturn err}-// AsSessionMessagePartSourceUrl returns the union data inside the SessionMessagePart as a SessionMessagePartSourceUrl-func (t SessionMessagePart) AsSessionMessagePartSourceUrl() (SessionMessagePartSourceUrl, error) {- var body SessionMessagePartSourceUrl+// AsMessagePartSourceUrl returns the union data inside the MessagePart as a MessagePartSourceUrl+func (t MessagePart) AsMessagePartSourceUrl() (MessagePartSourceUrl, error) {+ var body MessagePartSourceUrlerr := json.Unmarshal(t.union, &body)return body, err}-// FromSessionMessagePartSourceUrl overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartSourceUrl-func (t *SessionMessagePart) FromSessionMessagePartSourceUrl(v SessionMessagePartSourceUrl) error {+// FromMessagePartSourceUrl overwrites any union data inside the MessagePart as the provided MessagePartSourceUrl+func (t *MessagePart) FromMessagePartSourceUrl(v MessagePartSourceUrl) error {v.Type = "source-url"b, err := json.Marshal(v)t.union = breturn err}-// MergeSessionMessagePartSourceUrl performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartSourceUrl-func (t *SessionMessagePart) MergeSessionMessagePartSourceUrl(v SessionMessagePartSourceUrl) error {+// MergeMessagePartSourceUrl performs a merge with any union data inside the MessagePart, using the provided MessagePartSourceUrl+func (t *MessagePart) MergeMessagePartSourceUrl(v MessagePartSourceUrl) error {v.Type = "source-url"b, err := json.Marshal(v)if err != nil {@@ -293,23 +303,23 @@ func (t *SessionMessagePart) MergeSessionMessagePartSourceUrl(v SessionMessagePareturn err}-// AsSessionMessagePartFile returns the union data inside the SessionMessagePart as a SessionMessagePartFile-func (t SessionMessagePart) AsSessionMessagePartFile() (SessionMessagePartFile, error) {- var body SessionMessagePartFile+// AsMessagePartFile returns the union data inside the MessagePart as a MessagePartFile+func (t MessagePart) AsMessagePartFile() (MessagePartFile, error) {+ var body MessagePartFileerr := json.Unmarshal(t.union, &body)return body, err}-// FromSessionMessagePartFile overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartFile-func (t *SessionMessagePart) FromSessionMessagePartFile(v SessionMessagePartFile) error {+// FromMessagePartFile overwrites any union data inside the MessagePart as the provided MessagePartFile+func (t *MessagePart) FromMessagePartFile(v MessagePartFile) error {v.Type = "file"b, err := json.Marshal(v)t.union = breturn err}-// MergeSessionMessagePartFile performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartFile-func (t *SessionMessagePart) MergeSessionMessagePartFile(v SessionMessagePartFile) error {+// MergeMessagePartFile performs a merge with any union data inside the MessagePart, using the provided MessagePartFile+func (t *MessagePart) MergeMessagePartFile(v MessagePartFile) error {v.Type = "file"b, err := json.Marshal(v)if err != nil {@@ -321,23 +331,23 @@ func (t *SessionMessagePart) MergeSessionMessagePartFile(v SessionMessagePartFilreturn err}-// AsSessionMessagePartStepStart returns the union data inside the SessionMessagePart as a SessionMessagePartStepStart-func (t SessionMessagePart) AsSessionMessagePartStepStart() (SessionMessagePartStepStart, error) {- var body SessionMessagePartStepStart+// AsMessagePartStepStart returns the union data inside the MessagePart as a MessagePartStepStart+func (t MessagePart) AsMessagePartStepStart() (MessagePartStepStart, error) {+ var body MessagePartStepStarterr := json.Unmarshal(t.union, &body)return body, err}-// FromSessionMessagePartStepStart overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartStepStart-func (t *SessionMessagePart) FromSessionMessagePartStepStart(v SessionMessagePartStepStart) error {+// FromMessagePartStepStart overwrites any union data inside the MessagePart as the provided MessagePartStepStart+func (t *MessagePart) FromMessagePartStepStart(v MessagePartStepStart) error {v.Type = "step-start"b, err := json.Marshal(v)t.union = breturn err}-// MergeSessionMessagePartStepStart performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartStepStart-func (t *SessionMessagePart) MergeSessionMessagePartStepStart(v SessionMessagePartStepStart) error {+// MergeMessagePartStepStart performs a merge with any union data inside the MessagePart, using the provided MessagePartStepStart+func (t *MessagePart) MergeMessagePartStepStart(v MessagePartStepStart) error {v.Type = "step-start"b, err := json.Marshal(v)if err != nil {@@ -349,7 +359,7 @@ func (t *SessionMessagePart) MergeSessionMessagePartStepStart(v SessionMessagePareturn err}-func (t SessionMessagePart) Discriminator() (string, error) {+func (t MessagePart) Discriminator() (string, error) {var discriminator struct {Discriminator string `json:"type"`}@@ -357,56 +367,56 @@ func (t SessionMessagePart) Discriminator() (string, error) {return discriminator.Discriminator, err}-func (t SessionMessagePart) ValueByDiscriminator() (interface{}, error) {+func (t MessagePart) ValueByDiscriminator() (interface{}, error) {discriminator, err := t.Discriminator()if err != nil {return nil, err}switch discriminator {case "file":- return t.AsSessionMessagePartFile()+ return t.AsMessagePartFile()case "reasoning":- return t.AsSessionMessagePartReasoning()+ return t.AsMessagePartReasoning()case "source-url":- return t.AsSessionMessagePartSourceUrl()+ return t.AsMessagePartSourceUrl()case "step-start":- return t.AsSessionMessagePartStepStart()+ return t.AsMessagePartStepStart()case "text":- return t.AsSessionMessagePartText()+ return t.AsMessagePartText()case "tool-invocation":- return t.AsSessionMessagePartToolInvocation()+ return t.AsMessagePartToolInvocation()default:return nil, errors.New("unknown discriminator value: " + discriminator)}}-func (t SessionMessagePart) MarshalJSON() ([]byte, error) {+func (t MessagePart) MarshalJSON() ([]byte, error) {b, err := t.union.MarshalJSON()return b, err}-func (t *SessionMessagePart) UnmarshalJSON(b []byte) error {+func (t *MessagePart) UnmarshalJSON(b []byte) error {err := t.union.UnmarshalJSON(b)return err}-// AsSessionMessageToolInvocationToolCall returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolCall-func (t SessionMessageToolInvocation) AsSessionMessageToolInvocationToolCall() (SessionMessageToolInvocationToolCall, error) {- var body SessionMessageToolInvocationToolCall+// AsMessageToolInvocationToolCall returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolCall+func (t MessageToolInvocation) AsMessageToolInvocationToolCall() (MessageToolInvocationToolCall, error) {+ var body MessageToolInvocationToolCallerr := json.Unmarshal(t.union, &body)return body, err}-// FromSessionMessageToolInvocationToolCall overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolCall-func (t *SessionMessageToolInvocation) FromSessionMessageToolInvocationToolCall(v SessionMessageToolInvocationToolCall) error {+// FromMessageToolInvocationToolCall overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolCall+func (t *MessageToolInvocation) FromMessageToolInvocationToolCall(v MessageToolInvocationToolCall) error {v.State = "call"b, err := json.Marshal(v)t.union = breturn err}-// MergeSessionMessageToolInvocationToolCall performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolCall-func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolCall(v SessionMessageToolInvocationToolCall) error {+// MergeMessageToolInvocationToolCall performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolCall+func (t *MessageToolInvocation) MergeMessageToolInvocationToolCall(v MessageToolInvocationToolCall) error {v.State = "call"b, err := json.Marshal(v)if err != nil {@@ -418,23 +428,23 @@ func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolCallreturn err}-// AsSessionMessageToolInvocationToolPartialCall returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolPartialCall-func (t SessionMessageToolInvocation) AsSessionMessageToolInvocationToolPartialCall() (SessionMessageToolInvocationToolPartialCall, error) {- var body SessionMessageToolInvocationToolPartialCall+// AsMessageToolInvocationToolPartialCall returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolPartialCall+func (t MessageToolInvocation) AsMessageToolInvocationToolPartialCall() (MessageToolInvocationToolPartialCall, error) {+ var body MessageToolInvocationToolPartialCallerr := json.Unmarshal(t.union, &body)return body, err}-// FromSessionMessageToolInvocationToolPartialCall overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolPartialCall-func (t *SessionMessageToolInvocation) FromSessionMessageToolInvocationToolPartialCall(v SessionMessageToolInvocationToolPartialCall) error {+// FromMessageToolInvocationToolPartialCall overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolPartialCall+func (t *MessageToolInvocation) FromMessageToolInvocationToolPartialCall(v MessageToolInvocationToolPartialCall) error {v.State = "partial-call"b, err := json.Marshal(v)t.union = breturn err}-// MergeSessionMessageToolInvocationToolPartialCall performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolPartialCall-func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolPartialCall(v SessionMessageToolInvocationToolPartialCall) error {+// MergeMessageToolInvocationToolPartialCall performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolPartialCall+func (t *MessageToolInvocation) MergeMessageToolInvocationToolPartialCall(v MessageToolInvocationToolPartialCall) error {v.State = "partial-call"b, err := json.Marshal(v)if err != nil {@@ -446,23 +456,23 @@ func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolPartreturn err}-// AsSessionMessageToolInvocationToolResult returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolResult-func (t SessionMessageToolInvocation) AsSessionMessageToolInvocationToolResult() (SessionMessageToolInvocationToolResult, error) {- var body SessionMessageToolInvocationToolResult+// AsMessageToolInvocationToolResult returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolResult+func (t MessageToolInvocation) AsMessageToolInvocationToolResult() (MessageToolInvocationToolResult, error) {+ var body MessageToolInvocationToolResulterr := json.Unmarshal(t.union, &body)return body, err}-// FromSessionMessageToolInvocationToolResult overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolResult-func (t *SessionMessageToolInvocation) FromSessionMessageToolInvocationToolResult(v SessionMessageToolInvocationToolResult) error {+// FromMessageToolInvocationToolResult overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolResult+func (t *MessageToolInvocation) FromMessageToolInvocationToolResult(v MessageToolInvocationToolResult) error {v.State = "result"b, err := json.Marshal(v)t.union = breturn err}-// MergeSessionMessageToolInvocationToolResult performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolResult-func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolResult(v SessionMessageToolInvocationToolResult) error {+// MergeMessageToolInvocationToolResult performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolResult+func (t *MessageToolInvocation) MergeMessageToolInvocationToolResult(v MessageToolInvocationToolResult) error {v.State = "result"b, err := json.Marshal(v)if err != nil {@@ -474,7 +484,7 @@ func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolResureturn err}-func (t SessionMessageToolInvocation) Discriminator() (string, error) {+func (t MessageToolInvocation) Discriminator() (string, error) {var discriminator struct {Discriminator string `json:"state"`}@@ -482,29 +492,29 @@ func (t SessionMessageToolInvocation) Discriminator() (string, error) {return discriminator.Discriminator, err}-func (t SessionMessageToolInvocation) ValueByDiscriminator() (interface{}, error) {+func (t MessageToolInvocation) ValueByDiscriminator() (interface{}, error) {discriminator, err := t.Discriminator()if err != nil {return nil, err}switch discriminator {case "call":- return t.AsSessionMessageToolInvocationToolCall()+ return t.AsMessageToolInvocationToolCall()case "partial-call":- return t.AsSessionMessageToolInvocationToolPartialCall()+ return t.AsMessageToolInvocationToolPartialCall()case "result":- return t.AsSessionMessageToolInvocationToolResult()+ return t.AsMessageToolInvocationToolResult()default:return nil, errors.New("unknown discriminator value: " + discriminator)}}-func (t SessionMessageToolInvocation) MarshalJSON() ([]byte, error) {+func (t MessageToolInvocation) MarshalJSON() ([]byte, error) {b, err := t.union.MarshalJSON()return b, err}-func (t *SessionMessageToolInvocation) UnmarshalJSON(b []byte) error {+func (t *MessageToolInvocation) UnmarshalJSON(b []byte) error {err := t.union.UnmarshalJSON(b)return err}@@ -1105,7 +1115,7 @@ func (r PostSessionAbortResponse) StatusCode() int {type PostSessionChatResponse struct {Body []byteHTTPResponse *http.Response- JSON200 *SessionMessage+ JSON200 *MessageInfo}// Status returns HTTPResponse.Status@@ -1175,7 +1185,7 @@ func (r PostSessionListResponse) StatusCode() int {type PostSessionMessagesResponse struct {Body []byteHTTPResponse *http.Response- JSON200 *[]SessionMessage+ JSON200 *[]MessageInfo}// Status returns HTTPResponse.Status@@ -1378,7 +1388,7 @@ func ParsePostSessionChatResponse(rsp *http.Response) (*PostSessionChatResponse,switch {case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:- var dest SessionMessage+ var dest MessageInfoif err := json.Unmarshal(bodyBytes, &dest); err != nil {return nil, err}@@ -1460,7 +1470,7 @@ func ParsePostSessionMessagesResponse(rsp *http.Response) (*PostSessionMessagesRswitch {case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:- var dest []SessionMessage+ var dest []MessageInfoif err := json.Unmarshal(bodyBytes, &dest); err != nil {return nil, err}