ldk

package module
v2.0.0-...-50fc115 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 18 Imported by: 19

README

Loop Development Kit (LDK) for Go

PLEASE NOTE: In order to provide a highly controlled and secure environment for our Loops, we will be transitioning to a JavaScript-only model and removing support for the C# and Go LDKs. This will also enable us to build additional features and Aptitudes more quickly. Please feel free to reach out to your Olive Helps developer contact if you have any questions.

Installation

go get -u github.com/open-olive/loop-development-kit/ldk/go/v2

Usage

Full documentation available on pkg.go.dev.

Loops

Loops receive events and use them to generate relevant whispers. Loops choose which events they want to use and which they want to ignore.

This LDK can be used to write loops for Olive Helps. An example of the loop implementation is available here.

Interface

Writing a loop boils down to writing an implementation for the Loop interface and serving it via ldk.ServeLoopPlugin.

type Loop interface {
	LoopStart(Sidekick) error
	LoopStop() error
}
func main() {
	// Instantiating Logger
	logger := ldk.NewLogger("demo-loop-go")

	// Instantiating Loop
	var loop ldk.Loop
	loop = &Loop{
		logger:         logger
	}

	ldk.ServeLoopPlugin(logger, loop) // ServeLoopPlugin, gives an ability to provide your own logger
}

LoopStart - The Loop should wait to start operating until this is called. The provided Sidekick reference should be stored in memory for continued use.

LoopStop - The Loop should stop operating when this is called.

Subscribing to Aptitudes

Inside LoopStart, you can subscribe to various aptitudes. Here's an example of subscribing to a couple:

func (c *Loop) LoopStart(sidekick ldk.Sidekick) error {
	// ...

	handler := func (text string, err error) {
		// Respond to aptitude event here...
	}

	// Indicates if clipboard activities received from internal Olive Help windows will be propagated to the handler
	includeOliveHelpTraffic := true
	// Clipboard Configuration which takes handler and Clipboard traffic trigger
	clipboardListenConfiguration := ClipboardListenConfiguration{Handler: handler, IncludeOliveHelpTraffic: includeOliveHelpTraffic}

	if err := sidekick.Clipboard().Listen(l.ctx, clipboardListenConfiguration); err != nil {
		return err
	}

	if err := sidekick.UI().ListenSearchbar(l.ctx, handler); err != nil {
		return err
	}
}

Loops do not need to emit whispers in a 1:1 relationship with events, and may not use events at all. They could use some events, keep a history of events, or emit whispers only when several conditions are met.

List of possible Aptitudes to subscribe to
type Sidekick interface {
	Clipboard() ClipboardService
	Vault() VaultService
	Whisper() WhisperService
	Keyboard() KeyboardService
	Process() ProcessService
	Cursor() CursorService
	Filesystem() FilesystemService
	Window() WindowService
	UI() UIService
	Network() NetworkService
}
Lifecycle
  1. Olive Helps executes plugin process.
  2. Olive Helps calls LoopStart, sending the Sidekick reference to the plugin.
  3. The loop subscribes to one or more aptitudes in LoopStart.
  4. When the loop is notified of an aptitudes event, it processes it and calls the Whisper method on the Sidekick reference to emit a whisper.
  5. On user disabling the loop, Olive Helps calls LoopStop then sends sigterm to the process.
  6. On Olive Helps shutdown, Olive Helps calls LoopStop then sends sigterm to the process.
Running Locally

Olive Helps lets you add a local command as Local Plugins:

  1. Open Olive Helps.
  2. Open the Loop Library:
    1. Click the Hamburger icon.
    2. Click Loop Library.
  3. Click the Install Local Plugin button:
  4. Select the working directory for the command.
  5. Enter the command to be executed, including any arguments.
  6. Click Install.

The command will be installed as a plugin. If you need to change the command or its arguments you'll need remove it and then add the new commands. If you are developing locally, it can be helpful to give it the go run command, as this will remove the need to recompile each time to check your changes:

go run main.go

Be sure that when you selected the working directory in Step 5 that it is the root of your project that has the main.go file located in it.

Troubleshooting and Debugging

Olive Helps logs are available in the following directories for your OS:

~/Library/Logs/Olive\ Helps   # MacOS
/var/log/Olive\ Helps         # Linux
%AppData%\Olive Helps\Logs\   # Windows
Tailing Logs

It can be useful to tail the log as you develop to see any errors, warnings, or info messages. To do so, you can issue any of the following commands:

