sidewidget

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ScopeChat   = "chat"
	ScopeGlobal = "global"
)

Scopes of a widget.

View Source
const (
	ToolCreate = "widget_create"
	ToolUpdate = "widget_update"
	ToolList   = "widget_list"
	ToolRemove = "widget_remove"
)

The MCP tools of the widgets under the chat's right column: the same acts as `harnessly widget create|update|list| remove`, on the same Service.

View Source
const HostVersion = "0.16.342"

HostVersion is the host that draws side widgets.

View Source
const Instruction = "Widgets of the right column: on a computer the person keeps small cards under the chat's right column " +
	"(«Лимиты», «Машина», «Подчаты», «Выкат», «Заметка», «Часы» they add themselves from «+ Виджет»). When the person asks for " +
	"a widget that shows something («сделай виджет, который показывает…», «добавь виджет …», \"make a widget that shows …\"), " +
	"make it with widget_create (or `harnessly widget create`): a name, a title, and what it shows — `sources` (limits, machine, " +
	"subagents: the host's data it is given), `smart` (a request a model answers over those data every `every` minutes, at least 5, " +
	"and at once on the card's button) and/or your own `html`/`css`/`js` (a sandboxed page: hl.context.data has {sources, smart}, " +
	"hl.on('context', fn) brings new data; no network, no secrets, no chats). It appears in the person's stack by itself. Change it " +
	"with widget_update, list with widget_list, remove with widget_remove. A widget is made for the chat you are in (scope chat, the default): " +
	"the person pins it to other chats or to all of them; scope global is for what is theirs in every chat. A built-in widget is not made: tell the person to add it " +
	"from «+ Виджет» under the right column. When the person waits for something long (a render, a build, a deploy, a download), " +
	"offer a progress widget yourself, as the workspace prompt says: read the memory note side-widget-offers.md first, ask once with notice_ask."

Instruction is what an agent is told of the widgets, here and in the workspace's prompt.

View Source
const Publisher = "local"

Publisher is the publisher of the widgets an agent makes: they are the person's own, on their machine.

View Source
const View = "side"

View is the view id of such a widget.

Variables

View Source
var (
	// ErrExists: create of a name that is a widget already (update it).
	ErrExists = errors.New("sidewidget: a widget of that name exists: update it")
	// ErrNotFound: update or remove of a name that is no widget.
	ErrNotFound = errors.New("sidewidget: no widget of that name")
)
View Source
var ErrBadName = errors.New("sidewidget: a widget's name is lower case latin letters, digits and '-', up to 33")

ErrBadName is a widget's name that is not one: it never reaches a path.

Functions

func Created

func Created(name, title string) string

Created is the answer to a widget made.

func ID

func ID(name string) string

SideWidgetID is the app id of the widget named name.

func ListLine

func ListLine(w Info) string

ListLine is one widget of a list, as the CLI prints it too.

func ManifestJSON

func ManifestJSON(m *apps.Manifest) ([]byte, error)

ManifestJSON is the manifest as the package's harnessly/app.json.

func NameOf

func NameOf(id string) string

SideWidgetName is the name of a widget's app id, or "" for an app that is not such a widget.

func Package

func Package(s Spec, now time.Time) (*apps.Manifest, map[string]string, error)

SideWidgetPackage is the widget's package: its manifest and its files by path. The version is new each time, so an update installs over the last one.

Types

type Content

type Content struct {
	Rev  string `json:"rev"`
	HTML string `json:"html"`
	CSS  string `json:"css"`
}

Content is what the page hands a live frame to change what the card shows without starting it anew.

func ContentOf

func ContentOf(s Spec) Content

ContentOf is a widget's markup and style as the frame holds them, and their revision.

type Info

type Info struct {
	Name    string   `json:"name"`
	ID      string   `json:"id"`
	Title   string   `json:"title"`
	Smart   string   `json:"smart,omitempty"`
	Every   int      `json:"every,omitempty"`
	Sources []string `json:"sources,omitempty"`
	Size    string   `json:"size,omitempty"`
	// Scope is chat or global; Chat the conversation of a chat widget.
	Scope string `json:"scope,omitempty"`
	Chat  string `json:"chat,omitempty"`
}

