Skip to content

Commit 667de56

Browse files
authored
updates to allow wave ai panel to function without telemetry with BYOK/local models (#2685)
* lots of changes to how aimodes are shown on frontend * backend now requires aimode to be sent with request * diagnostic ping
1 parent 8b37bc6 commit 667de56

28 files changed

Lines changed: 473 additions & 332 deletions

File tree

Taskfile.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ tasks:
2727
- build:tsunamiscaffold
2828
env:
2929
WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env"
30+
WCLOUD_PING_ENDPOINT: "https://ping-dev.waveterm.dev/central"
3031
WCLOUD_ENDPOINT: "https://api-dev.waveterm.dev/central"
3132
WCLOUD_WS_ENDPOINT: "wss://wsapi-dev.waveterm.dev"
3233

@@ -40,6 +41,7 @@ tasks:
4041
- build:backend
4142
env:
4243
WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env"
44+
WCLOUD_PING_ENDPOINT: "https://ping-dev.waveterm.dev/central"
4345
WCLOUD_ENDPOINT: "https://api-dev.waveterm.dev/central"
4446
WCLOUD_WS_ENDPOINT: "wss://wsapi-dev.waveterm.dev"
4547

@@ -51,6 +53,7 @@ tasks:
5153
- build:backend:quickdev
5254
env:
5355
WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env"
56+
WCLOUD_PING_ENDPOINT: "https://ping-dev.waveterm.dev/central"
5457
WCLOUD_ENDPOINT: "https://api-dev.waveterm.dev/central"
5558
WCLOUD_WS_ENDPOINT: "wss://wsapi-dev.waveterm.dev/"
5659

@@ -62,6 +65,7 @@ tasks:
6265
- build:backend:quickdev:windows
6366
env:
6467
WAVETERM_ENVFILE: "{{.ROOT_DIR}}/.env"
68+
WCLOUD_PING_ENDPOINT: "https://ping-dev.waveterm.dev/central"
6569
WCLOUD_ENDPOINT: "https://api-dev.waveterm.dev/central"
6670
WCLOUD_WS_ENDPOINT: "wss://wsapi-dev.waveterm.dev/"
6771

cmd/server/main-server.go

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"github.com/wavetermdev/waveterm/pkg/web"
3939
"github.com/wavetermdev/waveterm/pkg/wps"
4040
"github.com/wavetermdev/waveterm/pkg/wshrpc"
41+
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshclient"
4142
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshremote"
4243
"github.com/wavetermdev/waveterm/pkg/wshrpc/wshserver"
4344
"github.com/wavetermdev/waveterm/pkg/wshutil"
@@ -59,6 +60,8 @@ const TelemetryInitialCountsWait = 5 * time.Second
5960
const TelemetryCountsInterval = 1 * time.Hour
6061
const BackupCleanupTick = 2 * time.Minute
6162
const BackupCleanupInterval = 4 * time.Hour
63+
const InitialDiagnosticWait = 5 * time.Minute
64+
const DiagnosticTick = 10 * time.Minute
6265

6366
var shutdownOnce sync.Once
6467

@@ -128,23 +131,46 @@ func telemetryLoop() {
128131
}
129132
}
130133

