contract

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 10 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

Overview

Package contract checks that the Local API behaves like *core.Service: the same scenarios run against the typed service and through JSON-RPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	AddAccount(ctx context.Context, in core.AccountInput) (core.Account, error)
	CheckAccount(ctx context.Context, in core.AccountInput) (core.CheckReport, error)
	DetectProvider(ctx context.Context, email string) (auth.Provider, auth.Source, error)
	ExportAccounts(ctx context.Context) ([]byte, error)
	PreviewAccountImport(ctx context.Context, data []byte) (core.AccountImportPreview, error)
	ImportAccounts(ctx context.Context, data []byte) (core.AccountImportResult, error)
	RemoveAccount(ctx context.Context, id int64) error
	UpdatePassword(ctx context.Context, id int64, password string) error
	ListAccounts(ctx context.Context) ([]core.Account, error)
	ListFolders(ctx context.Context, accountID int64) ([]core.Folder, error)
	ListThreads(ctx context.Context, v core.View, cursor string, limit int) (core.ThreadPage, error)
	GetThread(ctx context.Context, id int64) (core.Thread, error)
	ListMessages(ctx context.Context, v core.View, cursor string, limit int) (core.MessagePage, error)
	GetMessage(ctx context.Context, id int64, loadRemoteImages bool) (core.Message, error)
	GetMessageText(ctx context.Context, id int64) (core.MessageText, error)
	Search(ctx context.Context, accountID int64, query string, limit int) ([]core.MessageSummary, error)
	GetAttachment(ctx context.Context, attachmentID int64) (string, core.AttachmentInfo, error)
	NewDraft(ctx context.Context, accountID int64, mode string, sourceMessageID int64) (core.Draft, error)
	SaveDraft(ctx context.Context, d core.Draft) (core.Draft, error)
	Send(ctx context.Context, draftID int64) error
	SendAcknowledged(ctx context.Context, draftID int64, digest string) error
	RequestMCPSend(ctx context.Context, draftID, revision int64) (sent bool, err error)
	ListOutbox(ctx context.Context, accountID int64) ([]core.OutboxItem, error)
	CancelOutbox(ctx context.Context, id int64) error
	GetSettings(ctx context.Context) (core.Settings, error)
	SetSettings(ctx context.Context, st core.Settings) (core.Settings, error)
	TrustedImageSenders(ctx context.Context) ([]string, error)
	TrustImageSender(ctx context.Context, from string) error
	UntrustImageSender(ctx context.Context, addr string) error
	BlockedSenders(ctx context.Context) ([]string, error)
	BlockSender(ctx context.Context, from string) error
	UnblockSender(ctx context.Context, addr string) error
	CheckModelService(ctx context.Context, id int64, in core.ModelServiceInput) (core.ServiceCheck, error)
	RunSkill(ctx context.Context, name string, t core.Target) (<-chan ai.Event, error)
	NewConversation(ctx context.Context, kind string, draftID int64) (core.Conversation, error)
	Ask(ctx context.Context, conversationID int64, input string) (<-chan core.WitEvent, error)
	SubscribeConversation(id int64) (<-chan core.WitEvent, func())
	ResolveApproval(ctx context.Context, id int64, accept bool) error
	ResolveApprovalWithArgs(ctx context.Context, id int64, accept bool, args json.RawMessage) error
	ListApprovals(ctx context.Context, conversationID int64) ([]core.Approval, error)
	Subscribe() (<-chan events.Event, func())
	RunAction(ctx context.Context, id string, t core.Target, opts core.RunActionOptions) (core.ActionResult, error)
	BeginOAuth(ctx context.Context, providerID, loginHint string, client core.OAuthClient) (flowID, authURL string, err error)
	CancelOAuth(flowID string)
}

API is the subset of *core.Service the contract scenarios use, with the same signatures.

type Remote

type Remote struct {
	C *rpc.Client
	// contains filtered or unexported fields
}

Remote implements API over a Local API connection (full role). Streams that end abnormally, or carry an event that does not decode, are recorded in StreamErrs: the typed signatures have no place for them.

func (*Remote) AddAccount

func (r *Remote) AddAccount(ctx context.Context, in core.AccountInput) (core.Account, error)

func (*Remote) Ask

func (r *Remote) Ask(ctx context.Context, conversationID int64, input string) (<-chan core.WitEvent, error)

func (*Remote) BeginOAuth

func (r *Remote) BeginOAuth(ctx context.Context, providerID, loginHint string, client core.OAuthClient) (string, string, error)

func (*Remote) BlockSender added in v1.17.0

func (r *Remote) BlockSender(ctx context.Context, from string) error

func (*Remote) BlockedSenders added in v1.19.0

func (r *Remote) BlockedSenders(ctx context.Context) ([]string, error)

func (*Remote) CachedImage added in v1.36.0

func (r *Remote) CachedImage(ctx context.Context, src string) (core.CachedImageFile, error)

