diff options
| author | Dax Raad <[email protected]> | 2025-05-28 13:22:48 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-05-28 13:22:48 -0400 |
| commit | 3a4d3b249f4b529ead2f80dd0df19a9cdc0c10a6 (patch) | |
| tree | bb77726cba6875a6daa8fe6230d9a2826fab83ed /pkg | |
| parent | 55a6fcdd3f5b3c55712e5cfc9dd4d994da38d4c8 (diff) | |
| download | opencode-3a4d3b249f4b529ead2f80dd0df19a9cdc0c10a6.tar.gz opencode-3a4d3b249f4b529ead2f80dd0df19a9cdc0c10a6.zip | |
generate message type
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/client/gen/openapi.json | 326 | ||||
| -rw-r--r-- | pkg/client/generated-client.go | 405 |
2 files changed, 722 insertions, 9 deletions
diff --git a/pkg/client/gen/openapi.json b/pkg/client/gen/openapi.json index b7e40b7f9..41e16ad80 100644 --- a/pkg/client/gen/openapi.json +++ b/pkg/client/gen/openapi.json @@ -68,7 +68,12 @@ "description": "Successfully created session", "content": { "application/json": { - "schema": {} + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Session.Message" + } + } } } } @@ -173,12 +178,18 @@ "modelID": { "type": "string" }, - "parts": {} + "parts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Session.Message.Part" + } + } }, "required": [ "sessionID", "providerID", - "modelID" + "modelID", + "parts" ] } } @@ -250,6 +261,315 @@ "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": { "type": "object", "properties": { diff --git a/pkg/client/generated-client.go b/pkg/client/generated-client.go index 89d6a9273..14d2c56e6 100644 --- a/pkg/client/generated-client.go +++ b/pkg/client/generated-client.go @@ -12,6 +12,15 @@ import ( "net/http" "net/url" "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. @@ -43,12 +52,116 @@ type SessionInfo struct { } `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. 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. @@ -70,6 +183,286 @@ 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 + 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 type RequestEditorFn func(ctx context.Context, req *http.Request) error @@ -644,7 +1037,7 @@ func (r PostSessionListResponse) StatusCode() int { type PostSessionMessagesResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *interface{} + JSON200 *[]SessionMessage } // Status returns HTTPResponse.Status @@ -881,7 +1274,7 @@ func ParsePostSessionMessagesResponse(rsp *http.Response) (*PostSessionMessagesR switch { 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 { return nil, err } |