131-
func sendNoTelemetryUpdate(telemetryEnabled bool) {
134+
func diagnosticLoop() {
135+
defer func() {
136+
panichandler.PanicHandler("diagnosticLoop", recover())
137+
}()
138+
if os.Getenv("WAVETERM_NOPING") != "" {
139+
log.Printf("WAVETERM_NOPING set, disabling diagnostic ping\n")
140+
return
141+
}
142+
var lastSentDate string
143+
time.Sleep(InitialDiagnosticWait)
144+
for {
145+
currentDate := time.Now().Format("2006-01-02")
146+
if lastSentDate == "" || lastSentDate != currentDate {
147+
if sendDiagnosticPing() {
148+
lastSentDate = currentDate
149+
}
150+
}
151+
time.Sleep(DiagnosticTick)
152+
}
153+
}
154+
155+
func sendDiagnosticPing() bool {
132156
ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
133157
defer cancelFn()
158+
159+
rpcClient := wshclient.GetBareRpcClient()
160+
isOnline, err := wshclient.NetworkOnlineCommand(rpcClient, &wshrpc.RpcOpts{Route: "electron", Timeout: 2000})
161+
if err != nil || !isOnline {
162+
return false
163+
}
134164
clientData, err := wstore.DBGetSingleton[*waveobj.Client](ctx)
135165
if err != nil {
136-
log.Printf("telemetry update: error getting client data: %v\n", err)
137-
return
166+
return false
138167
}
139168
if clientData == nil {
140-
log.Printf("telemetry update: client data is nil\n")
141-
return
142-
}
143-
err = wcloud.SendNoTelemetryUpdate(ctx, clientData.OID, !telemetryEnabled)
144-
if err != nil {
145-
log.Printf("[error] sending no-telemetry update: %v\n", err)
146-
return
169+
return false
147170
}
171+
usageTelemetry := telemetry.IsTelemetryEnabled()
172+
wcloud.SendDiagnosticPing(ctx, clientData.OID, usageTelemetry)
173+
return true
148174
}
149175

150176
func setupTelemetryConfigHandler() {
@@ -159,7 +185,7 @@ func setupTelemetryConfigHandler() {
159185
newTelemetryEnabled := newConfig.Settings.TelemetryEnabled
160186
if newTelemetryEnabled != currentTelemetryEnabled {
161187
currentTelemetryEnabled = newTelemetryEnabled
162-
go sendNoTelemetryUpdate(newTelemetryEnabled)
188+
wcore.GoSendNoTelemetryUpdate(newTelemetryEnabled)
163189
}
164190
})
165191
}
@@ -318,8 +344,8 @@ func startupActivityUpdate(firstLaunch bool) {
318344
fullConfig := wconfig.GetWatcher().GetFullConfig()
319345
props := telemetrydata.TEventProps{
320346
UserSet: &telemetrydata.TEventUserProps{
321-
ClientVersion: "v" + WaveVersion,
322-
ClientBuildTime: BuildTime,
347+
ClientVersion: "v" + wavebase.WaveVersion,
348+
ClientBuildTime: wavebase.BuildTime,
323349
ClientArch: wavebase.ClientArch(),
324350
ClientOSRelease: wavebase.UnameKernelRelease(),
325351
ClientIsDev: wavebase.IsDevMode(),
@@ -533,6 +559,7 @@ func main() {
533559
maybeStartPprofServer()
534560
go stdinReadWatch()
535561
go telemetryLoop()
562+
go diagnosticLoop()
536563
setupTelemetryConfigHandler()
537564
go updateTelemetryCountsLoop()
538565
go backupCleanupLoop()

docs/docs/faq.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ id: "faq"
44
title: "FAQ"
55
---
66

7+
import { VersionBadge } from "@site/src/components/versionbadge";
8+
79
# FAQ
810

911
### How can I see the block numbers?
@@ -52,3 +54,15 @@ If you've installed via Snap, you can use the following command:
5254
```sh
5355
sudo snap install waveterm --classic --beta
5456
```
57+
58+
## Can I use Wave AI without enabling telemetry?
59+
60+
<VersionBadge version="v0.13.1" noLeftMargin={true}/>
61+
62+
Yes! Wave AI is normally disabled when telemetry is not enabled. However, you can enable Wave AI features without telemetry by configuring your own custom AI model (either a local model or using your own API key).
63+
64+
To enable Wave AI without telemetry:
65+
1. Configure a custom AI mode (see [Wave AI documentation](./waveai-modes))
66+
2. Set `waveai:defaultmode` to your custom mode's key in your Wave settings
67+
68+
Once you've completed both steps, Wave AI will be enabled and you can use it completely privately without telemetry. This allows you to use local models like Ollama or your own API keys with providers like OpenAI, OpenRouter, or others.

0 commit comments

Comments
 (0)