mirror of
https://github.com/anomalyco/opencode.git
synced 2026-04-30 13:39:52 +00:00
implement nested tool calls and initial setup for result metadata
This commit is contained in:
parent
8d874b839d
commit
0697dcc1d9
14 changed files with 585 additions and 168 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package tools
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type ToolInfo struct {
|
||||
Name string
|
||||
|
|
@ -17,9 +20,10 @@ const (
|
|||
)
|
||||
|
||||
type ToolResponse struct {
|
||||
Type toolResponseType `json:"type"`
|
||||
Content string `json:"content"`
|
||||
IsError bool `json:"is_error"`
|
||||
Type toolResponseType `json:"type"`
|
||||
Content string `json:"content"`
|
||||
Metadata string `json:"metadata,omitempty"`
|
||||
IsError bool `json:"is_error"`
|
||||
}
|
||||
|
||||
func NewTextResponse(content string) ToolResponse {
|
||||
|
|
@ -29,6 +33,17 @@ func NewTextResponse(content string) ToolResponse {
|
|||
}
|
||||
}
|
||||
|
||||
func WithResponseMetadata(response ToolResponse, metadata any) ToolResponse {
|
||||
if metadata != nil {
|
||||
metadataBytes, err := json.Marshal(metadata)
|
||||
if err != nil {
|
||||
return response
|
||||
}
|
||||
response.Metadata = string(metadataBytes)
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
func NewTextErrorResponse(content string) ToolResponse {
|
||||
return ToolResponse{
|
||||
Type: ToolResponseTypeText,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue