assistant

package
v0.2.0-dev.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 37 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 (

	// FollowUpLate: a follow-up the panel could not run until this long after its time (it was down) is dropped with a note.
	FollowUpLate = 24 * time.Hour
	// FollowUpRunLimit bounds one RunFollowUp: a turn, with the waits between a provider's attempts inside it.
	FollowUpRunLimit = maxTurnDuration + time.Minute
)
View Source
const ScheduledRunLimit = 2*scheduledTurn + 2*time.Minute

ScheduledRunLimit bounds one RunScheduled: a turn on each of two providers, with the waits between attempts.

Variables

This section is empty.

Functions

func ConversationSummaryAAD

func ConversationSummaryAAD(id string) string

func ConversationTitleAAD

func ConversationTitleAAD(id string) string

func FollowUpAAD

func FollowUpAAD(id string) string

FollowUpAAD is the vault's associated data of a follow-up's note.

func HasCredentialLabel

func HasCredentialLabel(s string) bool

HasCredentialLabel reports whether text contains a credential label with a value.

func MemoryAAD

func MemoryAAD(id string) string

func MessageAAD

func MessageAAD(id string) string

func PanelNotesAAD

func PanelNotesAAD() string

func PlanCardAAD

func PlanCardAAD(id string) string

func PlanConfirmAAD

func PlanConfirmAAD(id string) string

func ProviderKeyAAD

func ProviderKeyAAD(p adminv1.AssistantProvider) string

Types

type Config

type Config struct {
	Store         *store.Store
	Vault         *vault.Vault
	Auth          *auth.Service
	Now           func() time.Time
	Log           *slog.Logger
	ProviderBases map[adminv1.AssistantProvider]string
	HTTPClients   map[adminv1.AssistantProvider]*http.Client
	Providers     map[adminv1.AssistantProvider]adapter
}

Config supplies the signed-in AssistantService dependencies. Endpoint overrides and clients exist only for tests; production uses the fixed HTTPS URLs in provider_prices.go.

type FollowUpNotifier

type FollowUpNotifier func(adminID, summary string)

FollowUpNotifier sends a follow-up's problem to its admin's Telegram (telegram.Service.FollowUpProblem).

type FollowUpOutcome

type FollowUpOutcome struct {
	// "ran" (its turn ended with an answer), "failed" (it did not run, or its turn failed: the conversation says why), "missed"
	// (too late: the conversation says so), "dropped" (its admin or conversation is gone: nothing to say it to), or "deferred"
	// (try again after RetryAfter).
	Status     string
	Reason     string
	RetryAfter time.Duration
	// Counted: the deferral counts as a try (the store failed), not a wait for a busy conversation.
	Counted bool
}

FollowUpOutcome is what came of RunFollowUp.

type ScheduledOutcome

type ScheduledOutcome struct {
	Status         string // "ok", "problem", "failed" or "skipped"
	Reason         string // a code, for failed and skipped
	Summary        string // the verdict's line, cleaned
	ConversationID string
	Provider       string // the provider's slug ("anthropic" ...)
	Model          string
	USD            float64
	FellBack       bool
}

ScheduledOutcome is what came of a run.

type ScheduledRun

type ScheduledRun struct {
	TaskID, TaskName string
	// AdminID is the task's owner: the conversation is theirs, and so is the cost.
	AdminID string
	Prompt  string
	// ConversationID is the task's conversation; empty, or deleted meanwhile, starts a new one.
	ConversationID string
}

ScheduledRun is what a scheduled task asks of the assistant.

type Service

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

func New

func New(c Config) *Service

New creates the AssistantService and its one guarded HTTP client per provider.

func (*Service) CancelFollowUp

CancelFollowUp removes a follow-up waiting in one of the admin's own conversations.

func (*Service) Chat

func (*Service) Handler

func (s *Service) Handler(opts ...connect.HandlerOption) (string, http.Handler)

func (*Service) RecentQuestions

RecentQuestions returns what the admin typed lately across their conversations (not a task's or a follow-up's turns): short one-line texts, newest first, each once.

func (*Service) Retention

func (s *Service) Retention(ctx context.Context, now time.Time) error

func (*Service) RunFollowUp

RunFollowUp runs one due follow-up: a turn of its conversation as its admin. It never returns an error: what went wrong is the outcome, and a note in the conversation when there is one to write it in.

func (*Service) RunScheduled

func (s *Service) RunScheduled(ctx context.Context, run ScheduledRun) ScheduledOutcome

RunScheduled runs one scheduled assistant task and reports the outcome. It never returns an error: everything that went wrong is a status and a reason code, recorded with the run.

func (*Service) SetFollowUpNotifier

func (s *Service) SetFollowUpNotifier(n FollowUpNotifier)

SetFollowUpNotifier installs the Telegram sender once the services are built.

func (*Service) SetToolRuntime

func (s *Service) SetToolRuntime(runtime mcp.AssistantRuntime)

SetToolRuntime installs the MCP server once the authenticated admin API has been assembled.

Jump to

Keyboard shortcuts

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