func (*Remote) CachedImageDims added in v1.36.0

func (r *Remote) CachedImageDims(src string) core.ImageDims

func (*Remote) CancelOAuth

func (r *Remote) CancelOAuth(flowID string)

CancelOAuth has no result to fail with; a failed call is recorded.

func (*Remote) CancelOutbox added in v1.14.0

func (r *Remote) CancelOutbox(ctx context.Context, id int64) error

func (*Remote) CheckAccount

func (r *Remote) CheckAccount(ctx context.Context, in core.AccountInput) (core.CheckReport, error)

func (*Remote) CheckModelService

func (r *Remote) CheckModelService(ctx context.Context, id int64, in core.ModelServiceInput) (core.ServiceCheck, error)

func (*Remote) DetectProvider

func (r *Remote) DetectProvider(ctx context.Context, email string) (auth.Provider, auth.Source, error)

func (*Remote) DownloadRecognitionModelStream added in v1.36.0

func (r *Remote) DownloadRecognitionModelStream(ctx context.Context) (<-chan core.RecognitionModelProgress, error)

func (*Remote) ExportAccounts added in v1.36.0

func (r *Remote) ExportAccounts(ctx context.Context) ([]byte, error)

func (*Remote) FetchAttachmentsStream added in v1.36.0

func (r *Remote) FetchAttachmentsStream(ctx context.Context, attachmentIDs []int64) (<-chan core.FetchedAttachment, error)

func (*Remote) ForgetImageFailure added in v1.36.0

func (r *Remote) ForgetImageFailure(urls []string)

func (*Remote) GetAttachment

func (r *Remote) GetAttachment(ctx context.Context, attachmentID int64) (string, core.AttachmentInfo, error)

func (*Remote) GetMessage

func (r *Remote) GetMessage(ctx context.Context, id int64, loadRemoteImages bool) (core.Message, error)

func (*Remote) GetMessageLazyImages added in v1.36.0

func (r *Remote) GetMessageLazyImages(ctx context.Context, id int64, loadRemoteImages bool) (core.Message, error)

func (*Remote) GetMessageText

func (r *Remote) GetMessageText(ctx context.Context, id int64) (core.MessageText, error)

func (*Remote) GetSettings

func (r *Remote) GetSettings(ctx context.Context) (core.Settings, error)

func (*Remote) GetThread

func (r *Remote) GetThread(ctx context.Context, id int64) (core.Thread, error)

func (*Remote) ImportAccounts added in v1.36.0

func (r *Remote) ImportAccounts(ctx context.Context, data []byte) (core.AccountImportResult, error)

func (*Remote) InboxOnly added in v1.36.0

func (r *Remote) InboxOnly() bool

func (*Remote) InlineImagesStream added in v1.36.0

func (r *Remote) InlineImagesStream(ctx context.Context, id int64) (<-chan core.InlineImage, error)

func (*Remote) InstallPluginFromRegistryStream added in v1.36.0

func (r *Remote) InstallPluginFromRegistryStream(ctx context.Context, name string) (<-chan core.PluginInstallEvent, error)

func (*Remote) ListAccounts

func (r *Remote) ListAccounts(ctx context.Context) ([]core.Account, error)

func (*Remote) ListApprovals

func (r *Remote) ListApprovals(ctx context.Context, conversationID int64) ([]core.Approval, error)

func (*Remote) ListFolders

func (r *Remote) ListFolders(ctx context.Context, accountID int64) ([]core.Folder, error)

func (*Remote) ListMessages

func (r *Remote) ListMessages(ctx context.Context, v core.View, cursor string, limit int) (core.MessagePage, error)

func (*Remote) ListOutbox

func (r *Remote) ListOutbox(ctx context.Context, accountID int64) ([]core.OutboxItem, error)

func (*Remote) ListThreads

func (r *Remote) ListThreads(ctx context.Context, v core.View, cursor string, limit int) (core.ThreadPage, error)

func (*Remote) ModelServiceAvatar added in v1.36.0

func (r *Remote) ModelServiceAvatar(ctx context.Context, id int64) (core.Avatar, error)

func (*Remote) NewConversation

func (r *Remote) NewConversation(ctx context.Context, kind string, draftID int64) (core.Conversation, error)

func (*Remote) NewDraft

func (r *Remote) NewDraft(ctx context.Context, accountID int64, mode string, sourceMessageID int64) (core.Draft, error)

func (*Remote) PluginReadme added in v1.36.0

func (r *Remote) PluginReadme(ctx context.Context, name, lang string) (string, error)

func (*Remote) PrepareModelStream added in v1.36.0

func (r *Remote) PrepareModelStream(ctx context.Context, ref string) (<-chan core.PrepareModelEvent, error)

func (*Remote) PreviewAccountImport added in v1.36.0

