-
-
Notifications
You must be signed in to change notification settings - Fork 951
Expand file tree
/
Copy pathwtypemeta.go
More file actions
216 lines (190 loc) · 9.61 KB
/
wtypemeta.go
File metadata and controls
216 lines (190 loc) · 9.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// Copyright 2025, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
package waveobj
import (
"strings"
)
const Entity_Any = "any"
// for typescript typing
type MetaTSType struct {
// shared
View string `json:"view,omitempty"`
Controller string `json:"controller,omitempty"`
File string `json:"file,omitempty"`
Url string `json:"url,omitempty"`
PinnedUrl string `json:"pinnedurl,omitempty"`
Connection string `json:"connection,omitempty"`
Edit bool `json:"edit,omitempty"`
History []string `json:"history,omitempty"`
HistoryForward []string `json:"history:forward,omitempty"`
DisplayName string `json:"display:name,omitempty"`
DisplayOrder float64 `json:"display:order,omitempty"`
Icon string `json:"icon,omitempty"`
IconColor string `json:"icon:color,omitempty"`
FrameClear bool `json:"frame:*,omitempty"`
Frame bool `json:"frame,omitempty"`
FrameBorderColor string `json:"frame:bordercolor,omitempty"`
FrameActiveBorderColor string `json:"frame:activebordercolor,omitempty"`
FrameTitle string `json:"frame:title,omitempty"`
FrameIcon string `json:"frame:icon,omitempty"`
FrameText string `json:"frame:text,omitempty"`
CmdClear bool `json:"cmd:*,omitempty"`
Cmd string `json:"cmd,omitempty"`
CmdInteractive bool `json:"cmd:interactive,omitempty"`
CmdLogin bool `json:"cmd:login,omitempty"`
CmdPersistent bool `json:"cmd:persistent,omitempty"`
CmdRunOnStart bool `json:"cmd:runonstart,omitempty"`
CmdClearOnStart bool `json:"cmd:clearonstart,omitempty"`
CmdRunOnce bool `json:"cmd:runonce,omitempty"`
CmdCloseOnExit bool `json:"cmd:closeonexit,omitempty"`
CmdCloseOnExitForce bool `json:"cmd:closeonexitforce,omitempty"`
CmdCloseOnExitDelay float64 `json:"cmd:closeonexitdelay,omitempty"`
CmdNoWsh bool `json:"cmd:nowsh,omitempty"`
CmdArgs []string `json:"cmd:args,omitempty"` // args for cmd (only if cmd:shell is false)
CmdShell bool `json:"cmd:shell,omitempty"` // shell expansion for cmd+args (defaults to true)
CmdAllowConnChange bool `json:"cmd:allowconnchange,omitempty"`
CmdJwt bool `json:"cmd:jwt,omitempty"` // force adding JWT to environment
// these can be nested under "[conn]"
CmdEnv map[string]string `json:"cmd:env,omitempty"`
CmdCwd string `json:"cmd:cwd,omitempty"`
CmdInitScript string `json:"cmd:initscript,omitempty"`
CmdInitScriptSh string `json:"cmd:initscript.sh,omitempty"`
CmdInitScriptBash string `json:"cmd:initscript.bash,omitempty"`
CmdInitScriptZsh string `json:"cmd:initscript.zsh,omitempty"`
CmdInitScriptPwsh string `json:"cmd:initscript.pwsh,omitempty"`
CmdInitScriptFish string `json:"cmd:initscript.fish,omitempty"`
// AI options match settings
AiClear bool `json:"ai:*,omitempty"`
AiPresetKey string `json:"ai:preset,omitempty"`
AiApiType string `json:"ai:apitype,omitempty"`
AiBaseURL string `json:"ai:baseurl,omitempty"`
AiApiToken string `json:"ai:apitoken,omitempty"`
AiName string `json:"ai:name,omitempty"`
AiModel string `json:"ai:model,omitempty"`
AiOrgID string `json:"ai:orgid,omitempty"`
AIApiVersion string `json:"ai:apiversion,omitempty"`
AiMaxTokens float64 `json:"ai:maxtokens,omitempty"`
AiTimeoutMs float64 `json:"ai:timeoutms,omitempty"`
AiFileDiffChatId string `json:"aifilediff:chatid,omitempty"`
AiFileDiffToolCallId string `json:"aifilediff:toolcallid,omitempty"`
EditorClear bool `json:"editor:*,omitempty"`
EditorMinimapEnabled bool `json:"editor:minimapenabled,omitempty"`
EditorStickyScrollEnabled bool `json:"editor:stickyscrollenabled,omitempty"`
EditorWordWrap bool `json:"editor:wordwrap,omitempty"`
EditorFontSize float64 `json:"editor:fontsize,omitempty"`
GraphClear bool `json:"graph:*,omitempty"`
GraphNumPoints int `json:"graph:numpoints,omitempty"`
GraphMetrics []string `json:"graph:metrics,omitempty"`
SysinfoType string `json:"sysinfo:type,omitempty"`
// for tabs
BgClear bool `json:"bg:*,omitempty"`
Bg string `json:"bg,omitempty"`
BgOpacity float64 `json:"bg:opacity,omitempty"`
BgBlendMode string `json:"bg:blendmode,omitempty"`
BgBorderColor string `json:"bg:bordercolor,omitempty"` // frame:bordercolor
BgActiveBorderColor string `json:"bg:activebordercolor,omitempty"` // frame:activebordercolor
// for tabs+waveai
WaveAiPanelOpen bool `json:"waveai:panelopen,omitempty"`
WaveAiPanelWidth int `json:"waveai:panelwidth,omitempty"`
WaveAiModel string `json:"waveai:model,omitempty"`
WaveAiChatId string `json:"waveai:chatid,omitempty"`
WaveAiWidgetContext *bool `json:"waveai:widgetcontext,omitempty"` // default is true
TermClear bool `json:"term:*,omitempty"`
TermFontSize int `json:"term:fontsize,omitempty"`
TermFontFamily string `json:"term:fontfamily,omitempty"`
TermMode string `json:"term:mode,omitempty"`
TermTheme string `json:"term:theme,omitempty"`
TermLocalShellPath string `json:"term:localshellpath,omitempty"` // matches settings
TermLocalShellOpts []string `json:"term:localshellopts,omitempty"` // matches settings
TermScrollback *int `json:"term:scrollback,omitempty"`
TermVDomSubBlockId string `json:"term:vdomblockid,omitempty"`
TermVDomToolbarBlockId string `json:"term:vdomtoolbarblockid,omitempty"`
TermTransparency *float64 `json:"term:transparency,omitempty"` // default 0.5
TermAllowBracketedPaste *bool `json:"term:allowbracketedpaste,omitempty"`
TermShiftEnterNewline *bool `json:"term:shiftenternewline,omitempty"`
TermMacOptionIsMeta *bool `json:"term:macoptionismeta,omitempty"`
TermConnDebug string `json:"term:conndebug,omitempty"` // null, info, debug
TermBellSound *bool `json:"term:bellsound,omitempty"`
TermBellIndicator *bool `json:"term:bellindicator,omitempty"`
TermExitIndicator *bool `json:"term:exitindicator,omitempty"`
TermDurable *bool `json:"term:durable,omitempty"`
WebZoom float64 `json:"web:zoom,omitempty"`
WebHideNav *bool `json:"web:hidenav,omitempty"`
WebPartition string `json:"web:partition,omitempty"`
WebUserAgentType string `json:"web:useragenttype,omitempty"`
MarkdownFontSize float64 `json:"markdown:fontsize,omitempty"`
MarkdownFixedFontSize float64 `json:"markdown:fixedfontsize,omitempty"`
TsunamiClear bool `json:"tsunami:*,omitempty"`
TsunamiSdkReplacePath string `json:"tsunami:sdkreplacepath,omitempty"`
TsunamiAppPath string `json:"tsunami:apppath,omitempty"`
TsunamiAppId string `json:"tsunami:appid,omitempty"`
TsunamiScaffoldPath string `json:"tsunami:scaffoldpath,omitempty"`
TsunamiEnv map[string]string `json:"tsunami:env,omitempty"`
VDomClear bool `json:"vdom:*,omitempty"`
VDomInitialized bool `json:"vdom:initialized,omitempty"`
VDomCorrelationId string `json:"vdom:correlationid,omitempty"`
VDomRoute string `json:"vdom:route,omitempty"`
VDomPersist bool `json:"vdom:persist,omitempty"`
OnboardingGithubStar bool `json:"onboarding:githubstar,omitempty"` // for client
OnboardingLastVersion string `json:"onboarding:lastversion,omitempty"` // for client (tracks semver of last 'onboarding' shown)
Count int `json:"count,omitempty"` // temp for cpu plot. will remove later
}
type MetaDataDecl struct {
Key string `json:"key"`
Desc string `json:"desc,omitempty"`
Type string `json:"type"` // string, int, float, bool, array, object
Default any `json:"default,omitempty"`
StrOptions []string `json:"stroptions,omitempty"`
NumRange []*int `json:"numrange,omitempty"` // inclusive, null means no limit
Entity []string `json:"entity"` // what entities this applies to, e.g. "block", "tab", "any", etc.
Special []string `json:"special,omitempty"` // special handling. things that need to happen if this gets updated
}
type MetaPresetDecl struct {
Preset string `json:"preset"`
Desc string `json:"desc,omitempty"`
Keys []string `json:"keys"`
Entity []string `json:"entity"` // what entities this applies to, e.g. "block", "tab", etc.
}
// returns a clean copy of meta with mergeMeta merged in
// if mergeSpecial is false, then special keys will not be merged (like display:*)
func MergeMeta(meta MetaMapType, metaUpdate MetaMapType, mergeSpecial bool) MetaMapType {
rtn := make(MetaMapType)
for k, v := range meta {
rtn[k] = v
}
// deal with "section:*" keys
for k := range metaUpdate {
if !strings.HasSuffix(k, ":*") {
continue
}
if !metaUpdate.GetBool(k, false) {
continue
}
prefix := strings.TrimSuffix(k, ":*")
if prefix == "" {
continue
}
// delete "[prefix]" and all keys that start with "[prefix]:"
prefixColon := prefix + ":"
for k2 := range rtn {
if k2 == prefix || strings.HasPrefix(k2, prefixColon) {
delete(rtn, k2)
}
}
}
// now deal with regular keys
for k, v := range metaUpdate {
if !mergeSpecial && strings.HasPrefix(k, "display:") {
continue
}
if strings.HasSuffix(k, ":*") {
continue
}
if v == nil {
delete(rtn, k)
continue
}
rtn[k] = v
}
return rtn
}