mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-19 08:44:22 +01:00
slash commands (#2157)
Co-authored-by: adamdotdevin <2363879+adamdottv@users.noreply.github.com>
This commit is contained in:
@@ -114,6 +114,18 @@ func (r *SessionService) Children(ctx context.Context, id string, opts ...option
|
||||
return
|
||||
}
|
||||
|
||||
// Send a new command to a session
|
||||
func (r *SessionService) Command(ctx context.Context, id string, body SessionCommandParams, opts ...option.RequestOption) (res *SessionCommandResponse, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
}
|
||||
path := fmt.Sprintf("session/%s/command", id)
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
|
||||
return
|
||||
}
|
||||
|
||||
// Get session
|
||||
func (r *SessionService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
@@ -2301,6 +2313,29 @@ func (r sessionChatResponseJSON) RawJSON() string {
|
||||
return r.raw
|
||||
}
|
||||
|
||||
type SessionCommandResponse struct {
|
||||
Info AssistantMessage `json:"info,required"`
|
||||
Parts []Part `json:"parts,required"`
|
||||
JSON sessionCommandResponseJSON `json:"-"`
|
||||
}
|
||||
|
||||
// sessionCommandResponseJSON contains the JSON metadata for the struct
|
||||
// [SessionCommandResponse]
|
||||
type sessionCommandResponseJSON struct {
|
||||
Info apijson.Field
|
||||
Parts apijson.Field
|
||||
raw string
|
||||
ExtraFields map[string]apijson.Field
|
||||
}
|
||||
|
||||
func (r *SessionCommandResponse) UnmarshalJSON(data []byte) (err error) {
|
||||
return apijson.UnmarshalRoot(data, r)
|
||||
}
|
||||
|
||||
func (r sessionCommandResponseJSON) RawJSON() string {
|
||||
return r.raw
|
||||
}
|
||||
|
||||
type SessionMessageResponse struct {
|
||||
Info Message `json:"info,required"`
|
||||
Parts []Part `json:"parts,required"`
|
||||
@@ -2419,6 +2454,18 @@ func (r SessionChatParamsPartsType) IsKnown() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type SessionCommandParams struct {
|
||||
Arguments param.Field[string] `json:"arguments,required"`
|
||||
Command param.Field[string] `json:"command,required"`
|
||||
Agent param.Field[string] `json:"agent"`
|
||||
MessageID param.Field[string] `json:"messageID"`
|
||||
Model param.Field[string] `json:"model"`
|
||||
}
|
||||
|
||||
func (r SessionCommandParams) MarshalJSON() (data []byte, err error) {
|
||||
return apijson.MarshalRoot(r)
|
||||
}
|
||||
|
||||
type SessionInitParams struct {
|
||||
MessageID param.Field[string] `json:"messageID,required"`
|
||||
ModelID param.Field[string] `json:"modelID,required"`
|
||||
|
||||
Reference in New Issue
Block a user