func (r *Remote) PreviewAccountImport(ctx context.Context, data []byte) (core.AccountImportPreview, error)

func (*Remote) RemoveAccount added in v1.36.0

func (r *Remote) RemoveAccount(ctx context.Context, id int64) error

func (*Remote) RequestMCPSend added in v1.36.0

func (r *Remote) RequestMCPSend(ctx context.Context, draftID, revision int64) (bool, error)

func (*Remote) ResolveApproval

func (r *Remote) ResolveApproval(ctx context.Context, id int64, accept bool) error

func (*Remote) ResolveApprovalWithArgs added in v1.17.0

func (r *Remote) ResolveApprovalWithArgs(ctx context.Context, id int64, accept bool, args json.RawMessage) error

func (*Remote) RunAction

func (r *Remote) RunAction(ctx context.Context, id string, t core.Target, opts core.RunActionOptions) (core.ActionResult, error)

func (*Remote) RunSkill

func (r *Remote) RunSkill(ctx context.Context, name string, t core.Target) (<-chan ai.Event, error)

func (*Remote) SaveDraft

func (r *Remote) SaveDraft(ctx context.Context, d core.Draft) (core.Draft, error)

func (*Remote) Search

func (r *Remote) Search(ctx context.Context, accountID int64, query string, limit int) ([]core.MessageSummary, error)

func (*Remote) Send

func (r *Remote) Send(ctx context.Context, draftID int64) error

func (*Remote) SendAcknowledged

func (r *Remote) SendAcknowledged(ctx context.Context, draftID int64, digest string) error

func (*Remote) SenderAvatar added in v1.36.0

func (r *Remote) SenderAvatar(ctx context.Context, messageID int64, allowRemote bool) (core.Avatar, error)

func (*Remote) SetComposeOpen added in v1.36.0

func (r *Remote) SetComposeOpen(ctx context.Context, draftIDs []int64) error

func (*Remote) SetInboxOnly added in v1.36.0

func (r *Remote) SetInboxOnly(on bool)

func (*Remote) SetSettings

func (r *Remote) SetSettings(ctx context.Context, st core.Settings) (core.Settings, error)

func (*Remote) SetUIForeground added in v1.36.0

func (r *Remote) SetUIForeground(ctx context.Context, on bool) error

func (*Remote) StreamErrs

func (r *Remote) StreamErrs() []error

StreamErrs returns every abnormal stream end so far.

func (*Remote) Subscribe

func (r *Remote) Subscribe() (<-chan events.Event, func())

func (*Remote) SubscribeConversation

func (r *Remote) SubscribeConversation(id int64) (<-chan core.WitEvent, func())

func (*Remote) SystemTranslatorLanguages added in v1.36.0

func (r *Remote) SystemTranslatorLanguages() []string

func (*Remote) TrustImageSender

func (r *Remote) TrustImageSender(ctx context.Context, from string) error

func (*Remote) TrustedImageSenders added in v1.19.0

func (r *Remote) TrustedImageSenders(ctx context.Context) ([]string, error)

func (*Remote) UnblockSender added in v1.17.0

func (r *Remote) UnblockSender(ctx context.Context, addr string) error

func (*Remote) UntrustImageSender

func (r *Remote) UntrustImageSender(ctx context.Context, addr string) error

func (*Remote) UpdatePassword added in v1.36.0

func (r *Remote) UpdatePassword(ctx context.Context, id int64, password string) error

type UIAPI added in v1.36.0

type UIAPI interface {
	API
	SetUIForeground(ctx context.Context, on bool) error
	SetComposeOpen(ctx context.Context, draftIDs []int64) error
	SetInboxOnly(on bool)
	InboxOnly() bool
	GetMessageLazyImages(ctx context.Context, id int64, loadRemoteImages bool) (core.Message, error)
	InlineImagesStream(ctx context.Context, id int64) (<-chan core.InlineImage, error)
	FetchAttachmentsStream(ctx context.Context, attachmentIDs []int64) (<-chan core.FetchedAttachment, error)
	CachedImage(ctx context.Context, src string) (core.CachedImageFile, error)
	CachedImageDims(src string) core.ImageDims
	ForgetImageFailure(urls []string)
	SystemTranslatorLanguages() []string
	SenderAvatar(ctx context.Context, messageID int64, allowRemote bool) (core.Avatar, error)
	ModelServiceAvatar(ctx context.Context, id int64) (core.Avatar, error)
	PluginReadme(ctx context.Context, name, lang string) (string, error)
	InstallPluginFromRegistryStream(ctx context.Context, name string) (<-chan core.PluginInstallEvent, error)
	PrepareModelStream(ctx context.Context, ref string) (<-chan core.PrepareModelEvent, error)
	DownloadRecognitionModelStream(ctx context.Context) (<-chan core.RecognitionModelProgress, error)
}

UIAPI extends API with the methods exposed only to RoleUI.

Jump to

Keyboard shortcuts

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