mirror of
https://github.com/anomalyco/opencode-sdk-go.git
synced 2026-04-28 04:29:49 +00:00
feat(api): api update
This commit is contained in:
parent
3ba9a4c3e0
commit
2ed0800b2c
5 changed files with 92 additions and 39 deletions
|
|
@ -1,4 +1,4 @@
|
|||
configured_endpoints: 26
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-fb4caa8d0381531c44dd2d3c8c0b930b8c15a7bdde474d15bf7aeeb3b27aef56.yml
|
||||
openapi_spec_hash: 3a263e46f2369eeb2410430001c60d15
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-5748199af356c3243a46a466e73b5d0bab7eaa0c56895e1d0f903d637f61d0bb.yml
|
||||
openapi_spec_hash: c04f6b6be54b05d9b1283c24e870163b
|
||||
config_hash: 1ae82c93499b9f0b9ba828b8919f9cb3
|
||||
|
|
|
|||
4
api.md
4
api.md
|
|
@ -16,10 +16,6 @@ Methods:
|
|||
|
||||
# App
|
||||
|
||||
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#LogLevel">LogLevel</a>
|
||||
|
||||
Response 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#App">App</a>
|
||||
|
|
|
|||
38
app.go
38
app.go
|
|
@ -145,24 +145,6 @@ func (r appTimeJSON) RawJSON() string {
|
|||
return r.raw
|
||||
}
|
||||
|
||||
// Log level
|
||||
type LogLevel string
|
||||
|
||||
const (
|
||||
LogLevelDebug LogLevel = "debug"
|
||||
LogLevelInfo LogLevel = "info"
|
||||
LogLevelError LogLevel = "error"
|
||||
LogLevelWarn LogLevel = "warn"
|
||||
)
|
||||
|
||||
func (r LogLevel) IsKnown() bool {
|
||||
switch r {
|
||||
case LogLevelDebug, LogLevelInfo, LogLevelError, LogLevelWarn:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type Mode struct {
|
||||
Name string `json:"name,required"`
|
||||
Tools map[string]bool `json:"tools,required"`
|
||||
|
|
@ -352,7 +334,7 @@ func (r appProvidersResponseJSON) RawJSON() string {
|
|||
|
||||
type AppLogParams struct {
|
||||
// Log level
|
||||
Level param.Field[LogLevel] `json:"level,required"`
|
||||
Level param.Field[AppLogParamsLevel] `json:"level,required"`
|
||||
// Log message
|
||||
Message param.Field[string] `json:"message,required"`
|
||||
// Service name for the log entry
|
||||
|
|
@ -364,3 +346,21 @@ type AppLogParams struct {
|
|||
func (r AppLogParams) MarshalJSON() (data []byte, err error) {
|
||||
return apijson.MarshalRoot(r)
|
||||
}
|
||||
|
||||
// Log level
|
||||
type AppLogParamsLevel string
|
||||
|
||||
const (
|
||||
AppLogParamsLevelDebug AppLogParamsLevel = "debug"
|
||||
AppLogParamsLevelInfo AppLogParamsLevel = "info"
|
||||
AppLogParamsLevelError AppLogParamsLevel = "error"
|
||||
AppLogParamsLevelWarn AppLogParamsLevel = "warn"
|
||||
)
|
||||
|
||||
func (r AppLogParamsLevel) IsKnown() bool {
|
||||
switch r {
|
||||
case AppLogParamsLevelDebug, AppLogParamsLevelInfo, AppLogParamsLevelError, AppLogParamsLevelWarn:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func TestAppLogWithOptionalParams(t *testing.T) {
|
|||
option.WithBaseURL(baseURL),
|
||||
)
|
||||
_, err := client.App.Log(context.TODO(), opencode.AppLogParams{
|
||||
Level: opencode.F(opencode.LogLevelDebug),
|
||||
Level: opencode.F(opencode.AppLogParamsLevelDebug),
|
||||
Message: opencode.F("message"),
|
||||
Service: opencode.F("service"),
|
||||
Extra: opencode.F(map[string]interface{}{
|
||||
|
|
|
|||
83
session.go
83
session.go
|
|
@ -829,16 +829,19 @@ func (r MessageRole) IsKnown() bool {
|
|||
}
|
||||
|
||||
type Part struct {
|
||||
ID string `json:"id,required"`
|
||||
MessageID string `json:"messageID,required"`
|
||||
SessionID string `json:"sessionID,required"`
|
||||
Type PartType `json:"type,required"`
|
||||
CallID string `json:"callID"`
|
||||
Cost float64 `json:"cost"`
|
||||
Filename string `json:"filename"`
|
||||
Mime string `json:"mime"`
|
||||
Snapshot string `json:"snapshot"`
|
||||
Source FilePartSource `json:"source"`
|
||||
ID string `json:"id,required"`
|
||||
MessageID string `json:"messageID,required"`
|
||||
SessionID string `json:"sessionID,required"`
|
||||
Type PartType `json:"type,required"`
|
||||
CallID string `json:"callID"`
|
||||
Cost float64 `json:"cost"`
|
||||
Filename string `json:"filename"`
|
||||
// This field can have the runtime type of [[]string].
|
||||
Files interface{} `json:"files"`
|
||||
Hash string `json:"hash"`
|
||||
Mime string `json:"mime"`
|
||||
Snapshot string `json:"snapshot"`
|
||||
Source FilePartSource `json:"source"`
|
||||
// This field can have the runtime type of [ToolPartState].
|
||||
State interface{} `json:"state"`
|
||||
Synthetic bool `json:"synthetic"`
|
||||
|
|
@ -862,6 +865,8 @@ type partJSON struct {
|
|||
CallID apijson.Field
|
||||
Cost apijson.Field
|
||||
Filename apijson.Field
|
||||
Files apijson.Field
|
||||
Hash apijson.Field
|
||||
Mime apijson.Field
|
||||
Snapshot apijson.Field
|
||||
Source apijson.Field
|
||||
|
|
@ -893,13 +898,13 @@ func (r *Part) UnmarshalJSON(data []byte) (err error) {
|
|||
// for more type safety.
|
||||
//
|
||||
// Possible runtime types of the union are [TextPart], [FilePart], [ToolPart],
|
||||
// [StepStartPart], [StepFinishPart], [SnapshotPart].
|
||||
// [StepStartPart], [StepFinishPart], [SnapshotPart], [PartPatchPart].
|
||||
func (r Part) AsUnion() PartUnion {
|
||||
return r.union
|
||||
}
|
||||
|
||||
// Union satisfied by [TextPart], [FilePart], [ToolPart], [StepStartPart],
|
||||
// [StepFinishPart] or [SnapshotPart].
|
||||
// [StepFinishPart], [SnapshotPart] or [PartPatchPart].
|
||||
type PartUnion interface {
|
||||
implementsPart()
|
||||
}
|
||||
|
|
@ -938,9 +943,60 @@ func init() {
|
|||
Type: reflect.TypeOf(SnapshotPart{}),
|
||||
DiscriminatorValue: "snapshot",
|
||||
},
|
||||
apijson.UnionVariant{
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(PartPatchPart{}),
|
||||
DiscriminatorValue: "patch",
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
type PartPatchPart struct {
|
||||
ID string `json:"id,required"`
|
||||
Files []string `json:"files,required"`
|
||||
Hash string `json:"hash,required"`
|
||||
MessageID string `json:"messageID,required"`
|
||||
SessionID string `json:"sessionID,required"`
|
||||
Type PartPatchPartType `json:"type,required"`
|
||||
JSON partPatchPartJSON `json:"-"`
|
||||
}
|
||||
|
||||
// partPatchPartJSON contains the JSON metadata for the struct [PartPatchPart]
|
||||
type partPatchPartJSON struct {
|
||||
ID apijson.Field
|
||||
Files apijson.Field
|
||||
Hash apijson.Field
|
||||
MessageID apijson.Field
|
||||
SessionID apijson.Field
|
||||
Type apijson.Field
|
||||
raw string
|
||||
ExtraFields map[string]apijson.Field
|
||||
}
|
||||
|
||||
func (r *PartPatchPart) UnmarshalJSON(data []byte) (err error) {
|
||||
return apijson.UnmarshalRoot(data, r)
|
||||
}
|
||||
|
||||
func (r partPatchPartJSON) RawJSON() string {
|
||||
return r.raw
|
||||
}
|
||||
|
||||
func (r PartPatchPart) implementsPart() {}
|
||||
|
||||
type PartPatchPartType string
|
||||
|
||||
const (
|
||||
PartPatchPartTypePatch PartPatchPartType = "patch"
|
||||
)
|
||||
|
||||
func (r PartPatchPartType) IsKnown() bool {
|
||||
switch r {
|
||||
case PartPatchPartTypePatch:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type PartType string
|
||||
|
||||
const (
|
||||
|
|
@ -950,11 +1006,12 @@ const (
|
|||
PartTypeStepStart PartType = "step-start"
|
||||
PartTypeStepFinish PartType = "step-finish"
|
||||
PartTypeSnapshot PartType = "snapshot"
|
||||
PartTypePatch PartType = "patch"
|
||||
)
|
||||
|
||||
func (r PartType) IsKnown() bool {
|
||||
switch r {
|
||||
case PartTypeText, PartTypeFile, PartTypeTool, PartTypeStepStart, PartTypeStepFinish, PartTypeSnapshot:
|
||||
case PartTypeText, PartTypeFile, PartTypeTool, PartTypeStepStart, PartTypeStepFinish, PartTypeSnapshot, PartTypePatch:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue