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
b38248d597
commit
98a83504f7
3 changed files with 69 additions and 62 deletions
|
|
@ -1,4 +1,4 @@
|
|||
configured_endpoints: 22
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-05150c78e0e6e97b0ce97ed685ebcf1cb01dc839beccb99e9d3ead5b783cfd47.yml
|
||||
openapi_spec_hash: 833a5b6d53d98dc2beac2c4c394b20d5
|
||||
config_hash: bfc82d11ce9b808a15a860a9222ad78e
|
||||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-7270b9e4859010d6680bcc92afcd6f7c679d80a2645f65d7097d19ce2e8cdc5a.yml
|
||||
openapi_spec_hash: 5fcbfaedebfea62c17c74437a9728b04
|
||||
config_hash: 931828b5dd9393834a3c1703e02e02b0
|
||||
|
|
|
|||
1
api.md
1
api.md
|
|
@ -85,6 +85,7 @@ 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#Message">Message</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#Part">Part</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#Session">Session</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#SnapshotPart">SnapshotPart</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#StepFinishPart">StepFinishPart</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#StepStartPart">StepStartPart</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#TextPart">TextPart</a>
|
||||
|
|
|
|||
124
session.go
124
session.go
|
|
@ -659,13 +659,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], [PartObject].
|
||||
// [StepStartPart], [StepFinishPart], [SnapshotPart].
|
||||
func (r Part) AsUnion() PartUnion {
|
||||
return r.union
|
||||
}
|
||||
|
||||
// Union satisfied by [TextPart], [FilePart], [ToolPart], [StepStartPart],
|
||||
// [StepFinishPart] or [PartObject].
|
||||
// [StepFinishPart] or [SnapshotPart].
|
||||
type PartUnion interface {
|
||||
implementsPart()
|
||||
}
|
||||
|
|
@ -673,78 +673,40 @@ type PartUnion interface {
|
|||
func init() {
|
||||
apijson.RegisterUnion(
|
||||
reflect.TypeOf((*PartUnion)(nil)).Elem(),
|
||||
"",
|
||||
"type",
|
||||
apijson.UnionVariant{
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(TextPart{}),
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(TextPart{}),
|
||||
DiscriminatorValue: "text",
|
||||
},
|
||||
apijson.UnionVariant{
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(FilePart{}),
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(FilePart{}),
|
||||
DiscriminatorValue: "file",
|
||||
},
|
||||
apijson.UnionVariant{
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(ToolPart{}),
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(ToolPart{}),
|
||||
DiscriminatorValue: "tool",
|
||||
},
|
||||
apijson.UnionVariant{
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(StepStartPart{}),
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(StepStartPart{}),
|
||||
DiscriminatorValue: "step-start",
|
||||
},
|
||||
apijson.UnionVariant{
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(StepFinishPart{}),
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(StepFinishPart{}),
|
||||
DiscriminatorValue: "step-finish",
|
||||
},
|
||||
apijson.UnionVariant{
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(PartObject{}),
|
||||
TypeFilter: gjson.JSON,
|
||||
Type: reflect.TypeOf(SnapshotPart{}),
|
||||
DiscriminatorValue: "snapshot",
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
type PartObject struct {
|
||||
ID string `json:"id,required"`
|
||||
MessageID string `json:"messageID,required"`
|
||||
SessionID string `json:"sessionID,required"`
|
||||
Snapshot string `json:"snapshot,required"`
|
||||
Type PartObjectType `json:"type,required"`
|
||||
JSON partObjectJSON `json:"-"`
|
||||
}
|
||||
|
||||
// partObjectJSON contains the JSON metadata for the struct [PartObject]
|
||||
type partObjectJSON struct {
|
||||
ID apijson.Field
|
||||
MessageID apijson.Field
|
||||
SessionID apijson.Field
|
||||
Snapshot apijson.Field
|
||||
Type apijson.Field
|
||||
raw string
|
||||
ExtraFields map[string]apijson.Field
|
||||
}
|
||||
|
||||
func (r *PartObject) UnmarshalJSON(data []byte) (err error) {
|
||||
return apijson.UnmarshalRoot(data, r)
|
||||
}
|
||||
|
||||
func (r partObjectJSON) RawJSON() string {
|
||||
return r.raw
|
||||
}
|
||||
|
||||
func (r PartObject) implementsPart() {}
|
||||
|
||||
type PartObjectType string
|
||||
|
||||
const (
|
||||
PartObjectTypeSnapshot PartObjectType = "snapshot"
|
||||
)
|
||||
|
||||
func (r PartObjectType) IsKnown() bool {
|
||||
switch r {
|
||||
case PartObjectTypeSnapshot:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type PartType string
|
||||
|
||||
const (
|
||||
|
|
@ -862,6 +824,50 @@ func (r sessionShareJSON) RawJSON() string {
|
|||
return r.raw
|
||||
}
|
||||
|
||||
type SnapshotPart struct {
|
||||
ID string `json:"id,required"`
|
||||
MessageID string `json:"messageID,required"`
|
||||
SessionID string `json:"sessionID,required"`
|
||||
Snapshot string `json:"snapshot,required"`
|
||||
Type SnapshotPartType `json:"type,required"`
|
||||
JSON snapshotPartJSON `json:"-"`
|
||||
}
|
||||
|
||||
// snapshotPartJSON contains the JSON metadata for the struct [SnapshotPart]
|
||||
type snapshotPartJSON struct {
|
||||
ID apijson.Field
|
||||
MessageID apijson.Field
|
||||
SessionID apijson.Field
|
||||
Snapshot apijson.Field
|
||||
Type apijson.Field
|
||||
raw string
|
||||
ExtraFields map[string]apijson.Field
|
||||
}
|
||||
|
||||
func (r *SnapshotPart) UnmarshalJSON(data []byte) (err error) {
|
||||
return apijson.UnmarshalRoot(data, r)
|
||||
}
|
||||
|
||||
func (r snapshotPartJSON) RawJSON() string {
|
||||
return r.raw
|
||||
}
|
||||
|
||||
func (r SnapshotPart) implementsPart() {}
|
||||
|
||||
type SnapshotPartType string
|
||||
|
||||
const (
|
||||
SnapshotPartTypeSnapshot SnapshotPartType = "snapshot"
|
||||
)
|
||||
|
||||
func (r SnapshotPartType) IsKnown() bool {
|
||||
switch r {
|
||||
case SnapshotPartTypeSnapshot:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type StepFinishPart struct {
|
||||
ID string `json:"id,required"`
|
||||
Cost float64 `json:"cost,required"`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue