Browse Source

generate message type

Dax Raad 9 months ago
parent
commit
3a4d3b249f
4 changed files with 872 additions and 12 deletions
  1. 146 0
      js/src/server/message.ts
  2. 4 3
      js/src/server/server.ts
  3. 323 3
      pkg/client/gen/openapi.json
  4. 399 6
      pkg/client/generated-client.go

+ 146 - 0
js/src/server/message.ts

@@ -0,0 +1,146 @@
+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
+  .union([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 DataPart = z
+  .object({
+    type: z.custom<`data-${string}`>(),
+    id: z.string().optional(),
+    data: z.unknown(),
+  })
+  .openapi({
+    ref: "Session.Message.Part.Data",
+  });
+
+const Part = z
+  .union([
+    TextPart,
+    ReasoningPart,
+    ToolInvocationPart,
+    SourceUrlPart,
+    FilePart,
+    StepStartPart,
+    DataPart,
+  ])
+  .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",
+  });

+ 4 - 3
js/src/server/server.ts

@@ -9,6 +9,7 @@ import { z } from "zod";
 import "zod-openapi/extend";
 import "zod-openapi/extend";
 import { Config } from "../app/config";
 import { Config } from "../app/config";
 import { LLM } from "../llm/llm";
 import { LLM } from "../llm/llm";
+import { SessionMessage } from "./message";
 
 
 const SessionInfo = Session.Info.openapi({
 const SessionInfo = Session.Info.openapi({
   ref: "Session.Info",
   ref: "Session.Info",
@@ -118,7 +119,7 @@ export namespace Server {
               description: "Successfully created session",
               description: "Successfully created session",
               content: {
               content: {
                 "application/json": {
                 "application/json": {
-                  schema: resolver(z.custom<Session.Message[]>()),
+                  schema: resolver(SessionMessage.array()),
                 },
                 },
               },
               },
             },
             },
@@ -165,12 +166,12 @@ export namespace Server {
             sessionID: z.string(),
             sessionID: z.string(),
             providerID: z.string(),
             providerID: z.string(),
             modelID: z.string(),
             modelID: z.string(),
-            parts: z.custom<Session.Message["parts"]>(),
+            parts: SessionMessage.shape.parts,
           }),
           }),
         ),
         ),
         async (c) => {
         async (c) => {
           const body = c.req.valid("json");
           const body = c.req.valid("json");
-          const msg = await Session.chat(body);
+          const msg = await Session.chat(body as any);
           return c.json(msg);
           return c.json(msg);
         },
         },
       )
       )

+ 323 - 3
pkg/client/gen/openapi.json

@@ -68,7 +68,12 @@
             "description": "Successfully created session",
             "description": "Successfully created session",
             "content": {
             "content": {
               "application/json": {
               "application/json": {
-                "schema": {}
+                "schema": {
+                  "type": "array",
+                  "items": {
+                    "$ref": "#/components/schemas/Session.Message"
+                  }
+                }
               }
               }
             }
             }
           }
           }
@@ -173,12 +178,18 @@
                   "modelID": {
                   "modelID": {
                     "type": "string"
                     "type": "string"
                   },
                   },
-                  "parts": {}
+                  "parts": {
+                    "type": "array",
+                    "items": {
+                      "$ref": "#/components/schemas/Session.Message.Part"
+                    }
+                  }
                 },
                 },
                 "required": [
                 "required": [
                   "sessionID",
                   "sessionID",
                   "providerID",
                   "providerID",
-                  "modelID"
+                  "modelID",
+                  "parts"
                 ]
                 ]
               }
               }
             }
             }
@@ -250,6 +261,315 @@
           "tokens"
           "tokens"
         ]
         ]
       },
       },
+      "Session.Message": {
+        "type": "object",
+        "properties": {
+          "id": {
+            "type": "string"
+          },
+          "role": {
+            "type": "string",
+            "enum": [
+              "system",
+              "user",
+              "assistant"
+            ]
+          },
+          "parts": {
+            "type": "array",
+            "items": {
+              "$ref": "#/components/schemas/Session.Message.Part"
+            }
+          },
+          "metadata": {
+            "type": "object",
+            "properties": {
+              "time": {
+                "type": "object",
+                "properties": {
+                  "created": {
+                    "type": "number"
+                  },
+                  "completed": {
+                    "type": "number"
+                  }
+                },
+                "required": [
+                  "created"
+                ]
+              },
+              "sessionID": {
+                "type": "string"
+              },
+              "tool": {
+                "type": "object",
+                "additionalProperties": {}
+              }
+            },
+            "required": [
+              "time",
+              "sessionID",
+              "tool"
+            ]
+          }
+        },
+        "required": [
+          "id",
+          "role",
+          "parts",
+          "metadata"
+        ]
+      },
+      "Session.Message.Part": {
+        "anyOf": [
+          {
+            "$ref": "#/components/schemas/Session.Message.Part.Text"
+          },
+          {
+            "$ref": "#/components/schemas/Session.Message.Part.Reasoning"
+          },
+          {
+            "$ref": "#/components/schemas/Session.Message.Part.ToolInvocation"
+          },
+          {
+            "$ref": "#/components/schemas/Session.Message.Part.SourceUrl"
+          },
+          {
+            "$ref": "#/components/schemas/Session.Message.Part.File"
+          },
+          {
+            "$ref": "#/components/schemas/Session.Message.Part.StepStart"
+          },
+          {
+            "$ref": "#/components/schemas/Session.Message.Part.Data"
+          }
+        ]
+      },
+      "Session.Message.Part.Text": {
+        "type": "object",
+        "properties": {
+          "type": {
+            "type": "string",
+            "const": "text"
+          },
+          "text": {
+            "type": "string"
+          }
+        },
+        "required": [
+          "type",
+          "text"
+        ]
+      },
+      "Session.Message.Part.Reasoning": {
+        "type": "object",
+        "properties": {
+          "type": {
+            "type": "string",
+            "const": "reasoning"
+          },
+          "text": {
+            "type": "string"
+          },
+          "providerMetadata": {
+            "type": "object",
+            "additionalProperties": {}
+          }
+        },
+        "required": [
+          "type",
+          "text"
+        ]
+      },
+      "Session.Message.Part.ToolInvocation": {
+        "type": "object",
+        "properties": {
+          "type": {
+            "type": "string",
+            "const": "tool-invocation"
+          },
+          "toolInvocation": {
+            "$ref": "#/components/schemas/Session.Message.ToolInvocation"
+          }
+        },
+        "required": [
+          "type",
+          "toolInvocation"
+        ]
+      },
+      "Session.Message.ToolInvocation": {
+        "anyOf": [
+          {
+            "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolCall"
+          },
+          {
+            "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolPartialCall"
+          },
+          {
+            "$ref": "#/components/schemas/Session.Message.ToolInvocation.ToolResult"
+          }
+        ]
+      },
+      "Session.Message.ToolInvocation.ToolCall": {
+        "type": "object",
+        "properties": {
+          "state": {
+            "type": "string",
+            "const": "call"
+          },
+          "step": {
+            "type": "number"
+          },
+          "toolCallId": {
+            "type": "string"
+          },
+          "toolName": {
+            "type": "string"
+          },
+          "args": {
+            "type": "object",
+            "additionalProperties": {}
+          }
+        },
+        "required": [
+          "state",
+          "toolCallId",
+          "toolName",
+          "args"
+        ]
+      },
+      "Session.Message.ToolInvocation.ToolPartialCall": {
+        "type": "object",
+        "properties": {
+          "state": {
+            "type": "string",
+            "const": "partial-call"
+          },
+          "step": {
+            "type": "number"
+          },
+          "toolCallId": {
+            "type": "string"
+          },
+          "toolName": {
+            "type": "string"
+          },
+          "args": {
+            "type": "object",
+            "additionalProperties": {}
+          }
+        },
+        "required": [
+          "state",
+          "toolCallId",
+          "toolName",
+          "args"
+        ]
+      },
+      "Session.Message.ToolInvocation.ToolResult": {
+        "type": "object",
+        "properties": {
+          "state": {
+            "type": "string",
+            "const": "result"
+          },
+          "step": {
+            "type": "number"
+          },
+          "toolCallId": {
+            "type": "string"
+          },
+          "toolName": {
+            "type": "string"
+          },
+          "args": {
+            "type": "object",
+            "additionalProperties": {}
+          },
+          "result": {
+            "type": "string"
+          }
+        },
+        "required": [
+          "state",
+          "toolCallId",
+          "toolName",
+          "args",
+          "result"
+        ]
+      },
+      "Session.Message.Part.SourceUrl": {
+        "type": "object",
+        "properties": {
+          "type": {
+            "type": "string",
+            "const": "source-url"
+          },
+          "sourceId": {
+            "type": "string"
+          },
+          "url": {
+            "type": "string"
+          },
+          "title": {
+            "type": "string"
+          },
+          "providerMetadata": {
+            "type": "object",
+            "additionalProperties": {}
+          }
+        },
+        "required": [
+          "type",
+          "sourceId",
+          "url"
+        ]
+      },
+      "Session.Message.Part.File": {
+        "type": "object",
+        "properties": {
+          "type": {
+            "type": "string",
+            "const": "file"
+          },
+          "mediaType": {
+            "type": "string"
+          },
+          "filename": {
+            "type": "string"
+          },
+          "url": {
+            "type": "string"
+          }
+        },
+        "required": [
+          "type",
+          "mediaType",
+          "url"
+        ]
+      },
+      "Session.Message.Part.StepStart": {
+        "type": "object",
+        "properties": {
+          "type": {
+            "type": "string",
+            "const": "step-start"
+          }
+        },
+        "required": [
+          "type"
+        ]
+      },
+      "Session.Message.Part.Data": {
+        "type": "object",
+        "properties": {
+          "type": {},
+          "id": {
+            "type": "string"
+          },
+          "data": {}
+        }
+      },
       "Provider.Info": {
       "Provider.Info": {
         "type": "object",
         "type": "object",
         "properties": {
         "properties": {

+ 399 - 6
pkg/client/generated-client.go

@@ -12,6 +12,15 @@ import (
 	"net/http"
 	"net/http"
 	"net/url"
 	"net/url"
 	"strings"
 	"strings"
+
+	"github.com/oapi-codegen/runtime"
+)
+
+// Defines values for SessionMessageRole.
+const (
+	Assistant SessionMessageRole = "assistant"
+	System    SessionMessageRole = "system"
+	User      SessionMessageRole = "user"
 )
 )
 
 
 // ProviderInfo defines model for Provider.Info.
 // ProviderInfo defines model for Provider.Info.
@@ -43,12 +52,116 @@ type SessionInfo struct {
 	} `json:"tokens"`
 	} `json:"tokens"`
 }
 }
 
 