Info is a widget as list shows it.

type Installer

type Installer interface {
	Install(dir string, opt apps.InstallOptions) (apps.Installed, apps.Problems, error)
	Uninstall(id string, purge bool, safe *secrets.Store) error
	List() ([]apps.Installed, error)
}

Installer is what the service needs of the registry.

type Patch

type Patch struct {
	Title   *string   `json:"title,omitempty"`
	Icon    *string   `json:"icon,omitempty"`
	HTML    *string   `json:"html,omitempty"`
	CSS     *string   `json:"css,omitempty"`
	JS      *string   `json:"js,omitempty"`
	Size    *string   `json:"size,omitempty"`
	Refresh *int      `json:"refresh,omitempty"`
	Sources *[]string `json:"sources,omitempty"`
	Smart   *string   `json:"smart,omitempty"`
	Every   *int      `json:"every,omitempty"`
	// Scope and Chat change where the widget shows; Chat is the caller's chat when the scope becomes chat.
	Scope *string `json:"scope,omitempty"`
	Chat  *string `json:"chat,omitempty"`
}

Patch is an update: only the fields given change.

func PlacePatch

func PlacePatch(p Patch, chat string) (Patch, error)

PlacePatch is an update's change of scope with the caller's chat: «chat» means the caller's chat.

func (Patch) Apply

func (p Patch) Apply(sp Spec) Spec

Apply is the spec with the patch's fields.

type Service

type Service struct {
	Reg  Installer
	Root string // <data>/side-widgets
	Host string // the runtime's version, for the install's check
	Now  func() time.Time
}

Service makes, changes, lists and removes the widgets an agent makes.

func (*Service) Content

func (s *Service) Content(appID string) (Content, error)

Content is what the card of a widget made by an agent shows now, by the widget's app id: the page hands it to the live frame, and keeps the last one to draw the card at once when a chat opens.

func (*Service) Create

func (s *Service) Create(sp Spec) (apps.Installed, error)

Create makes a new widget and installs it.

func (*Service) List

func (s *Service) List() ([]Info, error)

List is every widget an agent made, by name.

func (*Service) Remove

func (s *Service) Remove(name string) error

Remove uninstalls a widget and forgets its folder.

func (*Service) Update

func (s *Service) Update(name string, p Patch) (apps.Installed, error)

Update changes a widget's fields and installs it again.

type Spec

type Spec struct {
	Name    string   `json:"name"`
	Title   string   `json:"title"`
	Icon    string   `json:"icon,omitempty"`
	HTML    string   `json:"html,omitempty"`
	CSS     string   `json:"css,omitempty"`
	JS      string   `json:"js,omitempty"`
	Size    string   `json:"size,omitempty"`
	Refresh int      `json:"refresh,omitempty"`
	Sources []string `json:"sources,omitempty"`
	Smart   string   `json:"smart,omitempty"`
	Every   int      `json:"every,omitempty"`
	// Scope is "chat" (shown in the chat it was made for, and where the person pins it) or "global" (every chat);
	// empty is chat when Chat is known. Chat is that conversation, put by the one who makes it.
	Scope string `json:"scope,omitempty"`
	Chat  string `json:"chat,omitempty"`
}

Spec is what `harnessly widget create` is told.

func Place

func Place(sp Spec, chat string) (Spec, error)

Place puts a new widget where it belongs: the chat of the one who makes it, unless it asks for every chat. A caller with no chat (a terminal that is no chat's) makes a widget for every chat.

func (Spec) ChatOf

func (s Spec) ChatOf() string

ChatOf is the conversation a widget of this spec belongs to, "" for one of every chat.

type Tools

type Tools struct {
	S *Service
	// Chat is the calling agent's chat: the widget it makes is for that chat.
	Chat string
}

Tools are the widgets' MCP tools.

func (Tools) Call

func (t Tools) Call(_ context.Context, name string, args *jsvalue.Object) *jsvalue.Object

func (Tools) Has

func (Tools) Has(name string) bool

func (Tools) Instructions

func (Tools) Instructions() string

func (Tools) Tools

func (Tools) Tools() []any

Jump to

Keyboard shortcuts

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