Linux
tail -F /var/log/Olive\ Helps/*.log
Mac
tail -F ~/Library/Logs/Olive\ Helps/*.log
Windows

From Powershell (not a cmd shell):

Get-Content $env:AppData\Olive Helps\Logs\Olive Helps-2020.08.12-1dcc37a.log -Tail 10 –Wait

Note: File names may differ from the examples above.

Development

protoc

The LDK utilizes protoc to create the protobuf that defines the contract that is utilized by GRPC.

  • Install protobuf with Homebrew brew link protobuf
  • Make your changes to proto/ldk.proto
  • Then generate the new protobuf file with make proto/ldk.pb.go

Since proto/ldk.pb.go is auto-generated, do not edit this file directly.

Documentation

Overview

Package ldk is an LDK (loop development kit) for plugins for the Sidekick project.

The LDK is built with go-plugin (https://github.com/hashicorp/go-plugin), a HashiCorp plugin system used in several of their projects.

Plugins developed with this library are executed by Sidekick as separate processes. This ensures that crashes or instability in the plugin will not destabilize the Sidekick process.

Communication between Sidekick and the plugin is first initialized over stdio and then performed using gRPC (https://grpc.io/). On mac and linux the GRPC communication is sent over unix domain socket and on windows over local TCP socket.

In order for Sidekick to use a plugin, it must be compiled. Sidekick does not compile or interpret source code at runtime. A consequence of this is that plugins will need to be compiled for each operating system that they want to support.

Controllers

Controllers receive events and use them to generate relevant whispers. Controllers choose which events they want to use and which they want to ignore.

Controller Interface

Writing a Controller plugin boils down to writing an implementation for the Controller interface.

type Controller interface {
  OnEvent(Event) error
  Start(ControllerHost) error
  Stop() error
}

Start() - The Controller should wait to start operating until this is called. The provided `ControllerHost` should be stored in memory for continued use.

Stop() - The Controller should stop operating when this is called.

OnEvent() - The controller can use this to handle events that are broadcast by Sensors. Controllers do not need to emit events in a 1:1 relationship with events. Controllers may not use events at all. Controllers may only use some events. Controllers may keep a history of events and only emit whispers when several conditions are met.

Controller Lifecycle

1. Sidekick executes plugin process

2. Sidekick calls `Start`, sending the host connection information to the plugin. This connection information is used to create the `ControllerHost`. The `ControllerHost` interface allows the plugin to emit whispers.

3. On Controller wanting to emit a whisper, the Controller calls the `EmitWhisper` method on the host interface.

4. On Sensor event, Sidekick calls `OnEvent`, passing the event from the Sensor to the Controller. These events can be ignored or used at the Controller's choice.

5. On User disabling the Controller, Sidekick calls `Stop` then sends `sigterm` to the process.

6. On Sidekick shutdown, Sidekick calls `Stop` then sends `sigterm` to the process.*

Basic Controller Example

We recommend using this repo as a starting point when creating a new controller: https://github.com/open-olive/sidekick-controller-examplego

Sensors

A Sensor is a type of plugin that generates events. Events can be as simple as a chunk of text but allow for complicated information. Sensors do not choose which controllers get their events. They are simply emitting the events. The decision about which events to use is left to the controller.

Sensor Interface

Writing a Sensor plugin boils down to writing an implementation for the Sensor interface.

type Sensor interface {
  Start(SensorHost) error
  Stop() error
  OnEvent(Event) error
}

Start() - The Sensor should wait to start operating until this is called. The provided `SensorHost` should be stored in memory for continued use.

Stop() - The Sensor should stop operating when this is called.

OnEvent() - The sensor can use this to handle events from the Sidekick UI. Many aptitudes will not care about UI events, and in that case the function should just return `nil`.

Sensor Lifecycle

1. Sidekick executes plugin process

2. Sidekick calls `Start`, sending the host connection information to the plugin. This connection information is used to create the `SensorHost`. The `SensorHost` interface allows the plugin to emit events.

3. On Sensor wanting to emit an event, the Sensor calls the `EmitEvent` method on the host interface.

4. On Sidekick UI event, Sidekick calls `OnEvent`, passing the event to the Sensor. These events can be ignore or used at the Sensor's choice.

5. On User disabling the Sensor, Sidekick calls `Stop` then sends `sigterm` to the process.

6. On Sidekick shutdown, Sidekick calls `Stop` then sends `sigterm` to the process.

Index

Constants

View Source
const (
	// Alt on Windows, Command on Mac
	KeyModifierCommandAltLeft  = 1 << 0  //  00000000000000000000000000000001 -> 1
	KeyModifierCommandAltRight = 1 << 1  //  00000000000000000000000000000010 -> 2
	KeyModifierCommandAlt      = 1 << 2  //  00000000000000000000000000000100 -> 4
	KeyModifierControlLeft     = 1 << 3  //  00000000000000000000000000001000 -> 8
	KeyModifierControlRight    = 1 << 4  //  00000000000000000000000000010000 -> 16
	KeyModifierControl         = 1 << 5  //  00000000000000000000000000100000 -> 32
	KeyModifierMetaLeft        = 1 << 6  //  00000000000000000000000001000000 -> 64
	KeyModifierMetaRight       = 1 << 7  //  00000000000000000000000010000000 -> 128
	KeyModifierMeta            = 1 << 8  //  00000000000000000000000100000000 -> 256
	KeyModifierShiftLeft       = 1 << 9  //  00000000000000000000001000000000 -> 512
	KeyModifierShiftRight      = 1 << 10 //  00000000000000000000010000000000 -> 1024
	KeyModifierShift           = 1 << 11 //  00000000000000000000100000000000 -> 2048
)

generate this base formatted code from: https://play.golang.org/p/CukMdzwdU0P

View Source
const (
	ProcessActionUnknown = 0
	ProcessActionStarted = 1
	ProcessActionStopped = 2
)
View Source
const (
	// WindowActionUnknown is the state for an unknown window action
	WindowActionUnknown = 0

	// WindowActionFocused is the state for a window becoming focused
	WindowActionFocused = 1

	// WindowActionUnfocused is the state for a window becoming unfocused
	WindowActionUnfocused = 2

	// WindowActionOpened is the state for a window being opened
	WindowActionOpened = 3

	// WindowActionClosed is the state for a window being closed
	WindowActionClosed = 4

	// WindowActionMoved is the state for a window being moved
	WindowActionMoved = 5

	// WindowActionResized is the state for a window being resized
	WindowActionResized = 6

	// WindowActionTitleChanged is the state for a window title being changed
	WindowActionTitleChanged = 7
)

Variables

View Source
var ErrNoFile = errors.New("a file has not been opened or created")

ErrNoFile File is not initiated

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "BASIC_PLUGIN",
	MagicCookieValue: "hello",
}

Handshake is a collection of information used to initialize communication between plugin and host

View Source
var LoopPluginMap = map[string]plugin.Plugin{
	"loop": &LoopPlugin{},
}

LoopPluginMap is the map of plugins we can dispense.

Functions

func ServeLoopPlugin

func ServeLoopPlugin(logger *Logger, loop Loop)

ServeLoopPlugin serves a specific loop plugin.

Types

type Access

type Access string

Access is a grouping of entity type

const (
	// AccessUnknown is the access value used when the value is not known
	AccessUnknown Access = "unknown"

	// AccessUser is the value that allows only the user who submitted the plugin to access it
	AccessUser Access = "user"

	// AccessOrganization is the value that allows only users in the submitting user's organization to access the plugin
	AccessOrganization Access = "organization"

	// AccessPublic is the value that allows any user of Sidekick to access the plugin
	AccessPublic Access = "public"
)

type Authority

type Authority interface {
	CancelSession(string) error
	NewSession(string) (*Session, error)
	ValidateSession(*Session) error
}

type BrowserService

type BrowserService interface {
	ActiveURL(context.Context) (string, error)
	ListenActiveURL(context.Context, ListenActiveURLHandler) error
	SelectedText(context.Context) (SelectedText, error)
	ListenSelectedText(context.Context, ListenSelectedTextHandler) error
}

BrowserService is an interface that defines what methods are made available to the loops for interacting with a browser

type ClipboardClient

type ClipboardClient struct {
	// contains filtered or unexported fields
}

ClipboardClient is used by loops to facilitate communication with the clipboard service

func (*ClipboardClient) Listen

func (c *ClipboardClient) Listen(ctx context.Context, clipboardListenConfigurations ClipboardListenConfiguration) error

Listen is used by the loop to establish a stream for handling clipboard changes

func (*ClipboardClient) Read

func (c *ClipboardClient) Read(ctx context.Context) (string, error)

Read is used by the loop to get the current clipboard text

func (*ClipboardClient) Write

func (c *ClipboardClient) Write(ctx context.Context, text string) error

Write is used by the loop to write text to the clipboard

type ClipboardListenConfiguration

type ClipboardListenConfiguration struct {
	Handler                 ReadListenHandler
	IncludeOliveHelpTraffic bool
}

type ClipboardServer

type ClipboardServer struct {
	Impl ClipboardService
}

ClipboardServer is used by sidekick to process clipboard communication with a loop

func (*ClipboardServer) ClipboardRead

ClipboardRead is used by plugins to get the value of an entry

func (*ClipboardServer) ClipboardReadStream

ClipboardReadStream is used by plugins to get the value of an entry

func (*ClipboardServer) ClipboardWrite

func (m *ClipboardServer) ClipboardWrite(ctx context.Context, req *proto.ClipboardWriteRequest) (*emptypb.Empty, error)

ClipboardWrite is used by plugins to set an entry

type ClipboardService

type ClipboardService interface {
	Read(context.Context) (string, error)
	Listen(context.Context, ClipboardListenConfiguration) error
	Write(context.Context, string) error
}

ClipboardService is an interface that defines what methods are made available to the loops for interacting with the clipboard

type Config

type Config map[string]string

Config is a type used to store the configuration parameters of a plugin

type CursorClient

type CursorClient struct {
	// contains filtered or unexported fields
}

func (*CursorClient) ListenPosition

func (c *CursorClient) ListenPosition(ctx context.Context, handler ListenPositionHandler) error

func (*CursorClient) Position

func (c *CursorClient) Position(ctx context.Context) (CursorPosition, error)

type CursorPosition

type CursorPosition struct {
	X int
	Y int
}

type CursorServer

type CursorServer struct {
	Impl CursorService
}

func (*CursorServer) CursorPosition

func (*CursorServer) CursorPositionStream

type CursorService

type CursorService interface {
	Position(context.Context) (CursorPosition, error)
	ListenPosition(context.Context, ListenPositionHandler) error
}

CursorService is an interface that defines what methods plugins can expect from the host

type Event

type Event struct {
	Data   map[string]string `json:"data"`
	Source Source            `json:"source"`
}

Event is a structure that defines a sensor event

func NewTextEvent

func NewTextEvent(text string) Event

NewTextEvent generates a new event with the given text

func (*Event) Text

func (e *Event) Text() string

Text is a shortcut for returning Event.Data["text"]

type ExceptionLoggingInterceptor

type ExceptionLoggingInterceptor struct {
	// contains filtered or unexported fields
}

func (*ExceptionLoggingInterceptor) Invoke

func (eli *ExceptionLoggingInterceptor) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...grpc.CallOption) error

func (*ExceptionLoggingInterceptor) NewStream

func (eli *ExceptionLoggingInterceptor) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)

type File

type File interface {
	Read([]byte) (int, error)
	Write([]byte) (int, error)
	Close() error
	Chmod(os.FileMode) error
	Chown(int, int) error
	Stat() (os.FileInfo, error)
	Sync() error
}

File this is a file

type FileAction

type FileAction int
const (
	FileActionUnknown FileAction = 0
	FileActionCreate  FileAction = 1
	FileActionWrite   FileAction = 2
	FileActionRemove  FileAction = 3
	FileActionRename  FileAction = 4
	FileActionChmod   FileAction = 5
)

func (FileAction) String

func (f FileAction) String() string

type FileEvent

type FileEvent struct {
	Info   os.FileInfo
	Action FileAction
}

type FileInfo

type FileInfo struct {
	// contains filtered or unexported fields
}

func NewFileInfo

func NewFileInfo(name string, mode, size int, updated time.Time, isDir bool) FileInfo

func (*FileInfo) IsDir

func (f *FileInfo) IsDir() bool

func (*FileInfo) ModTime

func (f *FileInfo) ModTime() time.Time

func (*FileInfo) Mode

func (f *FileInfo) Mode() os.FileMode

func (*FileInfo) Name

func (f *FileInfo) Name() string

func (*FileInfo) Size

func (f *FileInfo) Size() int64

func (*FileInfo) Sys

func (f *FileInfo) Sys() interface{}

type FilesystemClient

type FilesystemClient struct {
	// contains filtered or unexported fields
}

FilesystemClient is used by the controller plugin to facilitate plugin initiated communication with the host

func (*FilesystemClient) Copy

func (f *FilesystemClient) Copy(ctx context.Context, source, dest string) error

Copy file or directory

func (*FilesystemClient) Create

func (f *FilesystemClient) Create(ctx context.Context, path string) (File, error)

func (*FilesystemClient) Dir

func (f *FilesystemClient) Dir(ctx context.Context, dir string) ([]os.FileInfo, error)

Dir list the contents of a directory

func (*FilesystemClient) ListenDir

func (f *FilesystemClient) ListenDir(ctx context.Context, dir string, handler ListenDirHandler) error

ListenDir stream any updates to the contents of a directory

func (*FilesystemClient) ListenFile

func (f *FilesystemClient) ListenFile(ctx context.Context, path string, handler ListenFileHandler) error

ListenFile stream any updates to a file

func (*FilesystemClient) MakeDir

func (f *FilesystemClient) MakeDir(ctx context.Context, path string, perm uint32) error

MakeDir create new directory

func (*FilesystemClient) Move

func (f *FilesystemClient) Move(ctx context.Context, source, dest string) error

Move file or directory

func (*FilesystemClient) Open

func (f *FilesystemClient) Open(ctx context.Context, path string) (File, error)

Open something

func (*FilesystemClient) Remove

func (f *FilesystemClient) Remove(ctx context.Context, path string, recursive bool) error

Remove file or directory

type FilesystemServer

type FilesystemServer struct {
	Impl FilesystemService
}

FilesystemServer is used by the controller plugin host to receive plugin initiated communication

func (*FilesystemServer) FilesystemCopy

func (f *FilesystemServer) FilesystemCopy(ctx context.Context, req *proto.FilesystemCopyRequest) (*emptypb.Empty, error)

FilesystemCopy copies a file or directory to a new directory

func (*FilesystemServer) FilesystemDir

FilesystemDir list the contents of a directory

func (*FilesystemServer) FilesystemDirStream

FilesystemDirStream stream any updates to the contents of a directory

func (*FilesystemServer) FilesystemFileInfoStream

FilesystemFileInfoStream stream any updates to a file

func (*FilesystemServer) FilesystemFileStream

func (f *FilesystemServer) FilesystemFileStream(stream proto.Filesystem_FilesystemFileStreamServer) error

FilesystemFileStream write data to a file

func (*FilesystemServer) FilesystemMakeDir

func (f *FilesystemServer) FilesystemMakeDir(ctx context.Context, req *proto.FilesystemMakeDirRequest) (*emptypb.Empty, error)

FilesystemMakeDir creates new directory

func (*FilesystemServer) FilesystemMove

func (f *FilesystemServer) FilesystemMove(ctx context.Context, req *proto.FilesystemMoveRequest) (*emptypb.Empty, error)

FilesystemMove moves a file or directory to a new directory

func (*FilesystemServer) FilesystemRemove

func (f *FilesystemServer) FilesystemRemove(ctx context.Context, req *proto.FilesystemRemoveRequest) (*emptypb.Empty, error)

FilesystemRemove removes a file or directory to a new directory

type FilesystemService

FilesystemService is an interface that defines what methods plugins can expect from the host

type GRPCFile

type GRPCFile struct {
	// contains filtered or unexported fields
}

func (*GRPCFile) Chmod

func (f *GRPCFile) Chmod(mode os.FileMode) error

Chmod changes permissions of file

func (*GRPCFile) Chown

func (f *GRPCFile) Chown(uid, gid int) error

Chown changes owner of file

func (*GRPCFile) Close

func (f *GRPCFile) Close() error

Close closes file

func (*GRPCFile) Read

func (f *GRPCFile) Read(p []byte) (int, error)

func (*GRPCFile) Stat

func (f *GRPCFile) Stat() (os.FileInfo, error)

Stat get info of file

func (*GRPCFile) Sync

func (f *GRPCFile) Sync() error

func (*GRPCFile) Write

func (f *GRPCFile) Write(b []byte) (int, error)

type HTTPRequest

type HTTPRequest struct {
	URL       string
	Method    string
	Body      []byte
	Headers   map[string][]string
	TimeoutMs *int
}

HTTPRequest is the structure received from HttpRequest

type HTTPResponse

type HTTPResponse struct {
	ResponseCode int
	Data         []byte
	Headers      map[string][]string
}

HTTPResponse is the structure received from HttpRequest

type Hotkey

type Hotkey struct {
	Key       rune
	Modifiers KeyModifier
}

func (Hotkey) Match

func (h Hotkey) Match(v Hotkey) bool

This function takes the hotkey param (which is understood to be the actual hotkey combination provided by the keyboard service) and compares it against the receiver's configuration. It is expected that the actual value provided will set both the position bit (left/right) and the either side value to true.

type HoverService

type HoverService interface {
	Read() (string, error)
	ListenRead(context.Context, ListenReadHandler) error
}

HoverService is an interface that defines what methods plugins can expect from the host

type KeyModifier

type KeyModifier int

func (KeyModifier) Alt

func (k KeyModifier) Alt() bool

func (KeyModifier) AltGroup

func (k KeyModifier) AltGroup() KeyModifierGroup

func (KeyModifier) AltLeft

func (k KeyModifier) AltLeft() bool

func (KeyModifier) AltRight

func (k KeyModifier) AltRight() bool

func (KeyModifier) Control

func (k KeyModifier) Control() bool

func (KeyModifier) ControlGroup

func (k KeyModifier) ControlGroup() KeyModifierGroup

func (KeyModifier) ControlLeft

func (k KeyModifier) ControlLeft() bool

func (KeyModifier) ControlRight

func (k KeyModifier) ControlRight() bool

func (KeyModifier) Meta

func (k KeyModifier) Meta() bool

func (KeyModifier) MetaGroup

func (k KeyModifier) MetaGroup() KeyModifierGroup

func (KeyModifier) MetaLeft

func (k KeyModifier) MetaLeft() bool

func (KeyModifier) MetaRight

func (k KeyModifier) MetaRight() bool

func (KeyModifier) Shift

func (k KeyModifier) Shift() bool

func (KeyModifier) ShiftGroup

func (k KeyModifier) ShiftGroup() KeyModifierGroup

func (KeyModifier) ShiftLeft

func (k KeyModifier) ShiftLeft() bool

func (KeyModifier) ShiftRight

func (k KeyModifier) ShiftRight() bool

type KeyModifierGroup

type KeyModifierGroup struct {
	Either bool
	Left   bool
	Right  bool
}

func (KeyModifierGroup) MatchesActual

func (k KeyModifierGroup) MatchesActual(a KeyModifierGroup) bool

type KeyboardClient

type KeyboardClient struct {
	// contains filtered or unexported fields
}

KeyboardClient is used by the controller plugin to facilitate plugin initiated communication with the host

func (*KeyboardClient) ListenCharacter

func (k *KeyboardClient) ListenCharacter(ctx context.Context, handler ListenCharacterHandler) error

ListenCharacter will call the handler for each character typed on the keyboard

func (*KeyboardClient) ListenHotkey

func (k *KeyboardClient) ListenHotkey(ctx context.Context, hotkey Hotkey, handler ListenHotkeyHandler) error

ListenHotkey will listen for a specific set of hotkeys and call the handler for each press up or down

func (*KeyboardClient) ListenText

func (k *KeyboardClient) ListenText(ctx context.Context, keyboardListenTextConfiguration KeyboardListenTextConfiguration) error

ListenText will call the handler when a chunk of text has been captured from the keyboard

type KeyboardListenTextConfiguration

type KeyboardListenTextConfiguration struct {
	Handler                  ListenTextHandler
	IncludeOliveHelpsTraffic bool
}

type KeyboardServer

type KeyboardServer struct {
	Impl KeyboardService
}

KeyboardServer is used by the controller plugin host to receive plugin initiated communication This runs on Sidekick

func (*KeyboardServer) KeyboardCharacterStream

KeyboardCharacterStream streams characters as the are typed

func (*KeyboardServer) KeyboardHotkeyStream

KeyboardHotkeyStream registers a hotkey and receive streamed messages when it is pressed

func (*KeyboardServer) KeyboardTextStream

KeyboardTextStream streams chunks of text when the user finishes typing them

type KeyboardService

type KeyboardService interface {
	ListenHotkey(context.Context, Hotkey, ListenHotkeyHandler) error
	ListenText(context.Context, KeyboardListenTextConfiguration) error
	ListenCharacter(context.Context, ListenCharacterHandler) error
}

KeyboardService is an interface that defines what methods plugins can expect from the host

type ListenActiveURLHandler

type ListenActiveURLHandler func(string, error)

ListenActiveURLHandler is the signature for a handler than handles changes to the Active URL

type ListenActiveWindowHandler

type ListenActiveWindowHandler func(WindowInfo, error)

ListenActiveWindowHandler is the signature for a handler than handles changes to the active window

type ListenCharacterHandler

type ListenCharacterHandler func(rune, error)

type ListenDirHandler

type ListenDirHandler func(FileEvent, error)

type ListenFileHandler

type ListenFileHandler func(FileEvent, error)

type ListenHotkeyHandler

type ListenHotkeyHandler func(scanned bool, err error)

ListenHotkeyHandler will return `true` if the hotkey/combination was pressed

type ListenPositionHandler

type ListenPositionHandler func(CursorPosition, error)

type ListenProcessStateHandler

type ListenProcessStateHandler func(ProcessEvent, error)

type ListenReadHandler

type ListenReadHandler func(string, error)

type ListenSearchHandler

type ListenSearchHandler func(string, error)

type ListenSelectedTextHandler

type ListenSelectedTextHandler func(SelectedText, error)

ListenSelectedTextHandler is the signature for a handler than handles changes to the selected text

type ListenTextHandler

type ListenTextHandler func(string, error)

type ListenWindowStateHandler

type ListenWindowStateHandler func(WindowEvent, error)

ListenWindowStateHandler is the signature for a handler than handles changes to window state

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is a logger implementation, which wraps an hclog Logger.

func NewLogger

func NewLogger(name string) *Logger

NewLogger returns a configured logger.

func (*Logger) Debug

func (l *Logger) Debug(msg string, args ...interface{})

Debug emits the message and args at DEBUG level.

func (*Logger) Error

func (l *Logger) Error(msg string, args ...interface{})

Error emits the message and args at ERROR level.

func (*Logger) Info

func (l *Logger) Info(msg string, args ...interface{})

Info emits the message and args at INFO level.

func (*Logger) Logger

func (l *Logger) Logger() hclog.Logger

Logger returns the underlying logger.

func (*Logger) Trace

func (l *Logger) Trace(msg string, args ...interface{})

Trace emits the message and args at TRACE level.

func (*Logger) Warn

func (l *Logger) Warn(msg string, args ...interface{})

Warn emits the message and args at WARN level.

func (*Logger) With

func (l *Logger) With(args ...interface{}) *Logger

With creates a sublogger that will always have the given key/value pairs.

type Loop

type Loop interface {
	LoopStart(Sidekick) error
	LoopStop() error
}

Loop is an interface that defines the methods required of all loop plugins

type LoopClient

type LoopClient struct {
	// contains filtered or unexported fields
}

LoopClient is used by the controller plugin host to facilitate host initiated communication with controller plugins

func (*LoopClient) LoopStart

func (m *LoopClient) LoopStart(ctx context.Context, host Sidekick, session *Session) error

LoopStart is called by the host when the plugin is started to provide access to the host process

func (*LoopClient) LoopStop

func (m *LoopClient) LoopStop(ctx context.Context) error

LoopStop is called by the host when the plugin is stopped

type LoopPlugin

type LoopPlugin struct {
	plugin.NetRPCUnsupportedPlugin
	Impl Loop
	// contains filtered or unexported fields
}

LoopPlugin is a structure used to define the parameters of the plugin communication

func (*LoopPlugin) GRPCClient

func (p *LoopPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

GRPCClient is used to generate controller clients that can be used by the host

func (*LoopPlugin) GRPCServer

func (p *LoopPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

GRPCServer is used to register the controller plugin with the GRPC server

type LoopServer

type LoopServer struct {
	Impl Loop
	// contains filtered or unexported fields
}

LoopServer is used by the controller plugin to receive host initiated communication

func (*LoopServer) LoopStart

func (m *LoopServer) LoopStart(_ context.Context, req *proto.LoopStartRequest) (*emptypb.Empty, error)

LoopStart is called by the host when the plugin is started to provide access to the host process

func (*LoopServer) LoopStop

func (m *LoopServer) LoopStop(_ context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

LoopStop is called by the host when the plugin is stopped

type Metadata

type Metadata struct {
	// Author is the creator of the entity.
	Author string `json:"author" yaml:"author"`

	// Created is the time when the entity was created.
	Created time.Time `json:"created" yaml:"created"`

	// Description is a short explanation of the entity.
	Description string `json:"description" yaml:"description"`

	// Entrypoint is the path to the binary or the command (relative to the working directory)
	// to run on plugin start (defaults to "plugin"/"plugin.exe").
	Entrypoint []string `json:"entrypoint" yaml:"entrypoint"`

	// ID is a unique identifier for this entity that is consistent across all versions
	// and modifications of this entity.
	ID string `json:"id" yaml:"id"`

	// Name is a human readable identifier for this entity.
	Name string `json:"name" yaml:"name"`

	// Organization is the name of the organization to which the Author belongs.
	Organization string `json:"organization" yaml:"organization"`

	// Specification is a string indication which version
	// of the specification is being used to describe this entity.
	Specification string `json:"specification" yaml:"specification"`

	// Updated is the time when the entity was last updated.
	Updated time.Time `json:"updated" yaml:"updated"`

	// UploadID is the unique upload identifier for this entity that is specific to this
	// exact version of this entity. Unlike the ID, the UploadID will change with every
	// version and between operating systems.
	UploadID string `json:"uploadId" yaml:"uploadId"`

	// Version is a semver version of this entity.
	Version string `json:"version" yaml:"version"`
}

Metadata is data about an entity.

type NetworkClient

type NetworkClient struct {
	// contains filtered or unexported fields
}

NetworkClient is the client used by the NetworkService

func (*NetworkClient) HTTPRequest

func (n *NetworkClient) HTTPRequest(ctx context.Context, req *HTTPRequest) (*HTTPResponse, error)

type NetworkServer

type NetworkServer struct {
	Impl NetworkService
}

func (*NetworkServer) HTTPRequest

type NetworkService

type NetworkService interface {
	HTTPRequest(ctx context.Context, req *HTTPRequest) (*HTTPResponse, error)
}

type OperatingSystem

type OperatingSystem string

OperatingSystem is a grouping of entity type

const (
	// OperatingSystemUnknown is the OS value used when the OS is not known
	OperatingSystemUnknown OperatingSystem = "unknown"

	// OperatingSystemWindows is the OS value used for Windows
	OperatingSystemWindows OperatingSystem = "win32"

	// OperatingSystemMacOS is the OS value used for MacOS
	OperatingSystemMacOS OperatingSystem = "darwin"

	// OperatingSystemLinux is the OS value used for Linux
	OperatingSystemLinux OperatingSystem = "linux"

	// OperatingSystemAny is the OS value used a plugin is available on any OS
	OperatingSystemAny OperatingSystem = "any"
)

type ProcessAction

type ProcessAction int

type ProcessClient

type ProcessClient struct {
	// contains filtered or unexported fields
}

func (*ProcessClient) ListenState

func (p *ProcessClient) ListenState(ctx context.Context, handler ListenProcessStateHandler) error

func (*ProcessClient) State

func (p *ProcessClient) State(ctx context.Context) ([]ProcessInfo, error)

type ProcessEvent

type ProcessEvent struct {
	Process ProcessInfo
	Action  ProcessAction
}

type ProcessInfo

type ProcessInfo struct {
	Arguments string
	Command   string
	PID       int
}

type ProcessServer

type ProcessServer struct {
	Impl ProcessService
}

func (*ProcessServer) ProcessState

func (*ProcessServer) ProcessStateStream

type ProcessService

type ProcessService interface {
	State(context.Context) ([]ProcessInfo, error)
	ListenState(context.Context, ListenProcessStateHandler) error
}

ProcessService is an interface that defines what methods plugins can expect from the host

type ReadListenHandler

type ReadListenHandler func(string, error)

ReadListenHandler is the signature for a handler than handles changes to the clipboard text

type SelectedText

type SelectedText struct {
	TabTitle string
	Text     string
	URL      string
}

SelectedText is a struct containing information about the text selected by the user in the browser

type Session

type Session struct {
	LoopID string `json:"loopId"`
	Token  string `json:"-"`
}

func NewSessionFromProto

func NewSessionFromProto(session *proto.Session) (*Session, error)

func (*Session) ToProto

func (s *Session) ToProto() *proto.Session

type Sidekick

type Sidekick interface {
	Clipboard() ClipboardService
	Vault() VaultService
	Whisper() WhisperService
	Keyboard() KeyboardService
	Process() ProcessService
	Cursor() CursorService
	Filesystem() FilesystemService
	Window() WindowService
	UI() UIService
	Network() NetworkService
}

Sidekick is an interface that defines what methods plugins can expect from the host

type SidekickClient

type SidekickClient struct {
	// contains filtered or unexported fields
}

SidekickClient is used by Loops to interact with the host system through Sidekick

func (*SidekickClient) Clipboard

func (m *SidekickClient) Clipboard() ClipboardService

Clipboard is used interact with the clipboard

func (*SidekickClient) Cursor

func (m *SidekickClient) Cursor() CursorService

Cursor is used to listen for the cursor position and related events

func (*SidekickClient) Filesystem

func (m *SidekickClient) Filesystem() FilesystemService

Filesystem is used to interact with the host system's filesystem

func (*SidekickClient) Keyboard

func (m *SidekickClient) Keyboard() KeyboardService

Keyboard is used to listen for keyboard events like keystrokes and hot-keys

func (*SidekickClient) Network

func (m *SidekickClient) Network() NetworkService

Network is used to send/receive HTTP requests

func (*SidekickClient) Process

func (m *SidekickClient) Process() ProcessService

Process is used to list processes and listen for new user processes

func (*SidekickClient) UI

func (m *SidekickClient) UI() UIService

UI is used to listen for user interface events occurring in Sidekick, like search bar entry

func (*SidekickClient) Vault

func (m *SidekickClient) Vault() VaultService

The Vault is used to store and retrieve sensitive data

func (*SidekickClient) Whisper

func (m *SidekickClient) Whisper() WhisperService

Whisper is used to send whispers to Sidekick

func (*SidekickClient) Window

func (m *SidekickClient) Window() WindowService

Window is used to listen for the active window, and other window related events

type SidekickServer

type SidekickServer struct {
	// This is the real implementation
	Impl Sidekick

	Metadata Metadata
}

SidekickServer is used by the controller plugin host to receive plugin initiated communication

func (*SidekickServer) Vault

func (m *SidekickServer) Vault() VaultService

The Vault is used to store and retrieve sensitive data

func (*SidekickServer) Whisper

func (m *SidekickServer) Whisper() WhisperService

Whisper is used to send whispers to Sidekick

type Source

type Source struct {
	// Author is the creator of the entity.
	Author string `json:"author" yaml:"author"`

	// ID is a unique identifier for this entity that is consistent across all versions
	// and modifications of this entity.
	ID string `json:"id" yaml:"id"`

	// Name is a human readable identifier for this entity.
	Name string `json:"name" yaml:"name"`

	// Organization is the name of the organization to which the Author belongs.
	Organization string `json:"organization" yaml:"organization"`

	// UploadID is the unique upload identifier for this entity that is specific to this
	// exact version of this entity. Unlike the ID, the UploadID will change with every
	// version and between operating systems.
	UploadID string `json:"uploadId" yaml:"uploadId"`

	// Version is a semver version of this entity.
	Version string `json:"version" yaml:"version"`
}

Source is information about the origin of the data.

type UIClient

type UIClient struct {
	// contains filtered or unexported fields
}

UIClient is used to hook into UI events such as listening to search controls.

func (*UIClient) ListenGlobalSearch

func (u *UIClient) ListenGlobalSearch(ctx context.Context, handler ListenSearchHandler) error

ListenGlobalSearch allows you to listen to global search (omnibar) events.

func (*UIClient) ListenSearchbar

func (u *UIClient) ListenSearchbar(ctx context.Context, handler ListenSearchHandler) error

ListenSearchbar allows you to listen to searchbar events.

type UIServer

type UIServer struct {
	Impl UIService
}

func (*UIServer) GlobalSearchStream

func (u *UIServer) GlobalSearchStream(req *proto.GlobalSearchStreamRequest, server proto.UI_GlobalSearchStreamServer) error

func (*UIServer) SearchbarStream

func (u *UIServer) SearchbarStream(req *proto.SearchbarStreamRequest, server proto.UI_SearchbarStreamServer) error

type UIService

type UIService interface {
	ListenSearchbar(context.Context, ListenSearchHandler) error
	ListenGlobalSearch(context.Context, ListenSearchHandler) error
}

UIService is an interface that defines what methods plugins can expect from the UI

type VaultClient

type VaultClient struct {
	// contains filtered or unexported fields
}

VaultClient is used by loops to make vault vault service requests

func (*VaultClient) Delete

func (s *VaultClient) Delete(ctx context.Context, key string) error

Delete is used by loops to delete a vault entry

func (*VaultClient) Exists

func (s *VaultClient) Exists(ctx context.Context, key string) (bool, error)

Exists is used by loops to check if a key exists in the vault

func (*VaultClient) Read

func (s *VaultClient) Read(ctx context.Context, key string) (string, error)

Read is used by loops to get the value of an entry

func (*VaultClient) Write

func (s *VaultClient) Write(ctx context.Context, key, value string) error

Write is used by plugins to set a vault entry value

type VaultServer

type VaultServer struct {
	Impl VaultService
}

VaultServer is used by the host to receive vault vault requests

func (*VaultServer) VaultDelete

func (m *VaultServer) VaultDelete(ctx context.Context, req *proto.VaultDeleteRequest) (*emptypb.Empty, error)

Delete is used by loops to delete a vault entry

func (*VaultServer) VaultExists

Exists is used by loops to check if a key exists in the vault

func (*VaultServer) VaultRead

Read is used by loops to get the value of an entry

func (*VaultServer) VaultWrite

func (m *VaultServer) VaultWrite(ctx context.Context, req *proto.VaultWriteRequest) (*emptypb.Empty, error)

Write is used by loops to set an entry

type VaultService

type VaultService interface {
	Delete(context.Context, string) error
	Exists(context.Context, string) (bool, error)
	Read(context.Context, string) (string, error)
	Write(context.Context, string, string) error
}

The VaultService provides Loop developers with a way to store and retrieve credentials and other small pieces of sensitive information.

type WhisperClient

type WhisperClient struct {
	// contains filtered or unexported fields
}

WhisperClient is used by the controller plugin to facilitate plugin initiated communication with the host

func (*WhisperClient) Confirm

func (m *WhisperClient) Confirm(ctx context.Context, content *WhisperContentConfirm) (bool, error)

Confirm is used by loops to create confirm whispers This method is blocking until the Whisper is closed, or the context provided is cancelled.

func (*WhisperClient) Disambiguation

func (m *WhisperClient) Disambiguation(ctx context.Context, content *WhisperContentDisambiguation) (bool, error)

Disambiguation is used by loops to create disambiguation whispers This method is blocking until the Whisper is closed, or the context provided is cancelled.

func (*WhisperClient) Form

Form is used by loops to create form whispers This method is blocking until the Whisper is closed, or the context provided is cancelled.

func (*WhisperClient) List

func (m *WhisperClient) List(ctx context.Context, content *WhisperContentList) error

List is used by loops to create list whispers This method is blocking until the Whisper is closed, or the context provided is cancelled.

func (*WhisperClient) Markdown

func (m *WhisperClient) Markdown(ctx context.Context, content *WhisperContentMarkdown) error

Markdown is used by loops to create markdown whispers This method is blocking until the Whisper is closed, or the context provided is cancelled.

type WhisperContent

type WhisperContent interface {
	Type() WhisperContentType
}

WhisperContent is an interface for the different types of whisper content

type WhisperContentConfirm

type WhisperContentConfirm struct {
	Label string `json:"label"`

	Markdown string `json:"markdown"`

	RejectLabel  string `json:"rejectLabel"`
	ResolveLabel string `json:"resolveLabel"`
}

func (*WhisperContentConfirm) Type

Type returns the type of the whisper content

type WhisperContentDisambiguation

type WhisperContentDisambiguation struct {
	Label    string                                         `json:"label"`
	Markdown string                                         `json:"markdown"`
	Elements map[string]WhisperContentDisambiguationElement `json:"elements"`
}

func (*WhisperContentDisambiguation) ToProto

func (*WhisperContentDisambiguation) Type

Type returns the type of the whisper content

type WhisperContentDisambiguationElement

type WhisperContentDisambiguationElement interface {
	MarshalJSON() ([]byte, error)
	ToProto() (*proto.WhisperDisambiguationElement, error)
	Type() WhisperContentDisambiguationElementType
}

type WhisperContentDisambiguationElementOption

type WhisperContentDisambiguationElementOption struct {
	Label    string       `json:"label"`
	Order    uint32       `json:"order"`
	OnChange func(string) `json:"-"`
}

WhisperContentDisambiguationElementOption defines an option the user can select

func (*WhisperContentDisambiguationElementOption) MarshalJSON

func (*WhisperContentDisambiguationElementOption) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentDisambiguationElementOption) Type

Type returns the type of field for this form element

type WhisperContentDisambiguationElementText

type WhisperContentDisambiguationElementText struct {
	Body  string `json:"body"` // Markdown syntax to support different header sizes
	Order uint32 `json:"order"`
}

WhisperContentDisambiguationElementText defines a text element for a disambiguation whisper

func (*WhisperContentDisambiguationElementText) MarshalJSON

func (e *WhisperContentDisambiguationElementText) MarshalJSON() ([]byte, error)

func (*WhisperContentDisambiguationElementText) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentDisambiguationElementText) Type

Type returns the type of field for this form element

type WhisperContentDisambiguationElementType

type WhisperContentDisambiguationElementType string
const (
	WhisperContentDisambiguationElementTypeOption WhisperContentDisambiguationElementType = "option"
)
const (
	WhisperContentDisambiguationElementTypeText WhisperContentDisambiguationElementType = "text"
)

type WhisperContentForm

type WhisperContentForm struct {
	Label string `json:"label"`

	Markdown string                             `json:"markdown"`
	Inputs   map[string]WhisperContentFormInput `json:"inputs"`

	CancelLabel string `json:"cancelLabel"`
	SubmitLabel string `json:"submitLabel"`
}

func (*WhisperContentForm) Type

Type returns the type of the whisper content

type WhisperContentFormInput

type WhisperContentFormInput interface {
	MarshalJSON() ([]byte, error)
	ToProto() (*proto.WhisperFormInput, error)
	Type() WhisperContentFormType
}

type WhisperContentFormInputCheckbox

type WhisperContentFormInputCheckbox struct {
	Label    string     `json:"label"`
	Tooltip  string     `json:"tooltip"`
	Value    bool       `json:"value"`
	OnChange func(bool) `json:"-"`
	Order    uint32     `json:"order"`
}

WhisperContentFormInputCheckbox defines a checkbox field in a form

func (*WhisperContentFormInputCheckbox) MarshalJSON

func (fc *WhisperContentFormInputCheckbox) MarshalJSON() ([]byte, error)

func (*WhisperContentFormInputCheckbox) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormInputCheckbox) Type

Type returns the type of field for this form element

type WhisperContentFormInputEmail

type WhisperContentFormInputEmail struct {
	Label    string       `json:"label"`
	Tooltip  string       `json:"tooltip"`
	Value    string       `json:"value"`
	OnChange func(string) `json:"-"`
	Order    uint32       `json:"order"`
}

WhisperContentFormInputEmail defines an email field in a form

func (*WhisperContentFormInputEmail) MarshalJSON

func (fc *WhisperContentFormInputEmail) MarshalJSON() ([]byte, error)

func (*WhisperContentFormInputEmail) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormInputEmail) Type

Type returns the type of field for this form element

type WhisperContentFormInputMarkdown

type WhisperContentFormInputMarkdown struct {
	Label    string       `json:"label"`
	Tooltip  string       `json:"tooltip"`
	Value    string       `json:"value"`
	OnChange func(string) `json:"-"`
	Order    uint32       `json:"order"`
}

WhisperContentFormInputMarkdown defines a markdown field in a form

func (*WhisperContentFormInputMarkdown) MarshalJSON

func (fc *WhisperContentFormInputMarkdown) MarshalJSON() ([]byte, error)

func (*WhisperContentFormInputMarkdown) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormInputMarkdown) Type

Type returns the type of field for this form element

type WhisperContentFormInputNumber

type WhisperContentFormInputNumber struct {
	Label    string        `json:"label"`
	Tooltip  string        `json:"tooltip"`
	Min      float32       `json:"min"`
	Max      float32       `json:"max"`
	Value    float32       `json:"value"`
	OnChange func(float32) `json:"-"`
	Order    uint32        `json:"order"`
}

WhisperContentFormInputNumber defines a number field in a form

func (*WhisperContentFormInputNumber) MarshalJSON

func (fc *WhisperContentFormInputNumber) MarshalJSON() ([]byte, error)

func (*WhisperContentFormInputNumber) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormInputNumber) Type

Type returns the type of field for this form element

type WhisperContentFormInputPassword

type WhisperContentFormInputPassword struct {
	Label    string       `json:"label"`
	Tooltip  string       `json:"tooltip"`
	OnChange func(string) `json:"-"`
	Order    uint32       `json:"order"`
}

WhisperContentFormInputPassword defines a password field in a form

func (*WhisperContentFormInputPassword) MarshalJSON

func (fc *WhisperContentFormInputPassword) MarshalJSON() ([]byte, error)

func (*WhisperContentFormInputPassword) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormInputPassword) Type

Type returns the type of field for this form element

type WhisperContentFormInputRadio

type WhisperContentFormInputRadio struct {
	Label    string       `json:"label"`
	Tooltip  string       `json:"tooltip"`
	Options  []string     `json:"options"`
	OnChange func(string) `json:"-"`
	Value    string       `json:"value"`
	Order    uint32       `json:"order"`
}

WhisperContentFormInputRadio defines a radio button selection field in a form

func (*WhisperContentFormInputRadio) MarshalJSON

func (fc *WhisperContentFormInputRadio) MarshalJSON() ([]byte, error)

func (*WhisperContentFormInputRadio) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormInputRadio) Type

Type returns the type of field for this form element

type WhisperContentFormInputSelect

type WhisperContentFormInputSelect struct {
	Label    string       `json:"label"`
	Tooltip  string       `json:"tooltip"`
	Options  []string     `json:"options"`
	OnChange func(string) `json:"-"`
	Value    string       `json:"value"`
	Order    uint32       `json:"order"`
}

WhisperContentFormInputSelect defines a dropdown menu selection field in a form

func (*WhisperContentFormInputSelect) MarshalJSON

func (fc *WhisperContentFormInputSelect) MarshalJSON() ([]byte, error)

func (*WhisperContentFormInputSelect) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormInputSelect) Type

Type returns the type of field for this form element

type WhisperContentFormInputTel

type WhisperContentFormInputTel struct {
	Label    string       `json:"label"`
	Tooltip  string       `json:"tooltip"`
	Pattern  string       `json:"pattern"`
	Value    string       `json:"value"`
	OnChange func(string) `json:"-"`
	Order    uint32       `json:"order"`
}

WhisperContentFormInputTel defines a telephone field in a form

func (*WhisperContentFormInputTel) MarshalJSON

func (fc *WhisperContentFormInputTel) MarshalJSON() ([]byte, error)

func (*WhisperContentFormInputTel) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormInputTel) Type

Type returns the type of field for this form element

type WhisperContentFormInputText

type WhisperContentFormInputText struct {
	Label    string       `json:"label"`
	Tooltip  string       `json:"tooltip"`
	Value    string       `json:"value"`
	OnChange func(string) `json:"-"`
	Order    uint32       `json:"order"`
}

WhisperContentFormInputText defines a text field in a form

func (*WhisperContentFormInputText) MarshalJSON

func (fc *WhisperContentFormInputText) MarshalJSON() ([]byte, error)

func (*WhisperContentFormInputText) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormInputText) Type

Type returns the type of field for this form element

type WhisperContentFormInputTime

type WhisperContentFormInputTime struct {
	Label    string          `json:"label"`
	Tooltip  string          `json:"tooltip"`
	Value    time.Time       `json:"value"`
	OnChange func(time.Time) `json:"-"`
	Order    uint32          `json:"order"`
}

WhisperContentFormInputTime defines a time field in a form

func (*WhisperContentFormInputTime) MarshalJSON

func (fc *WhisperContentFormInputTime) MarshalJSON() ([]byte, error)

func (*WhisperContentFormInputTime) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormInputTime) Type

Type returns the type of field for this form element

type WhisperContentFormOutput

type WhisperContentFormOutput interface {
	Type() WhisperContentFormType
	ToProto() (*proto.WhisperFormOutput, error)
}

type WhisperContentFormOutputCheckbox

type WhisperContentFormOutputCheckbox struct {
	Value bool `json:"value"`
}

func (*WhisperContentFormOutputCheckbox) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormOutputCheckbox) Type

Type returns the type of field for this form element

type WhisperContentFormOutputEmail

type WhisperContentFormOutputEmail struct {
	Value string `json:"value"`
}

func (*WhisperContentFormOutputEmail) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormOutputEmail) Type

Type returns the type of field for this form element

type WhisperContentFormOutputMarkdown

type WhisperContentFormOutputMarkdown struct {
	Value string `json:"value"`
}

func (*WhisperContentFormOutputMarkdown) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormOutputMarkdown) Type

Type returns the type of field for this form element

type WhisperContentFormOutputNumber

type WhisperContentFormOutputNumber struct {
	Value float32 `json:"value"`
}

func (*WhisperContentFormOutputNumber) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormOutputNumber) Type

Type returns the type of field for this form element

type WhisperContentFormOutputPassword

type WhisperContentFormOutputPassword struct {
	Value string `json:"value"`
}

func (*WhisperContentFormOutputPassword) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormOutputPassword) Type

Type returns the type of field for this form element

type WhisperContentFormOutputRadio

type WhisperContentFormOutputRadio struct {
	Value string `json:"value"`
}

func (*WhisperContentFormOutputRadio) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormOutputRadio) Type

Type returns the type of field for this form element

type WhisperContentFormOutputSelect

type WhisperContentFormOutputSelect struct {
	Value string `json:"value"`
}

func (*WhisperContentFormOutputSelect) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormOutputSelect) Type

Type returns the type of field for this form element

type WhisperContentFormOutputTel

type WhisperContentFormOutputTel struct {
	Value string `json:"value"`
}

func (*WhisperContentFormOutputTel) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormOutputTel) Type

Type returns the type of field for this form element

type WhisperContentFormOutputText

type WhisperContentFormOutputText struct {
	Value string `json:"value"`
}

func (*WhisperContentFormOutputText) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormOutputText) Type

Type returns the type of field for this form element

type WhisperContentFormOutputTime

type WhisperContentFormOutputTime struct {
	Value time.Time `json:"value"`
}

func (*WhisperContentFormOutputTime) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentFormOutputTime) Type

Type returns the type of field for this form element

type WhisperContentFormType

type WhisperContentFormType string
const (
	WhisperContentFormTypeCheckbox WhisperContentFormType = "checkbox"
	WhisperContentFormTypeEmail    WhisperContentFormType = "email"
	WhisperContentFormTypeMarkdown WhisperContentFormType = "markdown"
	WhisperContentFormTypeNumber   WhisperContentFormType = "number"
	WhisperContentFormTypePassword WhisperContentFormType = "password"
	WhisperContentFormTypeRadio    WhisperContentFormType = "radio"
	WhisperContentFormTypeSelect   WhisperContentFormType = "select"
	WhisperContentFormTypeTel      WhisperContentFormType = "tel"
	WhisperContentFormTypeText     WhisperContentFormType = "text"
	WhisperContentFormTypeTime     WhisperContentFormType = "time"
)

type WhisperContentList

type WhisperContentList struct {
	Label    string                               `json:"label"`
	Markdown string                               `json:"markdown"`
	Elements map[string]WhisperContentListElement `json:"elements"`
}

func WhisperContentListFromProto

func WhisperContentListFromProto(req *proto.WhisperListRequest) (*WhisperContentList, error)

func (*WhisperContentList) ToProto

func (*WhisperContentList) Type

Type returns the type of the whisper content

type WhisperContentListElement

type WhisperContentListElement interface {
	MarshalJSON() ([]byte, error)
	ToProto() (*proto.WhisperListElement, error)
	Type() WhisperContentListElementType
}

type WhisperContentListElementAlign

type WhisperContentListElementAlign string
const (
	WhisperContentListElementAlignLeft   WhisperContentListElementAlign = "left"
	WhisperContentListElementAlignCenter WhisperContentListElementAlign = "center"
	WhisperContentListElementAlignRight  WhisperContentListElementAlign = "right"
)

func (WhisperContentListElementAlign) ToProto

type WhisperContentListElementDivider

type WhisperContentListElementDivider struct {
	Extra bool                           `json:"extra"`
	Order uint32                         `json:"order"`
	Style WhisperContentListElementStyle `json:"style"`
}

WhisperContentListElementDivider defines a divider element for a list whisper

func (*WhisperContentListElementDivider) MarshalJSON

func (e *WhisperContentListElementDivider) MarshalJSON() ([]byte, error)

func (*WhisperContentListElementDivider) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentListElementDivider) Type

Type returns the type of field for this form element

type WhisperContentListElementLink struct {
	Align WhisperContentListElementAlign `json:"align"`
	Extra bool                           `json:"extra"`
	Href  string                         `json:"href"`
	Order uint32                         `json:"order"`
	Style WhisperContentListElementStyle `json:"style"`
	Text  string                         `json:"text"`
}

WhisperContentListElementLink defines a link element for a list whisper

func (*WhisperContentListElementLink) MarshalJSON

func (e *WhisperContentListElementLink) MarshalJSON() ([]byte, error)

func (*WhisperContentListElementLink) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentListElementLink) Type

Type returns the type of field for this form element

type WhisperContentListElementMessage

type WhisperContentListElementMessage struct {
	Align  WhisperContentListElementAlign `json:"align"`
	Body   string                         `json:"body"`
	Extra  bool                           `json:"extra"`
	Header string                         `json:"header"`
	Order  uint32                         `json:"order"`
	Style  WhisperContentListElementStyle `json:"style"`
}

WhisperContentListElementMessage defines an alert element for a list whisper

func (*WhisperContentListElementMessage) MarshalJSON

func (e *WhisperContentListElementMessage) MarshalJSON() ([]byte, error)

func (*WhisperContentListElementMessage) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentListElementMessage) Type

Type returns the type of field for this form element

type WhisperContentListElementPair

type WhisperContentListElementPair struct {
	Copyable bool                           `json:"copyable"`
	Extra    bool                           `json:"extra"`
	Label    string                         `json:"label"`
	Order    uint32                         `json:"order"`
	Style    WhisperContentListElementStyle `json:"style"`
	Value    string                         `json:"value"`
}

WhisperContentListElementPair defines a key value pair element for a list whisper

func (*WhisperContentListElementPair) MarshalJSON

func (e *WhisperContentListElementPair) MarshalJSON() ([]byte, error)

func (*WhisperContentListElementPair) ToProto

ToProto returns a protobuf representation of the object

func (*WhisperContentListElementPair) Type

Type returns the type of field for this form element

type WhisperContentListElementStyle

type WhisperContentListElementStyle string
const (
	WhisperContentListElementStyleNone    WhisperContentListElementStyle = "none"
	WhisperContentListElementStyleError   WhisperContentListElementStyle = "error"
	WhisperContentListElementStyleSuccess WhisperContentListElementStyle = "success"
	WhisperContentListElementStyleWarning WhisperContentListElementStyle = "warning"
)

func (WhisperContentListElementStyle) ToProto

type WhisperContentListElementType

type WhisperContentListElementType string
const (
	WhisperContentListElementTypeDivider WhisperContentListElementType = "divider"
)
const (
	WhisperContentListElementTypeLink WhisperContentListElementType = "link"
)
const (
	WhisperContentListElementTypeMessage WhisperContentListElementType = "message"
)
const (
	WhisperContentListElementTypePair WhisperContentListElementType = "pair"
)

type WhisperContentMarkdown

type WhisperContentMarkdown struct {
	Label string `json:"label"`

	Markdown string `json:"markdown"`
}

func (*WhisperContentMarkdown) Type

Type returns the type of the whisper content

type WhisperContentType

type WhisperContentType string

WhisperContentType defines the type of whisper content

const (
	// WhisperContentTypeConfirm is the content type used by a confirm whisper
	WhisperContentTypeConfirm WhisperContentType = "confirm"

	// WhisperContentTypeDisambiguation is the content type used by a disambiguation whisper
	WhisperContentTypeDisambiguation WhisperContentType = "disambiguation"

	// WhisperContentTypeForm is the content type used by a form whisper
	WhisperContentTypeForm WhisperContentType = "form"

	// WhisperContentTypeMarkdown is the content type used by a markdown whisper
	WhisperContentTypeMarkdown WhisperContentType = "markdown"

	// WhisperContentTypeList is the content type used by a list whisper
	WhisperContentTypeList WhisperContentType = "list"
)

type WhisperServer

type WhisperServer struct {
	Impl WhisperService
}

WhisperServer is used by the controller plugin host to receive plugin initiated communication

func (*WhisperServer) WhisperConfirm

WhisperConfirm is used by loops to create confirm whispers

func (*WhisperServer) WhisperDisambiguation

WhisperDisambiguation is used by loops to create disambiguation whispers

func (*WhisperServer) WhisperForm

WhisperForm is used by loops to create form whispers

func (*WhisperServer) WhisperList

func (m *WhisperServer) WhisperList(ctx context.Context, req *proto.WhisperListRequest) (*emptypb.Empty, error)

WhisperList is used by loops to create list whispers

func (*WhisperServer) WhisperMarkdown

func (m *WhisperServer) WhisperMarkdown(ctx context.Context, req *proto.WhisperMarkdownRequest) (*emptypb.Empty, error)

WhisperMarkdown is used by loops to create markdown whispers

type WhisperService

type WhisperService interface {
	// This function only returns once the whisper is closed, or when the context provided is cancelled.
	Confirm(context.Context, *WhisperContentConfirm) (bool, error)
	// This function only returns once the whisper is closed, or when the context provided is cancelled.
	Disambiguation(context.Context, *WhisperContentDisambiguation) (bool, error)
	// This function only returns once the whisper is closed, or when the context provided is cancelled.
	Form(context.Context, *WhisperContentForm) (bool, map[string]WhisperContentFormOutput, error)
	// This function only returns once the whisper is closed, or when the context provided is cancelled.
	Markdown(context.Context, *WhisperContentMarkdown) error
	// This function only returns once the whisper is closed, or when the context provided is cancelled.
	List(context.Context, *WhisperContentList) error
}

WhisperService is an interface that defines what methods plugins can expect from the host

type WindowAction

type WindowAction int

WindowAction is a type that defines what type of action experienced by the window

type WindowClient

type WindowClient struct {
	// contains filtered or unexported fields
}

func (*WindowClient) ActiveWindow

func (w *WindowClient) ActiveWindow(ctx context.Context) (WindowInfo, error)

func (*WindowClient) ListenActiveWindow

func (w *WindowClient) ListenActiveWindow(ctx context.Context, handler ListenActiveWindowHandler) error

func (*WindowClient) ListenState

func (w *WindowClient) ListenState(ctx context.Context, handler ListenWindowStateHandler) error

func (*WindowClient) State

func (w *WindowClient) State(ctx context.Context) ([]WindowInfo, error)

type WindowEvent

type WindowEvent struct {
	Window WindowInfo
	Action WindowAction
}

WindowEvent is a struct containing information about a change in window state

type WindowInfo

type WindowInfo struct {
	Title  string
	Path   string
	PID    int
	X      int
	Y      int
	Width  int
	Height int
}

WindowInfo contains information about window geometry, position, and metadata

type WindowServer

type WindowServer struct {
	Authority Authority
	Impl      WindowService
}

func (*WindowServer) WindowActiveWindow

func (*WindowServer) WindowState

func (*WindowServer) WindowStateStream

type WindowService

type WindowService interface {
	ActiveWindow(context.Context) (WindowInfo, error)
	ListenActiveWindow(context.Context, ListenActiveWindowHandler) error
	State(context.Context) ([]WindowInfo, error)
	ListenState(context.Context, ListenWindowStateHandler) error
}

WindowService is an interface that defines what methods plugins can expect from the host

Source Files

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL