### Install Linux Dependencies (Debian/Ubuntu) Source: https://github.com/wavetermdev/waveterm/blob/main/BUILD.md Installs zip and snapd, then installs the Zig compiler via snap. ```sh sudo apt install zip snapd sudo snap install zig --classic --beta ``` -------------------------------- ### Rate Limit Update Event Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/wps-events.md Example demonstrating publishing a rate limit update event. Includes defining the event constant, publishing the event asynchronously with RateLimitInfo data, and frontend subscription setup. ```go const ( // ... other events ... Event_WaveAIRateLimit = "waveai:ratelimit" ) ``` ```go import "github.com/wavetermdev/waveterm/pkg/wps" func updateRateLimit(info *uctypes.RateLimitInfo) { if info == nil { return } rateLimitLock.Lock() defer rateLimitLock.Unlock() globalRateLimitInfo = info // Publish event in goroutine to avoid blocking go func() { wps.Broker.Publish(wps.WaveEvent{ Event: wps.Event_WaveAIRateLimit, Data: info, // RateLimitInfo struct }) }() } ``` ```typescript // Subscribe to rate limit updates const subscription = { event: "waveai:ratelimit", allscopes: true, // Receive all rate limit events }; ``` -------------------------------- ### Install Linux Dependencies (Arch) Source: https://github.com/wavetermdev/waveterm/blob/main/BUILD.md Installs zip and the Zig compiler using pacman. ```sh sudo pacman -S zip zig ``` -------------------------------- ### Partially Filled Assistant Response Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-messages-api.md Illustrates how to provide a partial assistant response to guide the model's continuation. This is useful for constraining the output. ```json [ {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"}, {"role": "assistant", "content": "The best answer is ("}, ] ``` -------------------------------- ### SSH Shell Client Usage Pattern Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/conn-arch.md Demonstrates the typical usage pattern for creating and interacting with an SSH shell client and process controller. It shows how to instantiate the client, create a process controller, get stdout, start the process, and wait for its completion. ```go client := genconn.MakeSSHShellClient(sshClient) proc, _ := client.MakeProcessController(cmdSpec) stdout, _ := proc.StdoutPipe() proc.Start() // Read from stdout... proc.Wait() ``` -------------------------------- ### Install Linux Dependencies (Fedora/RHEL) Source: https://github.com/wavetermdev/waveterm/blob/main/BUILD.md Installs zip and the Zig compiler using dnf. ```sh sudo dnf install zip zig ``` -------------------------------- ### Start Local Development Server Source: https://github.com/wavetermdev/waveterm/blob/main/docs/README.md Run this command to start a local development server for the docs. Changes are usually reflected live without a server restart. ```sh task docsite ``` -------------------------------- ### Minimal 'Hello World' Example for Waveterm Block Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/view-prompt.md A basic example demonstrating how to create a ViewModel and a ViewComponent for a simple 'Hello World' block using Jotai for state management. ```typescript import * as jotai from "jotai"; import React from "react"; class HelloWorldModel implements ViewModel { viewType = "helloworld"; viewIcon = jotai.atom("smile"); viewName = jotai.atom("Hello World"); viewText = jotai.atom("A simple greeting block"); viewComponent = HelloWorldView; } const HelloWorldView: ViewComponent = ({ model }) => { return
Hello, World!
; }; export { HelloWorldModel }; ``` -------------------------------- ### Install Code Dependencies Source: https://github.com/wavetermdev/waveterm/blob/main/BUILD.md Loads project dependencies for the first time. Run this again if you encounter build issues. ```sh task init ``` -------------------------------- ### Full AI Mode Configuration Example Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/waveai-modes.mdx This example demonstrates all available configuration fields for an AI mode, including display settings, AI provider details, API specifics, and capabilities. It's useful for understanding the full range of customization options. ```json { "mode-key": { "display:name": "Display Name", "display:order": 1, "display:icon": "icon-name", "display:description": "Full description", "ai:provider": "custom", "ai:apitype": "openai-chat", "ai:model": "model-name", "ai:thinkinglevel": "medium", "ai:endpoint": "http://localhost:11434/v1/chat/completions", "ai:azureapiversion": "v1", "ai:apitoken": "your-token", "ai:apitokensecretname": "PROVIDER_KEY", "ai:azureresourcename": "your-resource", "ai:azuredeployment": "your-deployment", "ai:capabilities": ["tools", "images", "pdfs"] } } ``` -------------------------------- ### Create Message Request (JavaScript) Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-messages-api.md This JavaScript example shows how to create a message using the Anthropic SDK. Make sure to install the SDK and initialize the client. ```javascript import { Anthropic } from '@anthropic-ai/sdk'; const anthropic = new Anthropic(); await anthropic.messages.create({ model: "claude-sonnet-4-20250514", max_tokens: 1024, messages: [ {"role": "user", "content": "Hello, world"} ] }); ``` -------------------------------- ### Install Wave Term Beta via Snap Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/faq.mdx Install the beta version of Wave Term on Linux using the snap package manager with the --beta flag. ```sh sudo snap install waveterm --classic --beta ``` -------------------------------- ### System Prompt Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-messages-api.md Example of a system prompt for defining the AI's role or goal. This can include specific instructions or context for the model's responses. ```yaml system: "Today's date is 2024-06-01." ``` -------------------------------- ### Tool Use Example: Get Stock Price Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-messages-api.md Demonstrates how the model might request to use a tool for fetching stock prices. The `get_stock_price` tool is defined with a `ticker` input. ```json [ { "type": "tool_use", "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "name": "get_stock_price", "input": { "ticker": "^GSPC" } } ] ``` -------------------------------- ### Python SDK Streaming Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-streaming.md Example demonstrating how to stream messages using the Anthropic Python SDK. ```APIDOC ## Streaming with Python SDK ### Description This example shows how to use the `client.messages.stream` method to receive streaming responses from the Anthropic API. ### Method `client.messages.stream` ### Parameters - `max_tokens` (int): The maximum number of tokens to generate. - `messages` (list): A list of message objects representing the conversation history. - `model` (str): The model to use for generation. ### Request Example ```python import anthropic client = anthropic.Anthropic() with client.messages.stream( max_tokens=1024, messages=[{"role": "user", "content": "Hello"}], model="claude-opus-4-1-20250805", ) as stream: for text in stream.text_stream: print(text, end="", flush=True) ``` ### Response Streaming responses are received as a sequence of text chunks. ``` -------------------------------- ### Install Wave Terminal with Homebrew (macOS) Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/gettingstarted.mdx Use Homebrew to install the Wave Terminal application on macOS. ```bash brew install --cask wave ``` -------------------------------- ### Install Wave Terminal with Snap (Linux) Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/gettingstarted.mdx Install Wave Terminal on Linux using the Snap package manager. This command requires sudo privileges. ```bash sudo snap install --classic waveterm ``` -------------------------------- ### Install Wave Terminal with Chocolatey (Windows) Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/gettingstarted.mdx Install Wave Terminal on Windows using the Chocolatey package manager. ```powershell choco install wave ``` -------------------------------- ### Install Wave Terminal with Windows Package Manager Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/gettingstarted.mdx Install Wave Terminal on Windows using the Windows Package Manager (winget). ```powershell winget install CommandLine.Wave ``` -------------------------------- ### Complete OpenAI Request Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/openai-request.md A comprehensive example of an OpenAI API request input, including user message, function call, function call output, and assistant response. ```json { "model": "gpt-4o", "input": [ { "role": "user", "content": [ { "type": "input_text", "text": "What files are in src/?" } ] }, { "type": "function_call", "call_id": "call_xyz789", "name": "list_files", "arguments": "{\"path\":\"src/\"}" }, { "type": "function_call_output", "call_id": "call_xyz789", "output": "main.go\nutil.go\nconfig.go" }, { "role": "assistant", "content": [ { "type": "output_text", "text": "The src/ directory contains 3 files: main.go, util.go, and config.go" } ] } ], "stream": true, "max_output_tokens": 4096 } ``` -------------------------------- ### TypeScript SDK Streaming Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-streaming.md Example demonstrating how to stream messages using the Anthropic TypeScript SDK. ```APIDOC ## Streaming with TypeScript SDK ### Description This example demonstrates how to stream messages using the Anthropic TypeScript SDK, handling text chunks via the `.on('text', ...)` event handler. ### Method `client.messages.stream` ### Parameters - `messages` (list): A list of message objects representing the conversation history. - `model` (str): The model to use for generation. - `max_tokens` (int): The maximum number of tokens to generate. ### Request Example ```typescript import Anthropic from '@anthropic-ai/sdk'; const client = new Anthropic(); await client.messages.stream({ messages: [{role: 'user', content: "Hello"}], model: 'claude-opus-4-1-20250805', max_tokens: 1024, }).on('text', (text) => { console.log(text); }); ``` ### Response Streaming responses are processed via the `text` event, which provides chunks of generated text. ``` -------------------------------- ### Start Step Part SSE Format Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/aisdk-streaming.md A part indicating the start of a step. This is a Server-Sent Event with a JSON object payload. ```text data: {"type":"start-step"} ``` -------------------------------- ### Background Image Configuration Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/tab-backgrounds.mdx Example of configuring a tab background using an image, specifying its URL, size, and position. ```json { "bg@ocean": { "display:name": "Ocean Scene", "bg": "url('/path/to/ocean.jpg') center/cover no-repeat", "bg:opacity": 0.2 } } ``` -------------------------------- ### OpenAI Code Interpreter Call Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/openai-streaming.md Demonstrates a code interpreter call, showing the code to be executed and its output logs. ```json { "type": "code_interpreter_call", "id": "code_abc123", "code": "print('Hello, world!')", "container_id": "container_123", "outputs": [ { "type": "logs", "logs": "Hello, world!\n" } ] } ``` -------------------------------- ### Send Prompt Start Command (A) Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/wave-osc-16162.md Use this command in the 'precmd' hook to signal the start of a new shell prompt. It helps differentiate prompt output from command output. ```bash printf '\033]16162;A\007' ``` -------------------------------- ### Multiple Conversational Turns Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-messages-api.md Shows how to include multiple user and assistant turns for a more complex conversation history. This helps the model understand context. ```json [ {"role": "user", "content": "Hello there."}, {"role": "assistant", "content": "Hi, I'm Claude. How can I help you?"}, {"role": "user", "content": "Can you explain LLMs in plain English?"}, ] ``` -------------------------------- ### Subscribe with Wildcard Scopes Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/wps-events.md Scopes support wildcard matching using `*` for a single segment and `**` for multiple segments. This example subscribes to all workspace events. ```go wps.Broker.Subscribe(routeId, wps.SubscriptionRequest{ Event: wps.Event_WaveObjUpdate, Scopes: []string{"workspace:*"}, }) ``` -------------------------------- ### OpenAI Computer Use Call Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/openai-streaming.md Represents a computer use call, showing its ID and completion status. ```json { "type": "computer_call", "id": "computer_abc123", "status": "completed" } ``` -------------------------------- ### SSH Authentication: Password Callback Prompt Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/conn-arch.md Callback function for handling password authentication prompts during SSH connection setup. ```go createPasswordCallbackPrompt() ``` -------------------------------- ### Full HTTP Stream Response Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-streaming.md Provides a complete example of an HTTP stream response from the Anthropic API, illustrating the sequence of events including message start, content blocks, deltas, and message stop. ```JSON event: message_start data: {"type": "message_start", "message": {"id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY", "type": "message", "role": "assistant", "content": [], "model": "claude-opus-4-1-20250805", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 25, "output_tokens": 1}}} event: content_block_start data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}} event: ping data: {"type": "ping"} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "Hello"}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "!"}} event: content_block_stop data: {"type": "content_block_stop", "index": 0} event: message_delta data: {"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence":null}, "usage": {"output_tokens": 15}} event: message_stop data: {"type": "message_stop"} ``` -------------------------------- ### Lazy Load Monaco Editor Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/monaco-v0.53.md Import the Monaco setup module lazily where the editor UI is mounted to keep the main bundle slim. ```typescript // where the editor UI mounts const { monaco } = await import("./monaco-setup"); const editor = monaco.editor.create(container, { language: "javascript", value: "" }); ``` -------------------------------- ### Example SSH Config Host Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/connections.mdx Demonstrates a typical SSH host configuration block. This format can be used to define connection parameters for a specific host. ```ssh-config Host myhost User username HostName 203.0.113.254 IdentityFile ~/.ssh/id_rsa AddKeysToAgent yes ``` -------------------------------- ### Simple Solid Color Background Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/tab-backgrounds.mdx Example of a basic tab background configuration using a solid color with specified opacity and active border color. ```json { "bg@blue": { "display:name": "Blue", "bg": "blue", "bg:opacity": 0.3, "bg:activebordercolor": "rgba(0, 0, 255, 1.0)" } } ``` -------------------------------- ### Tool Definition: Get Weather Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-messages-api.md An example schema for defining a `get_weather` tool. It specifies required inputs like `location` and optional inputs like `unit`. ```json { "name": "get_weather", "input_schema": { "properties": { "location": { "description": "The city and state, e.g. San Francisco, CA", "type": "string" }, "unit": { "description": ">- Unit for the output - one of (celsius, fahrenheit)", "type": "string" } }, "required": [ "location" ], "type": "object" } } ``` -------------------------------- ### System Prompt Configuration Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-messages-api.md Defines the system prompt for guiding the model's behavior and role. It can include text examples and is crucial for setting the context of the conversation. ```APIDOC ## System Prompt ### Description Guides the model's behavior and role. See our [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts). ### Examples - text: Today's date is 2024-06-01. type: text - Today's date is 2023-01-01. ``` -------------------------------- ### Build Static Documentation Site Source: https://github.com/wavetermdev/waveterm/blob/main/docs/README.md Execute this command to generate the static content for the documentation site into the 'build' directory. This output can be hosted on any static hosting service. ```sh task docsite:build:public ``` -------------------------------- ### Basic Context Menu Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/contextmenu.md Creates a simple context menu with text labels, a separator, and click handlers for actions like creating new files or folders. ```typescript const menu: ContextMenuItem[] = [ { label: "New File", click: () => { /* create a new file */ }, }, { label: "New Folder", click: () => { /* create a new folder */ }, }, { type: "separator" }, { label: "Rename", click: () => { /* rename item */ }, }, ]; ContextMenuModel.showContextMenu(menu, e); ``` -------------------------------- ### Get Terminal Scrollback with wsh termscrollback Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/wsh-reference.mdx Retrieve terminal scrollback using `wsh termscrollback`. Specify a target block with `-b`, line ranges with `--start` and `--end`, or get only the last command's output with `--lastcommand`. Output can be redirected to a file with `-o`. ```sh wsh termscrollback ``` ```sh wsh termscrollback -b 2 ``` ```sh wsh termscrollback --lastcommand ``` -------------------------------- ### Start a Long-Running Build Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/durable-sessions.mdx Use this command to initiate a build process that can continue even if you close your laptop or disconnect. Reconnect later to view the completed output. ```bash # Start a long build ./build.sh # Close your laptop, get coffee # Later: reconnect and see the completed output ``` -------------------------------- ### Streaming Tool Use Response Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-streaming.md This JSON represents a streamed response from the Anthropic API when tool use is involved. It shows the sequence of events, including message start, text deltas, and tool use input deltas, demonstrating fine-grained streaming for parameter values. ```json event: message_start data: {"type":"message_start","message":{"id":"msg_014p7gG3wDgGV9EUtLvnow3U","type":"message","role":"assistant","model":"claude-opus-4-1-20250805","stop_sequence":null,"usage":{"input_tokens":472,"output_tokens":2},"content":[],"stop_reason":null}} event: content_block_start data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}} event: ping data: {"type": "ping"} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Okay"}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":","}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" let"}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"'s"}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" check"}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" the"}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" weather"}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" for"}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" San"}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" Francisco"}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":","}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" CA"}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":":"}} event: content_block_stop data: {"type":"content_block_stop","index":0} event: content_block_start data: {"type":"content_block_start","index":1,"content_block":{"type":"tool_use","id":"toolu_01T1x1fJ34qAmk2tNTrN7Up6","name":"get_weather","input":{}}} event: content_block_delta data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":""}} event: content_block_delta data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":" {\"location\":"}} event: content_block_delta data: {"type":"content_block_delta","index":1,"delta":{"type":"input_json_delta","partial_json":" \"San"}} ``` -------------------------------- ### Example Bookmarks Configuration Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/config.mdx This JSON object demonstrates how to configure multiple web bookmarks, including custom titles, display orders, and icon URLs. Bookmarks are sorted by 'display:order' or 'id'. ```json { "bookmark@google": { "url": "https://www.google.com", "title": "Google" }, "bookmark@claude": { "url": "https://claude.ai", "title": "Claude AI" }, "bookmark@wave": { "url": "https://waveterm.dev", "title": "Wave Terminal", "display:order": -1 }, "bookmark@wave-github": { "url": "https://github.com/wavetermdev/waveterm", "title": "Wave Github", "iconurl": "https://github.githubassets.com/favicons/favicon-dark.png" }, "bookmark@chatgpt": { "url": "https://chatgpt.com", "iconurl": "https://cdn.oaistatic.com/assets/favicon-miwirzcw.ico" }, "bookmark@wave-pulls": { "url": "https://github.com/wavetermdev/waveterm/pulls", "title": "Wave Pull Requests", "iconurl": "https://github.githubassets.com/favicons/favicon-dark.png" } } ``` -------------------------------- ### Container Query Examples with Custom Breakpoints Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/tailwind-container-queries.md Demonstrates min-width and max-width container queries using custom breakpoints like `@w600:` and `@max-w600:`, as well as smaller, specialized breakpoints such as `@xs:` and `@max-xxs:`. These are useful for responsive panel designs. ```html
``` -------------------------------- ### Configure LM Studio Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/waveai-modes.mdx Use this configuration to connect to a local LM Studio server running a Qwen model. Ensure LM Studio is running and the model is loaded. ```json { "lmstudio-qwen": { "display:name": "LM Studio - Qwen", "display:order": 2, "display:icon": "server", "display:description": "Local Qwen model via LM Studio", "ai:apitype": "openai-chat", "ai:model": "qwen/qwen-2.5-coder-32b-instruct", "ai:thinkinglevel": "medium", "ai:endpoint": "http://localhost:1234/v1/chat/completions", "ai:apitoken": "not-needed" } } ``` -------------------------------- ### Queueing Backend Layout Actions Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/layout-simplification.md Illustrates how layout actions are queued for the backend using `QueueLayoutAction()` in the current implementation. ```go QueueLayoutAction() ``` -------------------------------- ### OpenAI Image Generation Call Example Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/openai-streaming.md An example of an image generation call, indicating the ID and the URL of the generated image. ```json { "type": "image_generation_call", "id": "img_abc123", "result": "https://example.com/generated-image.png" } ``` -------------------------------- ### CLI Commands for Setting Configuration Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/config-system.md Shell commands demonstrating how to set configuration values using the `wsh` tool, including global settings and block-specific metadata overrides. ```bash # Set globally wsh setconfig term:bellsound="custom.wav" # Set for current block only wsh setmeta term:bellsound="none" # Set for specific block wsh setmeta --block BLOCK_ID term:bellsound="beep" ``` -------------------------------- ### Automate Development Environment Setup with wsh Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/wsh.mdx Use wsh commands in a bash script to set up a development environment, open a web interface, view files, and run tests. This script also demonstrates using wsh notify to monitor long-running build tasks. ```bash #!/bin/bash # Setup development environment wsh run -- docker-compose up -d wsh web open localhost:8080 wsh view ./src wsh run -- npm run test:watch # Get notified when long-running tasks complete using wsh notify npm run build && wsh notify "Build complete" || wsh notify "Build failed" ``` -------------------------------- ### Scripting and Automation with wsh Source: https://context7.com/wavetermdev/waveterm/llms.txt Automate development workflows, remote monitoring, and AI-assisted debugging using 'wsh' commands. This example demonstrates launching services, opening web pages, and managing variables. ```bash #!/bin/bash # dev-setup.sh — Launch a full development environment in Wave # Start the database and backend in dedicated blocks wsh run -- docker-compose up -d wsh run -m -- npm run dev # Open documentation and staging in web blocks wsh web open http://localhost:3000 wsh web open http://localhost:8080/api/docs # Show source directory in a preview block wsh view ./src # Store build token for this session wsh setvar -b workspace BUILD_ENV=local # Run tests and notify on completion npm run test && wsh notify "✅ Tests passed" || wsh notify -t "Tests" "❌ Tests failed" ``` -------------------------------- ### Define Speedtest-Go Command Widget Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/customwidgets.mdx Create a widget to run the 'speedtest-go --unix' command. 'cmd:clearonstart' clears previous output each time the command is executed. ```json { "speedtest" : { "icon": "gauge-high", "label": "speed", "blockdef": { "meta": { "view": "term", "controller": "cmd", "cmd": "speedtest-go --unix", "cmd:clearonstart": true } } } } ``` -------------------------------- ### Install Monaco Editor and Remove Loader Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/monaco-v0.53.md Update dependencies by removing the Monaco editor loader and installing the new version of monaco-editor. ```bash npm rm @monaco-editor/loader npm i monaco-editor@^0.53 ``` -------------------------------- ### Frontend Configuration Patterns Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/config-system.md Demonstrates recommended patterns for accessing settings in frontend code, including settings with block-level overrides, global-only settings, and connection-specific settings. ```typescript // 1. Settings with block-level overrides (recommended) const termFontSize = useAtomValue(getOverrideConfigAtom(blockId, "term:fontsize")) ?? 12; // 2. Global-only settings const appGlobalHotkey = useAtomValue(getSettingsKeyAtom("app:globalhotkey")) ?? ""; // 3. Connection-specific settings const connStatus = useAtomValue(getConnStatusAtom(connectionName)); ``` -------------------------------- ### Get Connection Status Atom Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/fe-conn-arch.md Use connection atoms to get the current connection status. This atom depends on the block's connection metadata. ```typescript connStatus = atom((get) => { const blockData = get(this.blockAtom) const connName = blockData?.meta?.connection return get(getConnStatusAtom(connName)) }) ``` -------------------------------- ### Open Wave Configuration Editor Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/config.mdx Use this command to open the Wave configuration file in the built-in preview editor for easy editing. ```bash wsh editconfig ``` -------------------------------- ### Run Development Server Source: https://github.com/wavetermdev/waveterm/blob/main/BUILD.md Builds the app and runs it with Vite's development server, enabling Hot Module Reloading. ```sh task dev ``` -------------------------------- ### Get wsh Command Help Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/wsh.mdx Run wsh with no arguments to get a list of available commands, or use the -h flag with a specific command for detailed help. ```bash wsh ``` ```bash wsh [command] -h ``` -------------------------------- ### Configure Azure OpenAI with Capabilities Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/waveai-modes.mdx Example of configuring Azure OpenAI with specific capabilities like 'tools' and 'images'. This is required when using certain model features. ```json { "azure-gpt4": { "display:name": "Azure GPT-4", "ai:provider": "azure", "ai:model": "gpt-4", "ai:azureresourcename": "your-resource-name", "ai:capabilities": ["tools", "images"] } } ``` -------------------------------- ### Add All CPU Data Sysinfo Widget Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/customwidgets.mdx Configure a custom widget to display all available CPU data. This widget defaults to 100 seconds of data. ```json { "all-cpu" : { "icon": "chart-scatter", "label": "all-cpu", "blockdef": { "meta": { "view": "sysinfo", "sysinfo:type": "All CPU" } } } } ``` -------------------------------- ### Start new chat with wsh ai Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/wsh-reference.mdx Use the `-n` flag with `wsh ai` to clear the current chat history and start a new conversation, attaching specified files. ```bash wsh ai -n report.pdf data.csv -m "summarize these reports" ``` -------------------------------- ### Streaming Response with Extended Thinking Events Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/anthropic-streaming.md This JSON represents the stream of events received when requesting a response with extended thinking enabled. It includes message start, content block starts and deltas for both thinking and text, and message stop events. ```json event: message_start data: {"type": "message_start", "message": {"id": "msg_01...", "type": "message", "role": "assistant", "content": [], "model": "claude-opus-4-1-20250805", "stop_reason": null, "stop_sequence": null}} event: content_block_start data: {"type": "content_block_start", "index": 0, "content_block": {"type": "thinking", "thinking": ""}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "Let me solve this step by step:\n\n1. First break down 27 * 453"}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "\n2. 453 = 400 + 50 + 3"}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "\n3. 27 * 400 = 10,800"}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "\n4. 27 * 50 = 1,350"}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "\n5. 27 * 3 = 81"}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "thinking_delta", "thinking": "\n6. 10,800 + 1,350 + 81 = 12,231"}} event: content_block_delta data: {"type": "content_block_delta", "index": 0, "delta": {"type": "signature_delta", "signature": "EqQBCgIYAhIM1gbcDa9GJwZA2b3hGgxBdjrkzLoky3dl1pkiMOYds..."}} event: content_block_stop data: {"type": "content_block_stop", "index": 0} event: content_block_start data: {"type": "content_block_start", "index": 1, "content_block": {"type": "text", "text": ""}} event: content_block_delta data: {"type": "content_block_delta", "index": 1, "delta": {"type": "text_delta", "text": "27 * 453 = 12,231"}} event: content_block_stop data: {"type": "content_block_stop", "index": 1} event: message_delta data: {"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence": null}} event: message_stop data: {"type": "message_stop"} ``` -------------------------------- ### YouTube Web Widget Example Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/customwidgets.mdx Configures a web widget that defaults to the YouTube homepage and uses YouTube as its home page. This is useful for quick access to frequently visited sites. ```json { "youtube" : { "icon": "brands@youtube", "label": "youtube", "blockdef": { "meta": { "view": "web", "url": "https://youtube.com", "pinnedurl": "https://youtube.com" } } } } ``` -------------------------------- ### secret get Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/wsh-reference.mdx Retrieve and display the value of a stored secret. ```APIDOC ## wsh secret get ### Description Retrieve and display the value of a stored secret. ### Usage ```sh wsh secret get [name] ``` ### Examples ```sh # Get an API key wsh secret get github_token # Use in scripts export API_KEY=$(wsh secret get my_api_key) ``` ``` -------------------------------- ### List Files Source: https://context7.com/wavetermdev/waveterm/llms.txt Lists files on a remote host or in a local directory. Use '-l' for detailed output. ```bash wsh file ls wsh://ec2-user@myserver/var/log/ ``` ```bash wsh file ls -l ./local-dir/ ``` -------------------------------- ### wavepath Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/wsh-reference.mdx Get paths to Wave Terminal directories and files. ```APIDOC ## wsh wavepath ### Description The `wavepath` command lets you get the paths to various Wave Terminal directories and files, including configuration, data storage, and logs. ### Usage ```sh wsh wavepath {config|data|log} ``` This command returns the full path to the requested Wave Terminal system directory or file. It's useful for accessing Wave's configuration files, data storage, or checking logs. ### Flags - `-o, --open`: Open the path in a new block. - `-O, --open-external`: Open the path in the default external application. - `-t, --tail`: Show the last ~100 lines of the log file (only valid for log path). ### Examples ```sh # Get path to config directory wsh wavepath config # Get path to data directory wsh wavepath data # Get path to log file wsh wavepath log # Open log file in a new block wsh wavepath -o log # Open config directory in system file explorer wsh wavepath -O config # View recent log entries wsh wavepath -t log ``` ### Paths - `config`: Where Wave Terminal stores its configuration files. - `data`: Where Wave Terminal stores its persistent data. - `log`: The main Wave Terminal log file. :::tip Use the `-t` flag with the log path to quickly view recent log entries without having to open the full file. This is particularly useful for troubleshooting. ::: ``` -------------------------------- ### Get File Information Source: https://context7.com/wavetermdev/waveterm/llms.txt Retrieves metadata and information about a file, whether local or remote. ```bash wsh file info wsh://ec2-user@myserver/~/app.log ``` -------------------------------- ### Set Default Values Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/config-system.md Provide default values for new settings in `pkg/wconfig/defaultconfig/settings.json`. Only include defaults for settings that require a non-empty initial value. ```json { "ai:preset": "ai@global", "ai:model": "gpt-5-mini", // ... existing defaults ... "mynew:setting": "default value", "mynew:boolsetting": true, "mynew:numbersetting": 42.5, "mynew:intsetting": 100 } ``` -------------------------------- ### Start Command in Paused State Source: https://github.com/wavetermdev/waveterm/blob/main/docs/docs/wsh-reference.mdx Initiates a command in a paused state, allowing for review before execution. ```sh # Start a command in paused state wsh run -p -- ./server --dev ``` -------------------------------- ### Package Application Source: https://github.com/wavetermdev/waveterm/blob/main/BUILD.md Generates a production build and packages the application. Artifacts are placed in the 'make/' directory. ```sh task package ``` -------------------------------- ### Publish Basic Event Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/wps-events.md Publish a WaveEvent using the global wps.Broker. Ensure the wps package is imported. ```go import "github.com/wavetermdev/waveterm/pkg/wps" wps.Broker.Publish(wps.WaveEvent{ Event: wps.Event_YourNewEvent, Data: yourData, }) ``` -------------------------------- ### Handle `response.created` Event Source: https://github.com/wavetermdev/waveterm/blob/main/aiprompts/openai-streaming-text.md Use this event to initialize response tracking. It signals the start of a new response. ```json { "type": "response.created", "response": { "id": "resp_abc123", "created_at": 1640995200, "model": "gpt-5" } } ```