Documentation
¶
Index ¶
- Constants
- func AreModelsCompatible(apiType, model1, model2 string) bool
- type AIChat
- type AIMessage
- type AIMessagePart
- type AIMetrics
- type AIOptsType
- type AIToolResult
- type AIUsage
- type GenAIMessage
- type ProxyErrorResponse
- type RateLimitInfo
- type StopReasonKind
- type ToolDefinition
- type UIChat
- type UIMessage
- type UIMessageDataToolUse
- type UIMessageDataUserFile
- type UIMessagePart
- type UseChatRequest
- type UseChatStreamPart
- type WaveChatOpts
- type WaveContinueResponse
- type WaveStopReason
- type WaveToolCall
Constants ¶
const ( ThinkingLevelLow = "low" ThinkingLevelMedium = "medium" ThinkingLevelHigh = "high" )
const ( ToolUseStatusPending = "pending" ToolUseStatusError = "error" ToolUseStatusCompleted = "completed" )
const ( ApprovalNeedsApproval = "needs-approval" ApprovalUserApproved = "user-approved" ApprovalUserDenied = "user-denied" ApprovalTimeout = "timeout" ApprovalAutoApproved = "auto-approved" )
const ( AIMessagePartTypeText = "text" AIMessagePartTypeFile = "file" )
const DefaultAnthropicModel = "claude-sonnet-4-5"
const DefaultOpenAIModel = "gpt-5-mini"
const PremiumOpenAIModel = "gpt-5"
Variables ¶
This section is empty.
Functions ¶
func AreModelsCompatible ¶
Types ¶
type AIChat ¶
type AIChat struct {
ChatId string `json:"chatid"`
APIType string `json:"apitype"`
Model string `json:"model"`
APIVersion string `json:"apiversion"`
NativeMessages []GenAIMessage `json:"nativemessages"`
}
type AIMessage ¶
type AIMessage struct {
MessageId string `json:"messageid"` // only for idempotency
Parts []AIMessagePart `json:"parts"`
}
wave specific for POSTing a new message to a convo
func (*AIMessage) GetMessageId ¶
type AIMessagePart ¶
type AIMessagePart struct {
Type string `json:"type"` // "text", "file"
// for "text"
Text string `json:"text,omitempty"`
// for "file"
// mimetype is required, filename is not
// either data or url (not both) must be set
// url must be either an "https" or "data" url
FileName string `json:"filename,omitempty"`
MimeType string `json:"mimetype,omitempty"` // required
Data []byte `json:"data,omitempty"` // raw data (base64 on wire)
URL string `json:"url,omitempty"`
Size int `json:"size,omitempty"`
PreviewUrl string `json:"previewurl,omitempty"` // 128x128 webp data url for images
}
func (*AIMessagePart) Validate ¶
func (p *AIMessagePart) Validate() error
type AIMetrics ¶
type AIMetrics struct {
Usage AIUsage `json:"usage"`
RequestCount int `json:"requestcount"`
ToolUseCount int `json:"toolusecount"`
ToolUseErrorCount int `json:"tooluseerrorcount"`
ToolDetail map[string]int `json:"tooldetail,omitempty"`
PremiumReqCount int `json:"premiumreqcount"`
ProxyReqCount int `json:"proxyreqcount"`
HadError bool `json:"haderror"`
ImageCount int `json:"imagecount"`
PDFCount int `json:"pdfcount"`
TextDocCount int `json:"textdoccount"`
TextLen int `json:"textlen"`
FirstByteLatency int `json:"firstbytelatency"` // ms
RequestDuration int `json:"requestduration"` // ms
WidgetAccess bool `json:"widgetaccess"`
}
type AIOptsType ¶
type AIOptsType struct {
APIType string `json:"apitype,omitempty"`
Model string `json:"model"`
APIToken string `json:"apitoken"`
OrgID string `json:"orgid,omitempty"`
APIVersion string `json:"apiversion,omitempty"`
BaseURL string `json:"baseurl,omitempty"`
ProxyURL string `json:"proxyurl,omitempty"`
MaxTokens int `json:"maxtokens,omitempty"`
TimeoutMs int `json:"timeoutms,omitempty"`
ThinkingLevel string `json:"thinkinglevel,omitempty"` // ThinkingLevelLow, ThinkingLevelMedium, or ThinkingLevelHigh
}
Wave Specific AI opts for configuration
func (AIOptsType) IsPremiumModel ¶
func (opts AIOptsType) IsPremiumModel() bool
func (AIOptsType) IsWaveProxy ¶
func (opts AIOptsType) IsWaveProxy() bool
type AIToolResult ¶
type GenAIMessage ¶
GenAIMessage interface for messages stored in conversations All messages must have a unique identifier for idempotency checks
type ProxyErrorResponse ¶
type RateLimitInfo ¶
type RateLimitInfo struct {
Req int `json:"req"`
ReqLimit int `json:"reqlimit"`
PReq int `json:"preq"`
PReqLimit int `json:"preqlimit"`
ResetEpoch int64 `json:"resetepoch"`
Unknown bool `json:"unknown,omitempty"`
}
func ParseRateLimitHeader ¶
func ParseRateLimitHeader(header string) *RateLimitInfo
ParseRateLimitHeader parses the X-Wave-RateLimit header Format: X-Wave-RateLimit: req=<remaining>, reqlimit=<max_requests>, preq=<premium_remaining>, preqlimit=<max_premium>, reset=<expiration_epoch_seconds> Example: X-Wave-RateLimit: req=180, reqlimit=200, preq=45, preqlimit=50, reset=1727818382 - req: remaining regular requests in the current window - reqlimit: maximum regular requests allowed in the window - preq: remaining premium requests in the current window - preqlimit: maximum premium requests allowed in the window - reset: unix timestamp (epoch seconds) when the rate limit window resets
type StopReasonKind ¶
type StopReasonKind string
const ( StopKindDone StopReasonKind = "done" StopKindToolUse StopReasonKind = "tool_use" StopKindMaxTokens StopReasonKind = "max_tokens" StopKindContent StopReasonKind = "content_filter" StopKindCanceled StopReasonKind = "canceled" StopKindError StopReasonKind = "error" StopKindPauseTurn StopReasonKind = "pause_turn" StopKindPremiumRateLimit StopReasonKind = "premium_rate_limit" StopKindRateLimit StopReasonKind = "rate_limit" )
type ToolDefinition ¶
type ToolDefinition struct {
Name string `json:"name"`
DisplayName string `json:"displayname,omitempty"` // internal field (cannot marshal to API, must be stripped)
Description string `json:"description"`
ShortDescription string `json:"shortdescription,omitempty"` // internal field (cannot marshal to API, must be stripped)
ToolLogName string `json:"-"` // short name for telemetry (e.g., "term:getscrollback")
InputSchema map[string]any `json:"input_schema"`
Strict bool `json:"strict,omitempty"`
ToolTextCallback func(any) (string, error) `json:"-"`
ToolAnyCallback func(any, *UIMessageDataToolUse) (any, error) `json:"-"` // *UIMessageDataToolUse will NOT be nil
ToolCallDesc func(any, any, *UIMessageDataToolUse) string `json:"-"` // passed input, output (may be nil), *UIMessageDataToolUse (may be nil)
ToolApproval func(any) string `json:"-"`
ToolVerifyInput func(any, *UIMessageDataToolUse) error `json:"-"` // *UIMessageDataToolUse will NOT be nil
}
ToolDefinition represents a tool that can be used by the AI model
func (*ToolDefinition) Clean ¶
func (td *ToolDefinition) Clean() *ToolDefinition
func (*ToolDefinition) Desc ¶
func (td *ToolDefinition) Desc() string
type UIMessage ¶
type UIMessage struct {
ID string `json:"id"`
Role string `json:"role"` // "system", "user", "assistant"
Metadata any `json:"metadata,omitempty"`
Parts []UIMessagePart `json:"parts,omitempty"`
}
func (*UIMessage) GetContent ¶
GetContent extracts the text content from the parts array
type UIMessageDataToolUse ¶
type UIMessageDataToolUse struct {
ToolCallId string `json:"toolcallid"`
ToolName string `json:"toolname"`
ToolDesc string `json:"tooldesc"`
Status string `json:"status"`
RunTs int64 `json:"runts,omitempty"`
ErrorMessage string `json:"errormessage,omitempty"`
Approval string `json:"approval,omitempty"`
BlockId string `json:"blockid,omitempty"`
WriteBackupFileName string `json:"writebackupfilename,omitempty"`
InputFileName string `json:"inputfilename,omitempty"`
}
when updating this struct, also modify frontend/app/aipanel/aitypes.ts WaveUIDataTypes.tooluse
func (*UIMessageDataToolUse) IsApproved ¶
func (d *UIMessageDataToolUse) IsApproved() bool
type UIMessageDataUserFile ¶
type UIMessageDataUserFile struct {
FileName string `json:"filename,omitempty"`
Size int `json:"size,omitempty"`
MimeType string `json:"mimetype,omitempty"`
PreviewUrl string `json:"previewurl,omitempty"`
}
when updating this struct, also modify frontend/app/aipanel/aitypes.ts WaveUIDataTypes.userfile
type UIMessagePart ¶
type UIMessagePart struct {
// text, reasoning, tool-[toolname], source-url, source-document, file, data-[dataname], step-start
Type string `json:"type"`
// TextUIPart & ReasoningUIPart
Text string `json:"text,omitempty"`
// State field:
// - For "text"/"reasoning" types: optional, values are "streaming" or "done"
// - For "tool-*" types: required, values are "input-streaming", "input-available", "output-available", or "output-error"
State string `json:"state,omitempty"`
// ToolUIPart
ToolCallID string `json:"toolCallId,omitempty"`
Input any `json:"input,omitempty"`
Output any `json:"output,omitempty"`
ErrorText string `json:"errorText,omitempty"`
ProviderExecuted *bool `json:"providerExecuted,omitempty"`
// SourceUrlUIPart & SourceDocumentUIPart
SourceID string `json:"sourceId,omitempty"`
URL string `json:"url,omitempty"`
Title string `json:"title,omitempty"`
Filename string `json:"filename,omitempty"`
MediaType string `json:"mediaType,omitempty"`
// DataUIPart
ID string `json:"id,omitempty"`
Data any `json:"data,omitempty"`
// Provider metadata (ReasoningUIPart, SourceUrlUIPart, SourceDocumentUIPart)
ProviderMetadata map[string]any `json:"providerMetadata,omitempty"`
}
type UseChatRequest ¶
type UseChatRequest struct {
Messages []UIMessage `json:"messages"`
}
type UseChatStreamPart ¶
type UseChatStreamPart struct {
Type string `json:"type"`
// Text
Text string `json:"text,omitempty"`
// Reasoning
Delta string `json:"delta,omitempty"`
// Source parts
SourceID string `json:"sourceId,omitempty"`
URL string `json:"url,omitempty"` // also for file urls
MediaType string `json:"mediaType,omitempty"` // also for file types
Title string `json:"title,omitempty"`
// Data (custom data-\*)
Data any `json:"data,omitempty"`
// Tool use / tool result
ToolCallID string `json:"toolCallId,omitempty"`
ToolName string `json:"toolName,omitempty"`
Input any `json:"input,omitempty"`
Output any `json:"output,omitempty"`
InputTextDelta string `json:"inputTextDelta,omitempty"`
// Control parts (start/finish steps, errors, etc.)
ErrorText string `json:"errorText,omitempty"`
}
Type can be one of these consts... text-start, text-delta, text-end, reasoning-start, reasoning-delta, reasoning-end, source-url, source-document, file, data-*, tool-input-start, tool-input-delta, tool-input-available, tool-output-available, error, start-step, finish-step, finish
type WaveChatOpts ¶
type WaveChatOpts struct {
ChatId string
ClientId string
Config AIOptsType
Tools []ToolDefinition
SystemPrompt []string
TabStateGenerator func() (string, []ToolDefinition, string, error)
BuilderAppGenerator func() (string, string, error)
WidgetAccess bool
RegisterToolApproval func(string)
AllowNativeWebSearch bool
BuilderId string
BuilderAppId string
// ephemeral to the step
TabState string
TabTools []ToolDefinition
TabId string
AppGoFile string
AppBuildStatus string
}
func (*WaveChatOpts) GetToolDefinition ¶
func (opts *WaveChatOpts) GetToolDefinition(toolName string) *ToolDefinition
type WaveContinueResponse ¶
type WaveContinueResponse struct {
MessageID string `json:"message_id,omitempty"`
Model string `json:"model,omitempty"`
ContinueFromKind StopReasonKind `json:"continue_from_kind"`
ContinueFromRawReason string `json:"continue_from_raw_reason,omitempty"`
}
Wave Specific parameter used to signal to our step function that this is a continuation step, not an initial step
type WaveStopReason ¶
type WaveStopReason struct {
Kind StopReasonKind `json:"kind"`
RawReason string `json:"raw_reason,omitempty"`
MessageID string `json:"message_id,omitempty"`
Model string `json:"model,omitempty"`
ToolCalls []WaveToolCall `json:"tool_calls,omitempty"`
ErrorType string `json:"error_type,omitempty"`
ErrorText string `json:"error_text,omitempty"`
RateLimitInfo *RateLimitInfo `json:"ratelimitinfo,omitempty"` // set when Kind is StopKindPremiumRateLimit or StopKindRateLimit
FinishStep bool `json:"finish_step,omitempty"`
}
type WaveToolCall ¶
type WaveToolCall struct {
ID string `json:"id"` // Anthropic tool_use.id
Name string `json:"name,omitempty"` // tool name (if provided)
Input any `json:"input,omitempty"` // accumulated input JSON
ToolUseData *UIMessageDataToolUse `json:"toolusedata,omitempty"` // UI tool use data
}