forked from wavetermdev/waveterm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwshrpctypes.go
678 lines (589 loc) · 25.6 KB
/
wshrpctypes.go
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
// Copyright 2025, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
// types and methods for wsh rpc calls
package wshrpc
import (
"bytes"
"context"
"encoding/json"
"log"
"os"
"reflect"
"github.com/wavetermdev/waveterm/pkg/filestore"
"github.com/wavetermdev/waveterm/pkg/ijson"
"github.com/wavetermdev/waveterm/pkg/vdom"
"github.com/wavetermdev/waveterm/pkg/waveobj"
"github.com/wavetermdev/waveterm/pkg/wps"
)
const LocalConnName = "local"
const (
RpcType_Call = "call" // single response (regular rpc)
RpcType_ResponseStream = "responsestream" // stream of responses (streaming rpc)
RpcType_StreamingRequest = "streamingrequest" // streaming request
RpcType_Complex = "complex" // streaming request/response
)
const (
Command_Authenticate = "authenticate" // special
Command_Dispose = "dispose" // special (disposes of the route, for multiproxy only)
Command_RouteAnnounce = "routeannounce" // special (for routing)
Command_RouteUnannounce = "routeunannounce" // special (for routing)
Command_Message = "message"
Command_GetMeta = "getmeta"
Command_SetMeta = "setmeta"
Command_SetView = "setview"
Command_ControllerInput = "controllerinput"
Command_ControllerRestart = "controllerrestart"
Command_ControllerStop = "controllerstop"
Command_ControllerResync = "controllerresync"
Command_FileAppend = "fileappend"
Command_FileAppendIJson = "fileappendijson"
Command_ResolveIds = "resolveids"
Command_BlockInfo = "blockinfo"
Command_CreateBlock = "createblock"
Command_DeleteBlock = "deleteblock"
Command_FileWrite = "filewrite"
Command_FileRead = "fileread"
Command_EventPublish = "eventpublish"
Command_EventRecv = "eventrecv"
Command_EventSub = "eventsub"
Command_EventUnsub = "eventunsub"
Command_EventUnsubAll = "eventunsuball"
Command_EventReadHistory = "eventreadhistory"
Command_StreamTest = "streamtest"
Command_StreamWaveAi = "streamwaveai"
Command_StreamCpuData = "streamcpudata"
Command_Test = "test"
Command_SetConfig = "setconfig"
Command_SetConnectionsConfig = "connectionsconfig"
Command_RemoteStreamFile = "remotestreamfile"
Command_RemoteFileInfo = "remotefileinfo"
Command_RemoteFileTouch = "remotefiletouch"
Command_RemoteWriteFile = "remotewritefile"
Command_RemoteFileDelete = "remotefiledelete"
Command_RemoteFileJoin = "remotefilejoin"
Command_WaveInfo = "waveinfo"
Command_WshActivity = "wshactivity"
Command_Activity = "activity"
Command_GetVar = "getvar"
Command_SetVar = "setvar"
Command_RemoteMkdir = "remotemkdir"
Command_RemoteGetInfo = "remotegetinfo"
Command_RemoteInstallRcfiles = "remoteinstallrcfiles"
Command_ConnStatus = "connstatus"
Command_WslStatus = "wslstatus"
Command_ConnEnsure = "connensure"
Command_ConnReinstallWsh = "connreinstallwsh"
Command_ConnConnect = "connconnect"
Command_ConnDisconnect = "conndisconnect"
Command_ConnList = "connlist"
Command_WslList = "wsllist"
Command_WslDefaultDistro = "wsldefaultdistro"
Command_DismissWshFail = "dismisswshfail"
Command_ConnUpdateWsh = "updatewsh"
Command_WorkspaceList = "workspacelist"
Command_WebSelector = "webselector"
Command_Notify = "notify"
Command_FocusWindow = "focuswindow"
Command_GetUpdateChannel = "getupdatechannel"
Command_VDomCreateContext = "vdomcreatecontext"
Command_VDomAsyncInitiation = "vdomasyncinitiation"
Command_VDomRender = "vdomrender"
Command_VDomUrlRequest = "vdomurlrequest"
Command_AiSendMessage = "aisendmessage"
)
type RespOrErrorUnion[T any] struct {
Response T
Error error
}
type WshRpcInterface interface {
AuthenticateCommand(ctx context.Context, data string) (CommandAuthenticateRtnData, error)
DisposeCommand(ctx context.Context, data CommandDisposeData) error
RouteAnnounceCommand(ctx context.Context) error // (special) announces a new route to the main router
RouteUnannounceCommand(ctx context.Context) error // (special) unannounces a route to the main router
MessageCommand(ctx context.Context, data CommandMessageData) error
GetMetaCommand(ctx context.Context, data CommandGetMetaData) (waveobj.MetaMapType, error)
SetMetaCommand(ctx context.Context, data CommandSetMetaData) error
SetViewCommand(ctx context.Context, data CommandBlockSetViewData) error
ControllerInputCommand(ctx context.Context, data CommandBlockInputData) error
ControllerStopCommand(ctx context.Context, blockId string) error
ControllerResyncCommand(ctx context.Context, data CommandControllerResyncData) error
ControllerAppendOutputCommand(ctx context.Context, data CommandControllerAppendOutputData) error
ResolveIdsCommand(ctx context.Context, data CommandResolveIdsData) (CommandResolveIdsRtnData, error)
CreateBlockCommand(ctx context.Context, data CommandCreateBlockData) (waveobj.ORef, error)
CreateSubBlockCommand(ctx context.Context, data CommandCreateSubBlockData) (waveobj.ORef, error)
DeleteBlockCommand(ctx context.Context, data CommandDeleteBlockData) error
DeleteSubBlockCommand(ctx context.Context, data CommandDeleteBlockData) error
WaitForRouteCommand(ctx context.Context, data CommandWaitForRouteData) (bool, error)
FileCreateCommand(ctx context.Context, data CommandFileCreateData) error
FileDeleteCommand(ctx context.Context, data CommandFileData) error
FileAppendCommand(ctx context.Context, data CommandFileData) error
FileAppendIJsonCommand(ctx context.Context, data CommandAppendIJsonData) error
FileWriteCommand(ctx context.Context, data CommandFileData) error
FileReadCommand(ctx context.Context, data CommandFileData) (string, error)
FileInfoCommand(ctx context.Context, data CommandFileData) (*WaveFileInfo, error)
FileListCommand(ctx context.Context, data CommandFileListData) ([]*WaveFileInfo, error)
EventPublishCommand(ctx context.Context, data wps.WaveEvent) error
EventSubCommand(ctx context.Context, data wps.SubscriptionRequest) error
EventUnsubCommand(ctx context.Context, data string) error
EventUnsubAllCommand(ctx context.Context) error
EventReadHistoryCommand(ctx context.Context, data CommandEventReadHistoryData) ([]*wps.WaveEvent, error)
StreamTestCommand(ctx context.Context) chan RespOrErrorUnion[int]
StreamWaveAiCommand(ctx context.Context, request WaveAIStreamRequest) chan RespOrErrorUnion[WaveAIPacketType]
StreamCpuDataCommand(ctx context.Context, request CpuDataRequest) chan RespOrErrorUnion[TimeSeriesData]
TestCommand(ctx context.Context, data string) error
SetConfigCommand(ctx context.Context, data MetaSettingsType) error
SetConnectionsConfigCommand(ctx context.Context, data ConnConfigRequest) error
BlockInfoCommand(ctx context.Context, blockId string) (*BlockInfoData, error)
WaveInfoCommand(ctx context.Context) (*WaveInfoData, error)
WshActivityCommand(ct context.Context, data map[string]int) error
ActivityCommand(ctx context.Context, data ActivityUpdate) error
GetVarCommand(ctx context.Context, data CommandVarData) (*CommandVarResponseData, error)
SetVarCommand(ctx context.Context, data CommandVarData) error
PathCommand(ctx context.Context, data PathCommandData) (string, error)
// connection functions
ConnStatusCommand(ctx context.Context) ([]ConnStatus, error)
WslStatusCommand(ctx context.Context) ([]ConnStatus, error)
ConnEnsureCommand(ctx context.Context, data ConnExtData) error
ConnReinstallWshCommand(ctx context.Context, data ConnExtData) error
ConnConnectCommand(ctx context.Context, connRequest ConnRequest) error
ConnDisconnectCommand(ctx context.Context, connName string) error
ConnListCommand(ctx context.Context) ([]string, error)
WslListCommand(ctx context.Context) ([]string, error)
WslDefaultDistroCommand(ctx context.Context) (string, error)
DismissWshFailCommand(ctx context.Context, connName string) error
ConnUpdateWshCommand(ctx context.Context, remoteInfo RemoteInfo) (bool, error)
// eventrecv is special, it's handled internally by WshRpc with EventListener
EventRecvCommand(ctx context.Context, data wps.WaveEvent) error
// remotes
RemoteStreamFileCommand(ctx context.Context, data CommandRemoteStreamFileData) chan RespOrErrorUnion[CommandRemoteStreamFileRtnData]
RemoteFileInfoCommand(ctx context.Context, path string) (*FileInfo, error)
RemoteFileTouchCommand(ctx context.Context, path string) error
RemoteFileRenameCommand(ctx context.Context, pathTuple [2]string) error
RemoteFileDeleteCommand(ctx context.Context, path string) error
RemoteWriteFileCommand(ctx context.Context, data CommandRemoteWriteFileData) error
RemoteFileJoinCommand(ctx context.Context, paths []string) (*FileInfo, error)
RemoteMkdirCommand(ctx context.Context, path string) error
RemoteStreamCpuDataCommand(ctx context.Context) chan RespOrErrorUnion[TimeSeriesData]
RemoteGetInfoCommand(ctx context.Context) (RemoteInfo, error)
RemoteInstallRcFilesCommand(ctx context.Context) error
// emain
WebSelectorCommand(ctx context.Context, data CommandWebSelectorData) ([]string, error)
NotifyCommand(ctx context.Context, notificationOptions WaveNotificationOptions) error
FocusWindowCommand(ctx context.Context, windowId string) error
WorkspaceListCommand(ctx context.Context) ([]WorkspaceInfoData, error)
GetUpdateChannelCommand(ctx context.Context) (string, error)
// terminal
VDomCreateContextCommand(ctx context.Context, data vdom.VDomCreateContext) (*waveobj.ORef, error)
VDomAsyncInitiationCommand(ctx context.Context, data vdom.VDomAsyncInitiationRequest) error
// ai
AiSendMessageCommand(ctx context.Context, data AiMessageData) error
// proc
VDomRenderCommand(ctx context.Context, data vdom.VDomFrontendUpdate) chan RespOrErrorUnion[*vdom.VDomBackendUpdate]
VDomUrlRequestCommand(ctx context.Context, data VDomUrlRequestData) chan RespOrErrorUnion[VDomUrlRequestResponse]
}
// for frontend
type WshServerCommandMeta struct {
CommandType string `json:"commandtype"`
}
type RpcOpts struct {
Timeout int `json:"timeout,omitempty"`
NoResponse bool `json:"noresponse,omitempty"`
Route string `json:"route,omitempty"`
StreamCancelFn func() `json:"-"` // this is an *output* parameter, set by the handler
}
const (
ClientType_ConnServer = "connserver"
ClientType_BlockController = "blockcontroller"
)
type RpcContext struct {
ClientType string `json:"ctype,omitempty"`
BlockId string `json:"blockid,omitempty"`
TabId string `json:"tabid,omitempty"`
Conn string `json:"conn,omitempty"`
}
func HackRpcContextIntoData(dataPtr any, rpcContext RpcContext) {
dataVal := reflect.ValueOf(dataPtr).Elem()
if dataVal.Kind() != reflect.Struct {
return
}
dataType := dataVal.Type()
for i := 0; i < dataVal.NumField(); i++ {
field := dataVal.Field(i)
if !field.IsZero() {
continue
}
fieldType := dataType.Field(i)
tag := fieldType.Tag.Get("wshcontext")
if tag == "" {
continue
}
switch tag {
case "BlockId":
field.SetString(rpcContext.BlockId)
case "TabId":
field.SetString(rpcContext.TabId)
case "BlockORef":
if rpcContext.BlockId != "" {
field.Set(reflect.ValueOf(waveobj.MakeORef(waveobj.OType_Block, rpcContext.BlockId)))
}
default:
log.Printf("invalid wshcontext tag: %q in type(%T)", tag, dataPtr)
}
}
}
type CommandAuthenticateRtnData struct {
RouteId string `json:"routeid"`
AuthToken string `json:"authtoken,omitempty"`
}
type CommandDisposeData struct {
RouteId string `json:"routeid"`
// auth token travels in the packet directly
}
type CommandMessageData struct {
ORef waveobj.ORef `json:"oref" wshcontext:"BlockORef"`
Message string `json:"message"`
}
type CommandGetMetaData struct {
ORef waveobj.ORef `json:"oref" wshcontext:"BlockORef"`
}
type CommandSetMetaData struct {
ORef waveobj.ORef `json:"oref" wshcontext:"BlockORef"`
Meta waveobj.MetaMapType `json:"meta"`
}
type CommandResolveIdsData struct {
BlockId string `json:"blockid" wshcontext:"BlockId"`
Ids []string `json:"ids"`
}
type CommandResolveIdsRtnData struct {
ResolvedIds map[string]waveobj.ORef `json:"resolvedids"`
}
type CommandCreateBlockData struct {
TabId string `json:"tabid" wshcontext:"TabId"`
BlockDef *waveobj.BlockDef `json:"blockdef"`
RtOpts *waveobj.RuntimeOpts `json:"rtopts,omitempty"`
Magnified bool `json:"magnified,omitempty"`
Ephemeral bool `json:"ephemeral,omitempty"`
}
type CommandCreateSubBlockData struct {
ParentBlockId string `json:"parentblockid"`
BlockDef *waveobj.BlockDef `json:"blockdef"`
}
type CommandBlockSetViewData struct {
BlockId string `json:"blockid" wshcontext:"BlockId"`
View string `json:"view"`
}
type CommandControllerResyncData struct {
ForceRestart bool `json:"forcerestart,omitempty"`
TabId string `json:"tabid" wshcontext:"TabId"`
BlockId string `json:"blockid" wshcontext:"BlockId"`
RtOpts *waveobj.RuntimeOpts `json:"rtopts,omitempty"`
}
type CommandControllerAppendOutputData struct {
BlockId string `json:"blockid"`
Data64 string `json:"data64"`
}
type CommandBlockInputData struct {
BlockId string `json:"blockid" wshcontext:"BlockId"`
InputData64 string `json:"inputdata64,omitempty"`
SigName string `json:"signame,omitempty"`
TermSize *waveobj.TermSize `json:"termsize,omitempty"`
}
type CommandFileDataAt struct {
Offset int64 `json:"offset"`
Size int64 `json:"size,omitempty"`
}
type CommandFileData struct {
ZoneId string `json:"zoneid" wshcontext:"BlockId"`
FileName string `json:"filename"`
Data64 string `json:"data64,omitempty"`
At *CommandFileDataAt `json:"at,omitempty"` // if set, this turns read/write ops to ReadAt/WriteAt ops (len is only used for ReadAt)
}
type WaveFileInfo struct {
ZoneId string `json:"zoneid"`
Name string `json:"name"`
Opts filestore.FileOptsType `json:"opts,omitempty"`
Size int64 `json:"size,omitempty"`
CreatedTs int64 `json:"createdts,omitempty"`
ModTs int64 `json:"modts,omitempty"`
Meta map[string]any `json:"meta,omitempty"`
IsDir bool `json:"isdir,omitempty"`
}
type CommandFileListData struct {
ZoneId string `json:"zoneid"`
Prefix string `json:"prefix,omitempty"`
All bool `json:"all,omitempty"`
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
}
type CommandFileCreateData struct {
ZoneId string `json:"zoneid"`
FileName string `json:"filename"`
Meta map[string]any `json:"meta,omitempty"`
Opts *filestore.FileOptsType `json:"opts,omitempty"`
}
type CommandAppendIJsonData struct {
ZoneId string `json:"zoneid" wshcontext:"BlockId"`
FileName string `json:"filename"`
Data ijson.Command `json:"data"`
}
type CommandWaitForRouteData struct {
RouteId string `json:"routeid"`
WaitMs int `json:"waitms"`
}
type CommandDeleteBlockData struct {
BlockId string `json:"blockid" wshcontext:"BlockId"`
}
type CommandEventReadHistoryData struct {
Event string `json:"event"`
Scope string `json:"scope"`
MaxItems int `json:"maxitems"`
}
type WaveAIStreamRequest struct {
ClientId string `json:"clientid,omitempty"`
Opts *WaveAIOptsType `json:"opts"`
Prompt []WaveAIPromptMessageType `json:"prompt"`
}
type WaveAIPromptMessageType struct {
Role string `json:"role"`
Content string `json:"content"`
Name string `json:"name,omitempty"`
}
type WaveAIOptsType struct {
Model string `json:"model"`
APIType string `json:"apitype,omitempty"`
APIToken string `json:"apitoken"`
OrgID string `json:"orgid,omitempty"`
APIVersion string `json:"apiversion,omitempty"`
BaseURL string `json:"baseurl,omitempty"`
MaxTokens int `json:"maxtokens,omitempty"`
MaxChoices int `json:"maxchoices,omitempty"`
TimeoutMs int `json:"timeoutms,omitempty"`
}
type WaveAIPacketType struct {
Type string `json:"type"`
Model string `json:"model,omitempty"`
Created int64 `json:"created,omitempty"`
FinishReason string `json:"finish_reason,omitempty"`
Usage *WaveAIUsageType `json:"usage,omitempty"`
Index int `json:"index,omitempty"`
Text string `json:"text,omitempty"`
Error string `json:"error,omitempty"`
}
type WaveAIUsageType struct {
PromptTokens int `json:"prompt_tokens,omitempty"`
CompletionTokens int `json:"completion_tokens,omitempty"`
TotalTokens int `json:"total_tokens,omitempty"`
}
type CpuDataRequest struct {
Id string `json:"id"`
Count int `json:"count"`
}
type CpuDataType struct {
Time int64 `json:"time"`
Value float64 `json:"value"`
}
type FileInfo struct {
Path string `json:"path"` // cleaned path (may have "~")
Dir string `json:"dir"` // returns the directory part of the path (if this is a a directory, it will be equal to Path). "~" will be expanded, and separators will be normalized to "/"
Name string `json:"name"`
NotFound bool `json:"notfound,omitempty"`
Size int64 `json:"size"`
Mode os.FileMode `json:"mode"`
ModeStr string `json:"modestr"`
ModTime int64 `json:"modtime"`
IsDir bool `json:"isdir,omitempty"`
MimeType string `json:"mimetype,omitempty"`
ReadOnly bool `json:"readonly,omitempty"` // this is not set for fileinfo's returned from directory listings
}
type CommandRemoteStreamFileData struct {
Path string `json:"path"`
ByteRange string `json:"byterange,omitempty"`
}
type CommandRemoteStreamFileRtnData struct {
FileInfo []*FileInfo `json:"fileinfo,omitempty"`
Data64 string `json:"data64,omitempty"`
}
type CommandRemoteWriteFileData struct {
Path string `json:"path"`
Data64 string `json:"data64"`
CreateMode os.FileMode `json:"createmode,omitempty"`
}
type ConnKeywords struct {
ConnWshEnabled *bool `json:"conn:wshenabled,omitempty"`
ConnAskBeforeWshInstall *bool `json:"conn:askbeforewshinstall,omitempty"`
ConnOverrideConfig bool `json:"conn:overrideconfig,omitempty"`
ConnWshPath string `json:"conn:wshpath,omitempty"`
ConnShellPath string `json:"conn:shellpath,omitempty"`
DisplayHidden *bool `json:"display:hidden,omitempty"`
DisplayOrder float32 `json:"display:order,omitempty"`
TermClear bool `json:"term:*,omitempty"`
TermFontSize float64 `json:"term:fontsize,omitempty"`
TermFontFamily string `json:"term:fontfamily,omitempty"`
TermTheme string `json:"term:theme,omitempty"`
SshUser *string `json:"ssh:user,omitempty"`
SshHostName *string `json:"ssh:hostname,omitempty"`
SshPort *string `json:"ssh:port,omitempty"`
SshIdentityFile []string `json:"ssh:identityfile,omitempty"`
SshIdentitiesOnly *bool `json:"ssh:identitiesonly,omitempty"`
SshBatchMode *bool `json:"ssh:batchmode,omitempty"`
SshPubkeyAuthentication *bool `json:"ssh:pubkeyauthentication,omitempty"`
SshPasswordAuthentication *bool `json:"ssh:passwordauthentication,omitempty"`
SshKbdInteractiveAuthentication *bool `json:"ssh:kbdinteractiveauthentication,omitempty"`
SshPreferredAuthentications []string `json:"ssh:preferredauthentications,omitempty"`
SshAddKeysToAgent *bool `json:"ssh:addkeystoagent,omitempty"`
SshIdentityAgent *string `json:"ssh:identityagent,omitempty"`
SshProxyJump []string `json:"ssh:proxyjump,omitempty"`
SshUserKnownHostsFile []string `json:"ssh:userknownhostsfile,omitempty"`
SshGlobalKnownHostsFile []string `json:"ssh:globalknownhostsfile,omitempty"`
}
type ConnRequest struct {
Host string `json:"host"`
Keywords ConnKeywords `json:"keywords,omitempty"`
LogBlockId string `json:"logblockid,omitempty"`
}
type RemoteInfo struct {
ClientArch string `json:"clientarch"`
ClientOs string `json:"clientos"`
ClientVersion string `json:"clientversion"`
Shell string `json:"shell"`
}
const (
TimeSeries_Cpu = "cpu"
)
type TimeSeriesData struct {
Ts int64 `json:"ts"`
Values map[string]float64 `json:"values"`
}
type MetaSettingsType struct {
waveobj.MetaMapType
}
func (m *MetaSettingsType) UnmarshalJSON(data []byte) error {
var metaMap waveobj.MetaMapType
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.UseNumber()
if err := decoder.Decode(&metaMap); err != nil {
return err
}
*m = MetaSettingsType{MetaMapType: metaMap}
return nil
}
func (m MetaSettingsType) MarshalJSON() ([]byte, error) {
return json.Marshal(m.MetaMapType)
}
type ConnConfigRequest struct {
Host string `json:"host"`
MetaMapType waveobj.MetaMapType `json:"metamaptype"`
}
type ConnStatus struct {
Status string `json:"status"`
WshEnabled bool `json:"wshenabled"`
Connection string `json:"connection"`
Connected bool `json:"connected"`
HasConnected bool `json:"hasconnected"` // true if it has *ever* connected successfully
ActiveConnNum int `json:"activeconnnum"`
Error string `json:"error,omitempty"`
WshError string `json:"wsherror,omitempty"`
NoWshReason string `json:"nowshreason,omitempty"`
WshVersion string `json:"wshversion,omitempty"`
}
type WebSelectorOpts struct {
All bool `json:"all,omitempty"`
Inner bool `json:"inner,omitempty"`
}
type CommandWebSelectorData struct {
WorkspaceId string `json:"workspaceid"`
BlockId string `json:"blockid" wshcontext:"BlockId"`
TabId string `json:"tabid" wshcontext:"TabId"`
Selector string `json:"selector"`
Opts *WebSelectorOpts `json:"opts,omitempty"`
}
type BlockInfoData struct {
BlockId string `json:"blockid"`
TabId string `json:"tabid"`
WorkspaceId string `json:"workspaceid"`
Block *waveobj.Block `json:"block"`
Files []*filestore.WaveFile `json:"files"`
}
type WaveNotificationOptions struct {
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
Silent bool `json:"silent,omitempty"`
}
type VDomUrlRequestData struct {
Method string `json:"method"`
URL string `json:"url"`
Headers map[string]string `json:"headers"`
Body []byte `json:"body,omitempty"`
}
type VDomUrlRequestResponse struct {
StatusCode int `json:"statuscode,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Body []byte `json:"body,omitempty"`
}
type WaveInfoData struct {
Version string `json:"version"`
ClientId string `json:"clientid"`
BuildTime string `json:"buildtime"`
ConfigDir string `json:"configdir"`
DataDir string `json:"datadir"`
}
type WorkspaceInfoData struct {
WindowId string `json:"windowid"`
WorkspaceData *waveobj.Workspace `json:"workspacedata"`
}
type AiMessageData struct {
Message string `json:"message,omitempty"`
}
type CommandVarData struct {
Key string `json:"key"`
Val string `json:"val,omitempty"`
Remove bool `json:"remove,omitempty"`
ZoneId string `json:"zoneid"`
FileName string `json:"filename"`
}
type CommandVarResponseData struct {
Key string `json:"key"`
Val string `json:"val"`
Exists bool `json:"exists"`
}
type PathCommandData struct {
PathType string `json:"pathtype"`
Open bool `json:"open"`
OpenExternal bool `json:"openexternal"`
TabId string `json:"tabid" wshcontext:"TabId"`
}
type ActivityDisplayType struct {
Width int `json:"width"`
Height int `json:"height"`
DPR float64 `json:"dpr"`
Internal bool `json:"internal,omitempty"`
}
type ActivityUpdate struct {
FgMinutes int `json:"fgminutes,omitempty"`
ActiveMinutes int `json:"activeminutes,omitempty"`
OpenMinutes int `json:"openminutes,omitempty"`
NumTabs int `json:"numtabs,omitempty"`
NewTab int `json:"newtab,omitempty"`
NumBlocks int `json:"numblocks,omitempty"`
NumWindows int `json:"numwindows,omitempty"`
NumWS int `json:"numws,omitempty"`
NumWSNamed int `json:"numwsnamed,omitempty"`
NumSSHConn int `json:"numsshconn,omitempty"`
NumWSLConn int `json:"numwslconn,omitempty"`
NumMagnify int `json:"nummagnify,omitempty"`
NumPanics int `json:"numpanics,omitempty"`
NumAIReqs int `json:"numaireqs,omitempty"`
Startup int `json:"startup,omitempty"`
Shutdown int `json:"shutdown,omitempty"`
SetTabTheme int `json:"settabtheme,omitempty"`
BuildTime string `json:"buildtime,omitempty"`
Displays []ActivityDisplayType `json:"displays,omitempty"`
Renderers map[string]int `json:"renderers,omitempty"`
Blocks map[string]int `json:"blocks,omitempty"`
WshCmds map[string]int `json:"wshcmds,omitempty"`
Conn map[string]int `json:"conn,omitempty"`
}
type ConnExtData struct {
ConnName string `json:"connname"`
LogBlockId string `json:"logblockid,omitempty"`
}