+// SessionMessage defines model for Session.Message.
+type SessionMessage struct {
+	Id       string `json:"id"`
+	Metadata struct {
+		SessionID string `json:"sessionID"`
+		Time      struct {
+			Completed *float32 `json:"completed,omitempty"`
+			Created   float32  `json:"created"`
+		} `json:"time"`
+		Tool map[string]interface{} `json:"tool"`
+	} `json:"metadata"`
+	Parts []SessionMessagePart `json:"parts"`
+	Role  SessionMessageRole   `json:"role"`
+}
+
+// SessionMessageRole defines model for SessionMessage.Role.
+type SessionMessageRole string
+
+// SessionMessagePart defines model for Session.Message.Part.
+type SessionMessagePart struct {
+	union json.RawMessage
+}
+
+// SessionMessagePartData defines model for Session.Message.Part.Data.
+type SessionMessagePartData struct {
+	Data *interface{} `json:"data,omitempty"`
+	Id   *string      `json:"id,omitempty"`
+	Type *interface{} `json:"type,omitempty"`
+}
+
+// SessionMessagePartFile defines model for Session.Message.Part.File.
+type SessionMessagePartFile 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 {
+	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 {
+	ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`
+	SourceId         string                  `json:"sourceId"`
+	Title            *string                 `json:"title,omitempty"`
+	Type             string                  `json:"type"`
+	Url              string                  `json:"url"`
+}
+
+// SessionMessagePartStepStart defines model for Session.Message.Part.StepStart.
+type SessionMessagePartStepStart struct {
+	Type string `json:"type"`
+}
+
+// SessionMessagePartText defines model for Session.Message.Part.Text.
+type SessionMessagePartText 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"`
+}
+
+// SessionMessageToolInvocation defines model for Session.Message.ToolInvocation.
+type SessionMessageToolInvocation 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"`
+}
+
+// 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"`
+}
+
+// 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"`
+}
+
 // PostSessionChatJSONBody defines parameters for PostSessionChat.
 // PostSessionChatJSONBody defines parameters for PostSessionChat.
 type PostSessionChatJSONBody struct {
 type PostSessionChatJSONBody struct {
-	ModelID    string       `json:"modelID"`
-	Parts      *interface{} `json:"parts,omitempty"`
-	ProviderID string       `json:"providerID"`
-	SessionID  string       `json:"sessionID"`
+	ModelID    string               `json:"modelID"`
+	Parts      []SessionMessagePart `json:"parts"`
+	ProviderID string               `json:"providerID"`
+	SessionID  string               `json:"sessionID"`
 }
 }
 
 
 // PostSessionMessagesJSONBody defines parameters for PostSessionMessages.
 // PostSessionMessagesJSONBody defines parameters for PostSessionMessages.
