mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-24 03:04:21 +01:00
wip: optional IDs in api (#1128)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
configured_endpoints: 22
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-8792f91dd070f7b4ee671fc86e8a03976dc7fb6ee49f8c99ad989e1597003774.yml
|
||||
openapi_spec_hash: fe9dc3a074be560de0b97df9b5af2c1b
|
||||
config_hash: b7f3d9742335715c458494988498b183
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-d34620b462127c45497743c97fd3569f9e629d9fbd97c0707087eeddbd4b3de1.yml
|
||||
openapi_spec_hash: 23864c98d555350fe56f1d0e56f205c5
|
||||
config_hash: a8441af7cb2db855d79fd372ee3b9fb1
|
||||
|
||||
@@ -77,8 +77,8 @@ Methods:
|
||||
|
||||
Params Types:
|
||||
|
||||
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FilePartParam">FilePartParam</a>
|
||||
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#TextPartParam">TextPartParam</a>
|
||||
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FilePartInputParam">FilePartInputParam</a>
|
||||
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#TextPartInputParam">TextPartInputParam</a>
|
||||
|
||||
Response Types:
|
||||
|
||||
|
||||
@@ -67,8 +67,8 @@ type Config struct {
|
||||
Model string `json:"model"`
|
||||
// Custom provider configurations and model overrides
|
||||
Provider map[string]ConfigProvider `json:"provider"`
|
||||
// Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables
|
||||
// all sharing
|
||||
// Control sharing behavior:'manual' allows manual sharing via commands, 'auto'
|
||||
// enables automatic sharing, 'disabled' disables all sharing
|
||||
Share ConfigShare `json:"share"`
|
||||
// Theme name to use for the interface
|
||||
Theme string `json:"theme"`
|
||||
@@ -206,6 +206,8 @@ type ConfigMcp struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
// This field can have the runtime type of [map[string]string].
|
||||
Environment interface{} `json:"environment"`
|
||||
// This field can have the runtime type of [map[string]string].
|
||||
Headers interface{} `json:"headers"`
|
||||
// URL of the remote MCP server
|
||||
URL string `json:"url"`
|
||||
JSON configMcpJSON `json:"-"`
|
||||
@@ -218,6 +220,7 @@ type configMcpJSON struct {
|
||||
Command apijson.Field
|
||||
Enabled apijson.Field
|
||||
Environment apijson.Field
|
||||
Headers apijson.Field
|
||||
URL apijson.Field
|
||||
raw string
|
||||
ExtraFields map[string]apijson.Field
|
||||
@@ -427,18 +430,19 @@ func (r configProviderModelsLimitJSON) RawJSON() string {
|
||||
return r.raw
|
||||
}
|
||||
|
||||
// Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables
|
||||
// all sharing
|
||||
// Control sharing behavior:'manual' allows manual sharing via commands, 'auto'
|
||||
// enables automatic sharing, 'disabled' disables all sharing
|
||||
type ConfigShare string
|
||||
|
||||
const (
|
||||
ConfigShareManual ConfigShare = "manual"
|
||||
ConfigShareAuto ConfigShare = "auto"
|
||||
ConfigShareDisabled ConfigShare = "disabled"
|
||||
)
|
||||
|
||||
func (r ConfigShare) IsKnown() bool {
|
||||
switch r {
|
||||
case ConfigShareAuto, ConfigShareDisabled:
|
||||
case ConfigShareManual, ConfigShareAuto, ConfigShareDisabled:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -509,9 +513,9 @@ type KeybindsConfig struct {
|
||||
SessionShare string `json:"session_share,required"`
|
||||
// Unshare current session
|
||||
SessionUnshare string `json:"session_unshare,required"`
|
||||
// Switch mode
|
||||
// Next mode
|
||||
SwitchMode string `json:"switch_mode,required"`
|
||||
// Switch mode reverse
|
||||
// Previous Mode
|
||||
SwitchModeReverse string `json:"switch_mode_reverse,required"`
|
||||
// List available themes
|
||||
ThemeList string `json:"theme_list,required"`
|
||||
@@ -638,7 +642,9 @@ type McpRemoteConfig struct {
|
||||
// URL of the remote MCP server
|
||||
URL string `json:"url,required"`
|
||||
// Enable or disable the MCP server on startup
|
||||
Enabled bool `json:"enabled"`
|
||||
Enabled bool `json:"enabled"`
|
||||
// Headers to send with the request
|
||||
Headers map[string]string `json:"headers"`
|
||||
JSON mcpRemoteConfigJSON `json:"-"`
|
||||
}
|
||||
|
||||
@@ -647,6 +653,7 @@ type mcpRemoteConfigJSON struct {
|
||||
Type apijson.Field
|
||||
URL apijson.Field
|
||||
Enabled apijson.Field
|
||||
Headers apijson.Field
|
||||
raw string
|
||||
ExtraFields map[string]apijson.Field
|
||||
}
|
||||
|
||||
@@ -481,21 +481,33 @@ func (r FilePartType) IsKnown() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type FilePartParam struct {
|
||||
ID param.Field[string] `json:"id,required"`
|
||||
MessageID param.Field[string] `json:"messageID,required"`
|
||||
Mime param.Field[string] `json:"mime,required"`
|
||||
SessionID param.Field[string] `json:"sessionID,required"`
|
||||
Type param.Field[FilePartType] `json:"type,required"`
|
||||
URL param.Field[string] `json:"url,required"`
|
||||
Filename param.Field[string] `json:"filename"`
|
||||
type FilePartInputParam struct {
|
||||
Mime param.Field[string] `json:"mime,required"`
|
||||
Type param.Field[FilePartInputType] `json:"type,required"`
|
||||
URL param.Field[string] `json:"url,required"`
|
||||
ID param.Field[string] `json:"id"`
|
||||
Filename param.Field[string] `json:"filename"`
|
||||
}
|
||||
|
||||
func (r FilePartParam) MarshalJSON() (data []byte, err error) {
|
||||
func (r FilePartInputParam) MarshalJSON() (data []byte, err error) {
|
||||
return apijson.MarshalRoot(r)
|
||||
}
|
||||
|
||||
func (r FilePartParam) implementsSessionChatParamsPartUnion() {}
|
||||
func (r FilePartInputParam) implementsSessionChatParamsPartUnion() {}
|
||||
|
||||
type FilePartInputType string
|
||||
|
||||
const (
|
||||
FilePartInputTypeFile FilePartInputType = "file"
|
||||
)
|
||||
|
||||
func (r FilePartInputType) IsKnown() bool {
|
||||
switch r {
|
||||
case FilePartInputTypeFile:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
ID string `json:"id,required"`
|
||||
@@ -1076,28 +1088,40 @@ func (r textPartTimeJSON) RawJSON() string {
|
||||
return r.raw
|
||||
}
|
||||
|
||||
type TextPartParam struct {
|
||||
ID param.Field[string] `json:"id,required"`
|
||||
MessageID param.Field[string] `json:"messageID,required"`
|
||||
SessionID param.Field[string] `json:"sessionID,required"`
|
||||
Text param.Field[string] `json:"text,required"`
|
||||
Type param.Field[TextPartType] `json:"type,required"`
|
||||
Synthetic param.Field[bool] `json:"synthetic"`
|
||||
Time param.Field[TextPartTimeParam] `json:"time"`
|
||||
type TextPartInputParam struct {
|
||||
Text param.Field[string] `json:"text,required"`
|
||||
Type param.Field[TextPartInputType] `json:"type,required"`
|
||||
ID param.Field[string] `json:"id"`
|
||||
Synthetic param.Field[bool] `json:"synthetic"`
|
||||
Time param.Field[TextPartInputTimeParam] `json:"time"`
|
||||
}
|
||||
|
||||
func (r TextPartParam) MarshalJSON() (data []byte, err error) {
|
||||
func (r TextPartInputParam) MarshalJSON() (data []byte, err error) {
|
||||
return apijson.MarshalRoot(r)
|
||||
}
|
||||
|
||||
func (r TextPartParam) implementsSessionChatParamsPartUnion() {}
|
||||
func (r TextPartInputParam) implementsSessionChatParamsPartUnion() {}
|
||||
|
||||
type TextPartTimeParam struct {
|
||||
type TextPartInputType string
|
||||
|
||||
const (
|
||||
TextPartInputTypeText TextPartInputType = "text"
|
||||
)
|
||||
|
||||
func (r TextPartInputType) IsKnown() bool {
|
||||
switch r {
|
||||
case TextPartInputTypeText:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type TextPartInputTimeParam struct {
|
||||
Start param.Field[float64] `json:"start,required"`
|
||||
End param.Field[float64] `json:"end"`
|
||||
}
|
||||
|
||||
func (r TextPartTimeParam) MarshalJSON() (data []byte, err error) {
|
||||
func (r TextPartInputTimeParam) MarshalJSON() (data []byte, err error) {
|
||||
return apijson.MarshalRoot(r)
|
||||
}
|
||||
|
||||
@@ -1574,11 +1598,11 @@ func (r sessionMessagesResponseJSON) RawJSON() string {
|
||||
}
|
||||
|
||||
type SessionChatParams struct {
|
||||
MessageID param.Field[string] `json:"messageID,required"`
|
||||
Mode param.Field[string] `json:"mode,required"`
|
||||
ModelID param.Field[string] `json:"modelID,required"`
|
||||
Parts param.Field[[]SessionChatParamsPartUnion] `json:"parts,required"`
|
||||
ProviderID param.Field[string] `json:"providerID,required"`
|
||||
MessageID param.Field[string] `json:"messageID"`
|
||||
Mode param.Field[string] `json:"mode"`
|
||||
}
|
||||
|
||||
func (r SessionChatParams) MarshalJSON() (data []byte, err error) {
|
||||
@@ -1586,10 +1610,8 @@ func (r SessionChatParams) MarshalJSON() (data []byte, err error) {
|
||||
}
|
||||
|
||||
type SessionChatParamsPart struct {
|
||||
ID param.Field[string] `json:"id,required"`
|
||||
MessageID param.Field[string] `json:"messageID,required"`
|
||||
SessionID param.Field[string] `json:"sessionID,required"`
|
||||
Type param.Field[SessionChatParamsPartsType] `json:"type,required"`
|
||||
ID param.Field[string] `json:"id"`
|
||||
Filename param.Field[string] `json:"filename"`
|
||||
Mime param.Field[string] `json:"mime"`
|
||||
Synthetic param.Field[bool] `json:"synthetic"`
|
||||
@@ -1604,7 +1626,8 @@ func (r SessionChatParamsPart) MarshalJSON() (data []byte, err error) {
|
||||
|
||||
func (r SessionChatParamsPart) implementsSessionChatParamsPartUnion() {}
|
||||
|
||||
// Satisfied by [FilePartParam], [TextPartParam], [SessionChatParamsPart].
|
||||
// Satisfied by [TextPartInputParam], [FilePartInputParam],
|
||||
// [SessionChatParamsPart].
|
||||
type SessionChatParamsPartUnion interface {
|
||||
implementsSessionChatParamsPartUnion()
|
||||
}
|
||||
@@ -1612,13 +1635,13 @@ type SessionChatParamsPartUnion interface {
|
||||
type SessionChatParamsPartsType string
|
||||
|
||||
const (
|
||||
SessionChatParamsPartsTypeFile SessionChatParamsPartsType = "file"
|
||||
SessionChatParamsPartsTypeText SessionChatParamsPartsType = "text"
|
||||
SessionChatParamsPartsTypeFile SessionChatParamsPartsType = "file"
|
||||
)
|
||||
|
||||
func (r SessionChatParamsPartsType) IsKnown() bool {
|
||||
switch r {
|
||||
case SessionChatParamsPartsTypeFile, SessionChatParamsPartsTypeText:
|
||||
case SessionChatParamsPartsTypeText, SessionChatParamsPartsTypeFile:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -101,7 +101,7 @@ func TestSessionAbort(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionChat(t *testing.T) {
|
||||
func TestSessionChatWithOptionalParams(t *testing.T) {
|
||||
t.Skip("skipped: tests are disabled for the time being")
|
||||
baseURL := "http://localhost:4010"
|
||||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
|
||||
@@ -117,19 +117,20 @@ func TestSessionChat(t *testing.T) {
|
||||
context.TODO(),
|
||||
"id",
|
||||
opencode.SessionChatParams{
|
||||
MessageID: opencode.F("messageID"),
|
||||
Mode: opencode.F("mode"),
|
||||
ModelID: opencode.F("modelID"),
|
||||
Parts: opencode.F([]opencode.SessionChatParamsPartUnion{opencode.FilePartParam{
|
||||
ModelID: opencode.F("modelID"),
|
||||
Parts: opencode.F([]opencode.SessionChatParamsPartUnion{opencode.TextPartInputParam{
|
||||
Text: opencode.F("text"),
|
||||
Type: opencode.F(opencode.TextPartInputTypeText),
|
||||
ID: opencode.F("id"),
|
||||
MessageID: opencode.F("messageID"),
|
||||
Mime: opencode.F("mime"),
|
||||
SessionID: opencode.F("sessionID"),
|
||||
Type: opencode.F(opencode.FilePartTypeFile),
|
||||
URL: opencode.F("url"),
|
||||
Filename: opencode.F("filename"),
|
||||
Synthetic: opencode.F(true),
|
||||
Time: opencode.F(opencode.TextPartInputTimeParam{
|
||||
Start: opencode.F(0.000000),
|
||||
End: opencode.F(0.000000),
|
||||
}),
|
||||
}}),
|
||||
ProviderID: opencode.F("providerID"),
|
||||
MessageID: opencode.F("msg"),
|
||||
Mode: opencode.F("mode"),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user