Documentation
¶
Index ¶
- Constants
- Variables
- func CombineConsecutiveSameRoleMessages(uiChat *uctypes.UIChat) *uctypes.UIChat
- func ConvertAIChatToUIChat(aiChat *uctypes.AIChat) (*uctypes.UIChat, error)
- func CurrentToolApprovalStatus(toolCallId string) string
- func GenerateCurrentTabStatePrompt(blocks []*waveobj.Block, widgetAccess bool) string
- func GenerateTabStateAndTools(ctx context.Context, tabid string, widgetAccess bool) (string, []uctypes.ToolDefinition, error)
- func GetAdderToolDefinition() uctypes.ToolDefinition
- func GetCaptureScreenshotToolDefinition(tabId string) uctypes.ToolDefinition
- func GetChatUsage(chat *uctypes.AIChat) uctypes.AIUsage
- func GetGlobalRateLimit() *uctypes.RateLimitInfo
- func GetReadDirToolDefinition() uctypes.ToolDefinition
- func GetReadTextFileToolDefinition() uctypes.ToolDefinition
- func GetTermGetScrollbackToolDefinition(tabId string) uctypes.ToolDefinition
- func GetTsunamiGetConfigToolDefinition(block *waveobj.Block, rtInfo *waveobj.ObjRTInfo, ...) *uctypes.ToolDefinition
- func GetTsunamiGetDataToolDefinition(block *waveobj.Block, rtInfo *waveobj.ObjRTInfo, ...) *uctypes.ToolDefinition
- func GetTsunamiSetConfigToolDefinition(block *waveobj.Block, rtInfo *waveobj.ObjRTInfo, ...) *uctypes.ToolDefinition
- func GetWebNavigateToolDefinition(tabId string) uctypes.ToolDefinition
- func MakeBlockShortDesc(block *waveobj.Block) string
- func RegisterToolApproval(toolCallId string)
- func ResolveToolCall(toolCall uctypes.WaveToolCall, chatOpts uctypes.WaveChatOpts) (result uctypes.AIToolResult)
- func RunAIChat(ctx context.Context, sseHandler *sse.SSEHandlerCh, ...) (*uctypes.AIMetrics, error)
- func UpdateToolApproval(toolCallId string, approval string, keepAlive bool) error
- func WaitForToolApproval(toolCallId string) string
- func WaveAIGetChatHandler(w http.ResponseWriter, r *http.Request)
- func WaveAIPostMessageHandler(w http.ResponseWriter, r *http.Request)
- func WaveAIPostMessageWrap(ctx context.Context, sseHandler *sse.SSEHandlerCh, message *uctypes.AIMessage, ...) error
- type ApprovalRegistry
- type ApprovalRequest
- type DirEntryOut
- type PostMessageRequest
- type TermGetScrollbackToolInput
- type TermGetScrollbackToolOutput
- type WebNavigateToolInput
Constants ¶
View Source
const ( InitialApprovalTimeout = 10 * time.Second KeepAliveExtension = 10 * time.Second )
View Source
const ( APIType_Anthropic = "anthropic" APIType_OpenAI = "openai" )
View Source
const DefaultAIEndpoint = "https://cfapi.waveterm.dev/api/waveai"
View Source
const DefaultAPI = APIType_OpenAI
View Source
const DefaultMaxTokens = 4 * 1024
View Source
const ReadDirDefaultMaxEntries = 500
View Source
const ReadDirHardMaxEntries = 10000
View Source
const ReadFileDefaultLineCount = 100
View Source
const ReadFileDefaultMaxBytes = 50 * 1024
View Source
const StopReasonMaxBytes = "max_bytes"
Variables ¶
View Source
var SystemPromptText = strings.Join([]string{
`You are Wave AI, an intelligent assistant embedded within Wave Terminal, a modern terminal application with graphical widgets.`,
`You appear as a pull-out panel on the left side of a tab, with the tab's widgets laid out on the right.`,
`Widget context is provided as informationa only.`,
`Do NOT assume any API access or ability to interact with the widgets except via tools provided (note that some widgets may expose NO tools, so their context is informational only).`,
}, " ")
View Source
var SystemPromptText_OpenAI = strings.Join([]string{
`You are Wave AI, an assistant embedded in Wave Terminal (a terminal with graphical widgets).`,
`You appear as a pull-out panel on the left; widgets are on the right.`,
`Tools define your only capabilities. If a capability is not provided by a tool, you cannot do it.`,
`Context from widgets is read-only unless a tool explicitly grants interaction.`,
`Never fabricate data. If you lack data or access, say so and offer the next best step (e.g., suggest enabling a tool).`,
`Be concise and direct. Prefer determinism over speculation. If a brief clarifying question eliminates guesswork, ask it.`,
`When presenting commands or any runnable multi-line code, always use fenced Markdown code blocks.`,
`Use an appropriate language hint after the opening fence (e.g., "bash" for shell commands, "go" for Go, "json" for JSON).`,
`For shell commands, do NOT prefix lines with "$" or shell prompts. Use placeholders in ALL_CAPS (e.g., PROJECT_ID) and explain them once after the block if needed.`,
"Reserve inline code (single backticks) for short references like command names (`grep`, `less`), flags, env vars, file paths, or tiny snippets not meant to be executed.",
`You may use Markdown (lists, tables, bold/italics) to improve readability.`,
`Never comment on or justify your formatting choices; just follow these rules.`,
`When generating code or command blocks, try to keep lines under ~100 characters wide where practical (soft wrap; do not break tokens mid-word). Favor indentation and short variable names to stay compact, but correctness always takes priority.`,
`If a request would execute dangerous or destructive actions, warn briefly and provide a safer alternative.`,
`If output is very long, prefer a brief summary plus a copy-ready fenced block or offer a follow-up chunking strategy.`,
`You have NO API access to widgets or Wave unless provided via an explicit tool.`,
}, " ")
Functions ¶
func CombineConsecutiveSameRoleMessages ¶
CombineConsecutiveSameRoleMessages combines consecutive UIMessages with the same role by appending their Parts together. This is useful for APIs like OpenAI that may split assistant messages into separate messages (e.g., one for text and one for tool calls).
func ConvertAIChatToUIChat ¶
ConvertAIChatToUIChat converts an AIChat to a UIChat by routing to the appropriate provider-specific converter based on APIType, then combining consecutive same-role messages.
func GetAdderToolDefinition ¶
func GetAdderToolDefinition() uctypes.ToolDefinition
func GetCaptureScreenshotToolDefinition ¶
func GetCaptureScreenshotToolDefinition(tabId string) uctypes.ToolDefinition
func GetGlobalRateLimit ¶
func GetGlobalRateLimit() *uctypes.RateLimitInfo
func GetReadDirToolDefinition ¶
func GetReadDirToolDefinition() uctypes.ToolDefinition
func GetReadTextFileToolDefinition ¶
func GetReadTextFileToolDefinition() uctypes.ToolDefinition
func GetTermGetScrollbackToolDefinition ¶
func GetTermGetScrollbackToolDefinition(tabId string) uctypes.ToolDefinition
func GetTsunamiGetConfigToolDefinition ¶
func GetTsunamiGetConfigToolDefinition(block *waveobj.Block, rtInfo *waveobj.ObjRTInfo, status *blockcontroller.BlockControllerRuntimeStatus) *uctypes.ToolDefinition
func GetTsunamiGetDataToolDefinition ¶
func GetTsunamiGetDataToolDefinition(block *waveobj.Block, rtInfo *waveobj.ObjRTInfo, status *blockcontroller.BlockControllerRuntimeStatus) *uctypes.ToolDefinition
func GetTsunamiSetConfigToolDefinition ¶
func GetTsunamiSetConfigToolDefinition(block *waveobj.Block, rtInfo *waveobj.ObjRTInfo, status *blockcontroller.BlockControllerRuntimeStatus) *uctypes.ToolDefinition
func GetWebNavigateToolDefinition ¶
func GetWebNavigateToolDefinition(tabId string) uctypes.ToolDefinition
func MakeBlockShortDesc ¶
func RegisterToolApproval ¶
func RegisterToolApproval(toolCallId string)
func ResolveToolCall ¶
func ResolveToolCall(toolCall uctypes.WaveToolCall, chatOpts uctypes.WaveChatOpts) (result uctypes.AIToolResult)
func RunAIChat ¶
func RunAIChat(ctx context.Context, sseHandler *sse.SSEHandlerCh, chatOpts uctypes.WaveChatOpts) (*uctypes.AIMetrics, error)
func UpdateToolApproval ¶
func WaitForToolApproval ¶
func WaveAIGetChatHandler ¶
func WaveAIGetChatHandler(w http.ResponseWriter, r *http.Request)
func WaveAIPostMessageHandler ¶
func WaveAIPostMessageHandler(w http.ResponseWriter, r *http.Request)
func WaveAIPostMessageWrap ¶
func WaveAIPostMessageWrap(ctx context.Context, sseHandler *sse.SSEHandlerCh, message *uctypes.AIMessage, chatOpts uctypes.WaveChatOpts) error
Types ¶
type ApprovalRegistry ¶
type ApprovalRegistry struct {
// contains filtered or unexported fields
}
type ApprovalRequest ¶
type ApprovalRequest struct {
// contains filtered or unexported fields
}
type DirEntryOut ¶
type PostMessageRequest ¶
type PostMessageRequest struct { TabId string `json:"tabid"` ChatID string `json:"chatid"` Msg uctypes.AIMessage `json:"msg"` WidgetAccess bool `json:"widgetaccess,omitempty"` }
PostMessageRequest represents the request body for posting a message
type TermGetScrollbackToolOutput ¶
type TermGetScrollbackToolOutput struct { TotalLines int `json:"total_lines"` LineStart int `json:"line_start"` LineEnd int `json:"line_end"` ReturnedLines int `json:"returned_lines"` Content string `json:"content"` SinceLastOutputSec *int `json:"since_last_output_sec,omitempty"` HasMore bool `json:"has_more"` NextStart *int `json:"next_start"` }
type WebNavigateToolInput ¶
type WebNavigateToolInput struct {}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.