@@ -70,6 +183,286 @@ type PostSessionMessagesJSONRequestBody PostSessionMessagesJSONBody
 // PostSessionShareJSONRequestBody defines body for PostSessionShare for application/json ContentType.
 // PostSessionShareJSONRequestBody defines body for PostSessionShare for application/json ContentType.
 type PostSessionShareJSONRequestBody PostSessionShareJSONBody
 type PostSessionShareJSONRequestBody PostSessionShareJSONBody
 
 
+// AsSessionMessagePartText returns the union data inside the SessionMessagePart as a SessionMessagePartText
+func (t SessionMessagePart) AsSessionMessagePartText() (SessionMessagePartText, error) {
+	var body SessionMessagePartText
+	err := 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 {
+	b, err := json.Marshal(v)
+	t.union = b
+	return err
+}
+
+// MergeSessionMessagePartText performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartText
+func (t *SessionMessagePart) MergeSessionMessagePartText(v SessionMessagePartText) error {
+	b, err := json.Marshal(v)
+	if err != nil {
+		return err
+	}
+
+	merged, err := runtime.JSONMerge(t.union, b)
+	t.union = merged
+	return err
+}
+
+// AsSessionMessagePartReasoning returns the union data inside the SessionMessagePart as a SessionMessagePartReasoning
+func (t SessionMessagePart) AsSessionMessagePartReasoning() (SessionMessagePartReasoning, error) {
+	var body SessionMessagePartReasoning
+	err := 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 {
+	b, err := json.Marshal(v)
+	t.union = b
+	return err
+}
+
+// MergeSessionMessagePartReasoning performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartReasoning
+func (t *SessionMessagePart) MergeSessionMessagePartReasoning(v SessionMessagePartReasoning) error {
+	b, err := json.Marshal(v)
+	if err != nil {
+		return err
+	}
+
+	merged, err := runtime.JSONMerge(t.union, b)
+	t.union = merged
+	return err
+}
+
+// AsSessionMessagePartToolInvocation returns the union data inside the SessionMessagePart as a SessionMessagePartToolInvocation
+func (t SessionMessagePart) AsSessionMessagePartToolInvocation() (SessionMessagePartToolInvocation, error) {
+	var body SessionMessagePartToolInvocation
+	err := 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 {
+	b, err := json.Marshal(v)
+	t.union = b
+	return err
+}
+
+// MergeSessionMessagePartToolInvocation performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartToolInvocation
+func (t *SessionMessagePart) MergeSessionMessagePartToolInvocation(v SessionMessagePartToolInvocation) error {
+	b, err := json.Marshal(v)
+	if err != nil {
+		return err
+	}
+
+	merged, err := runtime.JSONMerge(t.union, b)
+	t.union = merged
+	return err
+}
+
+// AsSessionMessagePartSourceUrl returns the union data inside the SessionMessagePart as a SessionMessagePartSourceUrl
+func (t SessionMessagePart) AsSessionMessagePartSourceUrl() (SessionMessagePartSourceUrl, error) {
+	var body SessionMessagePartSourceUrl
+	err := 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 {
+	b, err := json.Marshal(v)
+	t.union = b
+	return err
+}
+
+// MergeSessionMessagePartSourceUrl performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartSourceUrl
+func (t *SessionMessagePart) MergeSessionMessagePartSourceUrl(v SessionMessagePartSourceUrl) error {
+	b, err := json.Marshal(v)
+	if err != nil {
+		return err
+	}
+
+	merged, err := runtime.JSONMerge(t.union, b)
+	t.union = merged
+	return err
+}
+
+// AsSessionMessagePartFile returns the union data inside the SessionMessagePart as a SessionMessagePartFile
+func (t SessionMessagePart) AsSessionMessagePartFile() (SessionMessagePartFile, error) {
+	var body SessionMessagePartFile
+	err := 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 {
+	b, err := json.Marshal(v)
+	t.union = b
+	return err
+}
+
+// MergeSessionMessagePartFile performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartFile
+func (t *SessionMessagePart) MergeSessionMessagePartFile(v SessionMessagePartFile) error {
+	b, err := json.Marshal(v)
+	if err != nil {
+		return err
+	}
+
+	merged, err := runtime.JSONMerge(t.union, b)
+	t.union = merged
+	return err
+}
+
+// AsSessionMessagePartStepStart returns the union data inside the SessionMessagePart as a SessionMessagePartStepStart
+func (t SessionMessagePart) AsSessionMessagePartStepStart() (SessionMessagePartStepStart, error) {
+	var body SessionMessagePartStepStart
+	err := 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 {
+	b, err := json.Marshal(v)
+	t.union = b
+	return err
+}
+
+// MergeSessionMessagePartStepStart performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartStepStart
+func (t *SessionMessagePart) MergeSessionMessagePartStepStart(v SessionMessagePartStepStart) error {
+	b, err := json.Marshal(v)
+	if err != nil {
+		return err
+	}
+
+	merged, err := runtime.JSONMerge(t.union, b)
+	t.union = merged
+	return err
+}
+
+// AsSessionMessagePartData returns the union data inside the SessionMessagePart as a SessionMessagePartData
+func (t SessionMessagePart) AsSessionMessagePartData() (SessionMessagePartData, error) {
+	var body SessionMessagePartData
+	err := json.Unmarshal(t.union, &body)
+	return body, err
+}
+
+// FromSessionMessagePartData overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartData
+func (t *SessionMessagePart) FromSessionMessagePartData(v SessionMessagePartData) error {
+	b, err := json.Marshal(v)
+	t.union = b
+	return err
+}
+
+// MergeSessionMessagePartData performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartData
+func (t *SessionMessagePart) MergeSessionMessagePartData(v SessionMessagePartData) error {
+	b, err := json.Marshal(v)
+	if err != nil {
+		return err
+	}
+
+	merged, err := runtime.JSONMerge(t.union, b)
+	t.union = merged
+	return err
+}
+
+func (t SessionMessagePart) MarshalJSON() ([]byte, error) {
+	b, err := t.union.MarshalJSON()
+	return b, err
+}
+
+func (t *SessionMessagePart) 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
+	err := 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 {
+	b, err := json.Marshal(v)
+	t.union = b
+	return err
+}
+
+// MergeSessionMessageToolInvocationToolCall performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolCall
+func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolCall(v SessionMessageToolInvocationToolCall) error {
+	b, err := json.Marshal(v)
+	if err != nil {
+		return err
+	}
+
+	merged, err := runtime.JSONMerge(t.union, b)
+	t.union = merged
+	return err
+}
+
+// AsSessionMessageToolInvocationToolPartialCall returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolPartialCall
+func (t SessionMessageToolInvocation) AsSessionMessageToolInvocationToolPartialCall() (SessionMessageToolInvocationToolPartialCall, error) {
+	var body SessionMessageToolInvocationToolPartialCall
+	err := 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 {
+	b, err := json.Marshal(v)
+	t.union = b
+	return err
+}
+
+// MergeSessionMessageToolInvocationToolPartialCall performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolPartialCall
+func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolPartialCall(v SessionMessageToolInvocationToolPartialCall) error {
+	b, err := json.Marshal(v)
+	if err != nil {
+		return err
+	}
+
+	merged, err := runtime.JSONMerge(t.union, b)
+	t.union = merged
+	return err
+}
+
+// AsSessionMessageToolInvocationToolResult returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolResult
+func (t SessionMessageToolInvocation) AsSessionMessageToolInvocationToolResult() (SessionMessageToolInvocationToolResult, error) {
+	var body SessionMessageToolInvocationToolResult
+	err := 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 {
+	b, err := json.Marshal(v)
+	t.union = b
+	return err
+}
+
+// MergeSessionMessageToolInvocationToolResult performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolResult
+func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolResult(v SessionMessageToolInvocationToolResult) error {
+	b, err := json.Marshal(v)
+	if err != nil {
+		return err
+	}
+
+	merged, err := runtime.JSONMerge(t.union, b)
+	t.union = merged
+	return err
+}
+
+func (t SessionMessageToolInvocation) MarshalJSON() ([]byte, error) {
+	b, err := t.union.MarshalJSON()
+	return b, err
+}
+
+func (t *SessionMessageToolInvocation) UnmarshalJSON(b []byte) error {
+	err := t.union.UnmarshalJSON(b)
+	return err
+}
+
 // RequestEditorFn  is the function signature for the RequestEditor callback function
 // RequestEditorFn  is the function signature for the RequestEditor callback function
 type RequestEditorFn func(ctx context.Context, req *http.Request) error
 type RequestEditorFn func(ctx context.Context, req *http.Request) error
 
 
@@ -644,7 +1037,7 @@ func (r PostSessionListResponse) StatusCode() int {
 type PostSessionMessagesResponse struct {
 type PostSessionMessagesResponse struct {
 	Body         []byte
 	Body         []byte
 	HTTPResponse *http.Response
 	HTTPResponse *http.Response
-	JSON200      *interface{}
+	JSON200      *[]SessionMessage
 }
 }
 
 
 // Status returns HTTPResponse.Status
 // Status returns HTTPResponse.Status
@@ -881,7 +1274,7 @@ func ParsePostSessionMessagesResponse(rsp *http.Response) (*PostSessionMessagesR
 
 
 	switch {
 	switch {
 	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
 	case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
-		var dest interface{}
+		var dest []SessionMessage
 		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
 		if err := json.Unmarshal(bodyBytes, &dest); err != nil {
 			return nil, err
 			return nil, err
 		}
 		}