Documentation
¶
Overview ¶
Package core defines protocol-level types shared across Whale subsystems.
Keep this package limited to stable data structures and pure helpers with no filesystem, network, UI, or agent runtime side effects. Business flow belongs in agent/app/tools/tui packages instead of here.
Index ¶
- Constants
- func AsAnySlice(v any) []any
- func AsString(v any) string
- func ContainsArg(argv []string, want string) bool
- func ExtractProposedPlanText(text string) (string, bool)
- func FirstLine(s string) string
- func FirstNonEmpty(values ...string) string
- func FlattenSchemaForModel(parameters map[string]any) map[string]any
- func IsReadOnlyToolCall(spec ToolSpec, call ToolCall) bool
- func IsSessionJSONLName(name string) bool
- func MarshalToolEnvelope(env ToolEnvelope) (string, error)
- func PathInside(path, parent string) (bool, error)
- func RenestFlatInputForSpec(spec ToolSpec, raw string) (string, bool)
- func SanitizeSessionID(v string) string
- func ShouldFlattenSchema(parameters map[string]any) bool
- func SkillNameDisabled(name string, disabled []string) bool
- func StripProposedPlanBlocks(text string) string
- func WithToolResultArchive(ctx context.Context, dir, sessionID string) context.Context
- type FinishReason
- type Message
- type ProposedPlanParser
- type ProposedPlanSegment
- type ProposedPlanSegmentKind
- type Role
- type SubagentStep
- type Tool
- type ToolApprovalHint
- type ToolCall
- type ToolCapabilities
- type ToolDescriber
- type ToolEnvelope
- type ToolInputRepair
- type ToolParamSpec
- type ToolPreviewer
- type ToolProgress
- type ToolProgressRunner
- type ToolReadOnly
- type ToolReadOnlyCheck
- type ToolRegistry
- func (r *ToolRegistry) Dispatch(ctx context.Context, call ToolCall) (ToolResult, error)
- func (r *ToolRegistry) DispatchWithProgress(ctx context.Context, call ToolCall, progress func(ToolProgress)) (ToolResult, error)
- func (r *ToolRegistry) Get(name string) Tool
- func (r *ToolRegistry) ReplaceTools(tools []Tool) error
- func (r *ToolRegistry) SetMaxResultChars(limit int)
- func (r *ToolRegistry) Snapshot() *ToolRegistry
- func (r *ToolRegistry) Spec(name string) (ToolSpec, bool)
- func (r *ToolRegistry) Specs() []ToolSpec
- func (r *ToolRegistry) Tools() []Tool
- type ToolResult
- type ToolSpec
- type ToolSupportsParallel
- type UserInputAnswer
- type UserInputOption
- type UserInputQuestion
- type UserInputRequest
- type UserInputResponse
Constants ¶
const ( ProposedPlanOpenTag = "<proposed_plan>" ProposedPlanCloseTag = "</proposed_plan>" )
const ( // ToolInputEventsSuffix is the filename suffix for tool input event logs. ToolInputEventsSuffix = ".tool_input_events.jsonl" // ApprovalEventsSuffix is the filename suffix for approval event logs. ApprovalEventsSuffix = ".approval_events.jsonl" )
const ( ToolInputRepairNullOptionalOmitted = "null_optional_omitted" ToolInputRepairStringifiedArray = "stringified_array" ToolInputRepairBareStringToArray = "bare_string_to_array" ToolInputRepairEmptyObjectToArray = "empty_object_to_array" ToolInputRepairMarkdownAutolinkPath = "markdown_autolink_path" )
const DefaultMaxToolResultChars = 32 * 1024
Variables ¶
This section is empty.
Functions ¶
func AsAnySlice ¶ added in v0.1.24
AsAnySlice extracts a []any value, returning nil on mismatch or nil input.
func AsString ¶ added in v0.1.24
AsString extracts a string value from any type, returning empty string on mismatch.
func ContainsArg ¶ added in v0.1.24
ContainsArg reports whether want is present in argv.
func ExtractProposedPlanText ¶
func FirstLine ¶ added in v0.1.24
FirstLine returns the first line of s (up to the first newline), trimmed. Returns the full trimmed input if there is no newline.
func FirstNonEmpty ¶ added in v0.1.24
FirstNonEmpty returns the first non-empty (after trimming whitespace) variadic string argument. Returns "" if all values are empty.
func FlattenSchemaForModel ¶
FlattenSchemaForModel flattens nested object properties into dotted keys (for example: payload.path) to reduce nested JSON generation errors.
func IsReadOnlyToolCall ¶
func IsSessionJSONLName ¶ added in v0.1.24
IsSessionJSONLName reports whether name is a session JSONL file (not tool input or approval events).
func MarshalToolEnvelope ¶
func MarshalToolEnvelope(env ToolEnvelope) (string, error)
func PathInside ¶ added in v0.1.24
PathInside reports whether path is inside parent (or equal to parent), resolving symlinks through the nearest existing ancestor for accurate boundary checking even when the final path does not exist yet.
func RenestFlatInputForSpec ¶
RenestFlatInputForSpec turns dotted keys back into nested objects when the tool schema is flattened for model interaction.
func SanitizeSessionID ¶ added in v0.1.24
SanitizeSessionID sanitizes a session ID for use in filenames. Non-alphanumeric characters (except - and _) are replaced with _.
func ShouldFlattenSchema ¶
ShouldFlattenSchema reports whether a tool schema is deep/wide enough to benefit from flattened argument keys for model-side tool calling.
func SkillNameDisabled ¶ added in v0.1.24
SkillNameDisabled reports whether name is in the disabled list. Comparison is case-insensitive with whitespace trimmed.
func StripProposedPlanBlocks ¶
Types ¶
type FinishReason ¶
type FinishReason string
const ( FinishReasonEndTurn FinishReason = "end_turn" FinishReasonToolUse FinishReason = "tool_use" FinishReasonCanceled FinishReason = "canceled" FinishReasonError FinishReason = "error" )
type ProposedPlanParser ¶
type ProposedPlanParser struct {
// contains filtered or unexported fields
}
func (*ProposedPlanParser) Finish ¶
func (p *ProposedPlanParser) Finish() []ProposedPlanSegment
func (*ProposedPlanParser) Parse ¶
func (p *ProposedPlanParser) Parse(delta string) []ProposedPlanSegment
type ProposedPlanSegment ¶
type ProposedPlanSegment struct {
Kind ProposedPlanSegmentKind
Text string
}
type ProposedPlanSegmentKind ¶
type ProposedPlanSegmentKind string
const ( ProposedPlanSegmentNormal ProposedPlanSegmentKind = "normal" ProposedPlanSegmentStart ProposedPlanSegmentKind = "start" ProposedPlanSegmentDelta ProposedPlanSegmentKind = "delta" ProposedPlanSegmentEnd ProposedPlanSegmentKind = "end" )
type SubagentStep ¶ added in v0.1.24
type ToolApprovalHint ¶
type ToolApprovalHint interface {
ApprovalHint() string
}
type ToolCapabilities ¶
type ToolCapabilities interface {
Capabilities() []string
}
type ToolDescriber ¶
type ToolDescriber interface {
Description() string
}
type ToolEnvelope ¶
type ToolEnvelope struct {
OK bool `json:"ok"`
Success bool `json:"success"`
Error string `json:"error,omitempty"`
Message string `json:"message,omitempty"`
Code string `json:"code,omitempty"`
Summary string `json:"summary,omitempty"`
Data map[string]any `json:"data,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Meta map[string]any `json:"meta,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
func NewToolErrorEnvelope ¶
func NewToolErrorEnvelope(code, message string) ToolEnvelope
func NewToolSuccessEnvelope ¶
func NewToolSuccessEnvelope(data map[string]any) ToolEnvelope
func ParseToolEnvelope ¶
func ParseToolEnvelope(raw string) (ToolEnvelope, bool)
type ToolInputRepair ¶ added in v0.1.10
func RepairToolInputForSpec ¶ added in v0.1.10
func RepairToolInputForSpec(spec ToolSpec, raw string) (string, []ToolInputRepair)
RepairToolInputForSpec applies narrowly scoped, schema-guided repairs to common tool-call argument shape mistakes. Valid inputs are returned unchanged.
type ToolParamSpec ¶
type ToolPreviewer ¶ added in v0.1.2
type ToolProgress ¶ added in v0.1.5
type ToolProgressRunner ¶ added in v0.1.5
type ToolProgressRunner interface {
RunWithProgress(ctx context.Context, call ToolCall, progress func(ToolProgress)) (ToolResult, error)
}
type ToolReadOnly ¶
type ToolReadOnly interface {
ReadOnly() bool
}
type ToolReadOnlyCheck ¶
type ToolRegistry ¶
type ToolRegistry struct {
// contains filtered or unexported fields
}
func NewToolRegistry ¶
func NewToolRegistry(tools []Tool) *ToolRegistry
func NewToolRegistryChecked ¶
func NewToolRegistryChecked(tools []Tool) (*ToolRegistry, error)
func (*ToolRegistry) Dispatch ¶
func (r *ToolRegistry) Dispatch(ctx context.Context, call ToolCall) (ToolResult, error)
func (*ToolRegistry) DispatchWithProgress ¶ added in v0.1.5
func (r *ToolRegistry) DispatchWithProgress(ctx context.Context, call ToolCall, progress func(ToolProgress)) (ToolResult, error)
func (*ToolRegistry) Get ¶
func (r *ToolRegistry) Get(name string) Tool
func (*ToolRegistry) ReplaceTools ¶ added in v0.1.6
func (r *ToolRegistry) ReplaceTools(tools []Tool) error
func (*ToolRegistry) SetMaxResultChars ¶
func (r *ToolRegistry) SetMaxResultChars(limit int)
func (*ToolRegistry) Snapshot ¶ added in v0.1.23
func (r *ToolRegistry) Snapshot() *ToolRegistry
func (*ToolRegistry) Specs ¶
func (r *ToolRegistry) Specs() []ToolSpec
func (*ToolRegistry) Tools ¶
func (r *ToolRegistry) Tools() []Tool
type ToolResult ¶
type ToolSpec ¶
type ToolSpec struct {
Name string
Description string
Parameters map[string]any
ReadOnly bool
ReadOnlyCheck func(args map[string]any) bool
Capabilities []string
ApprovalHint string
SupportsParallel bool
}
func DescribeTool ¶
type ToolSupportsParallel ¶
type ToolSupportsParallel interface {
SupportsParallel() bool
}
type UserInputAnswer ¶
type UserInputOption ¶
type UserInputQuestion ¶
type UserInputQuestion struct {
Header string `json:"header"`
ID string `json:"id"`
Question string `json:"question"`
Options []UserInputOption `json:"options"`
}
type UserInputRequest ¶
type UserInputRequest struct {
Questions []UserInputQuestion `json:"questions"`
}
type UserInputResponse ¶
type UserInputResponse struct {
Answers []UserInputAnswer `json:"answers"`
}