client

package
v0.1.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 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 client is a workspace held by the Blitz service, reached over its socket: an api.Backend, so front ends drive it exactly as they drive a local *engine.Workspace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Remote

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

Remote is one workspace in the service.

func Attach

func Attach(ctx context.Context, sock, dir string, warn func(string)) (*Remote, error)

Attach opens dir (made absolute) in the service listening on sock.

func AttachHTTP

func AttachHTTP(ctx context.Context, hc connect.HTTPClient, baseURL, dir string, warn func(string)) (*Remote, error)

AttachHTTP is Attach over any HTTP client, e.g. in tests.

func (*Remote) ActiveAgent

func (r *Remote) ActiveAgent() api.AgentInfo

ActiveAgent is the agent in use (from ListAgents).

func (*Remote) ActiveAgentTools

func (r *Remote) ActiveAgentTools() api.AgentTools

ActiveAgentTools lists the tools the active agent can call (WorkspaceService.ListTools) (on failure, warn is told and it returns nothing).

func (*Remote) ActiveSession

func (r *Remote) ActiveSession() (api.SessionInfo, bool)

ActiveSession returns the session in use and whether there is one (SessionService.GetActiveSession) (on failure, warn is told and it returns nothing).

func (*Remote) AddImage

func (r *Remote) AddImage(name string, data []byte) (*images.Image, error)

AddImage prepares an image from its bytes (a paste) for a prompt (WorkspaceService.AddImage).

func (*Remote) AddMemory

func (r *Remote) AddMemory(ctx context.Context, text string) (string, error)

AddMemory appends a note to the project's memory file and returns the file (WorkspaceService.AddMemory).

func (*Remote) AddPermissionRule

func (r *Remote) AddPermissionRule(effect, rule string, save bool) (api.PermissionChange, error)

AddPermissionRule adds a rule with its effect (allow, ask or deny), for the session or, with save, in the configuration (WorkspaceService.AddPermissionRule).

func (*Remote) AllModelSettings

func (r *Remote) AllModelSettings() map[string]config.ModelSettings

AllModelSettings returns every model's generation settings from the configuration (WorkspaceService.GetModelSettings) (on failure, warn is told and it returns nothing).

func (*Remote) AuditShell

func (r *Remote) AuditShell(string, int, error)

AuditShell does nothing: the command ran here, outside the service.

func (*Remote) AvailableLocales

func (r *Remote) AvailableLocales() ([]api.LocaleInfo, string)

AvailableLocales lists the languages the model can reply in, and the folder of extra translations (WorkspaceService.ListLocales) (on failure, warn is told and it returns nothing).

func (*Remote) ClearApprovals

func (r *Remote) ClearApprovals() int

ClearApprovals revokes every standing approval and returns how many went (WorkspaceService.RevokeApprovals).

func (*Remote) Close

func (r *Remote) Close() error

Close leaves the workspace open in the service, for other clients.

func (*Remote) Compact

func (r *Remote) Compact(ctx context.Context, focus string) (api.CompactResult, error)

Compact summarizes the session's older events to free context, focusing the summary on focus if given (SessionService.Compact).

func (*Remote) Context

func (r *Remote) Context() (api.ContextInfo, error)

Context describes how full the active session's context is (from SessionService.GetUsage).

func (*Remote) Dir

func (r *Remote) Dir() string

Dir is the workspace's directory.

func (*Remote) GitDiff

func (r *Remote) GitDiff(ctx context.Context, color bool) (string, error)

GitDiff is `git diff` of the workspace, with color if asked (WorkspaceService.GetDiff).

func (*Remote) ImagesEnabled

func (r *Remote) ImagesEnabled() bool

ImagesEnabled reports whether the workspace accepts images (its images settings, from GetSettings).

func (*Remote) ListAgents

func (r *Remote) ListAgents() []api.AgentInfo

ListAgents lists the agents the workspace offers, marking the active one (WorkspaceService.ListAgents) (on failure, warn is told and it returns nothing).

func (*Remote) ListApprovals

func (r *Remote) ListApprovals() []api.Approval

ListApprovals lists the standing approvals the user gave (WorkspaceService.ListApprovals) (on failure, warn is told and it returns nothing).

func (*Remote) ListCheckpoints

func (r *Remote) ListCheckpoints() []api.Checkpoint

ListCheckpoints lists the turns that changed files, newest first (WorkspaceService.ListCheckpoints) (on failure, warn is told and it returns nothing).

func (*Remote) ListCommands

func (r *Remote) ListCommands() []api.CommandInfo

ListCommands lists the workspace's custom slash commands (WorkspaceService.ListCommands) (on failure, warn is told and it returns nothing).

func (*Remote) ListEnvs

func (r *Remote) ListEnvs() ([]api.Env, error)

ListEnvs lists the Python environments skills' scripts use (WorkspaceService.ListEnvs).

func (*Remote) ListMCPServers

func (r *Remote) ListMCPServers() []api.MCPServer

ListMCPServers lists the configured MCP servers and their state (WorkspaceService.ListMCPServers) (on failure, warn is told and it returns nothing).

func (*Remote) ListPermissionRules

func (r *Remote) ListPermissionRules() []api.PermissionRule

ListPermissionRules lists the allow, ask and deny rules in effect (WorkspaceService.ListPermissionRules) (on failure, warn is told and it returns nothing).

func (*Remote) ListSessions

func (r *Remote) ListSessions(all bool) ([]api.SessionInfo, error)

ListSessions lists the workspace's sessions, or every workspace's with all (SessionService.ListSessions).

func (*Remote) ListSkills

func (r *Remote) ListSkills() []api.SkillInfo

ListSkills lists the skills the workspace offers (WorkspaceService.ListSkills).

func (*Remote) LoadAttachments

func (r *Remote) LoadAttachments(paths []string, prompt string, warn func(string)) ([]*images.Image, error)

LoadAttachments loads image files (failures are errors naming the path) and @image mentions in prompt (failures are warnings), as the local workspace does.

func (*Remote) LoadImage

func (r *Remote) LoadImage(path string) (*images.Image, error)

LoadImage prepares the image at path (in the workspace) for a prompt (WorkspaceService.LoadImage).

func (*Remote) LoadSession

func (r *Remote) LoadSession(ref string) (api.SessionInfo, bool, error)

LoadSession makes the session ref names active: an ID, or a snapshot's name, which starts a new session copied from it (reported as branched) (SessionService.LoadSession).

func (*Remote) MemoryFiles

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

MemoryFiles lists the project memory files loaded (AGENTS.md and the like) (WorkspaceService.ReloadMemory) (on failure, warn is told and it returns nothing).

func (*Remote) Model

func (r *Remote) Model() api.ModelInfo

Model describes the model in use, and why it's unavailable if it is (WorkspaceService.GetModel) (on failure, warn is told and it returns nothing).

func (*Remote) ModelErr

func (r *Remote) ModelErr() error

ModelErr is why the workspace's model was unavailable when attaching (nil if it worked).

func (*Remote) ModelSettings

func (r *Remote) ModelSettings(ref string) (api.ModelSettingsInfo, error)

ModelSettings returns one model's generation settings, with the global ones they fall back to (WorkspaceService.GetModelSettings).

func (*Remote) NewSession

func (r *Remote) NewSession() (api.SessionInfo, error)

NewSession starts a new session and makes it active (SessionService.NewSession).

func (*Remote) OpenSession

func (r *Remote) OpenSession(resume string, cont bool) (api.SessionInfo, bool, error)

OpenSession picks the session to use, as the CLI does at start: the one resume names (an ID, or a snapshot to start from), the latest when cont is set, else a new one. It reports whether a session was resumed (SessionService.OpenSession).

func (*Remote) PinModel

func (r *Remote) PinModel(ctx context.Context, agent, ref string) (api.PinResult, error)

PinModel runs agent on the model ref from now on, and saves the pin in the configuration (WorkspaceService.PinModel).

func (*Remote) Processes

func (r *Remote) Processes() api.Processes

Processes is nil: background processes belong to the service, and stay when this client exits.

func (*Remote) PruneEnvs

func (r *Remote) PruneEnvs() (api.PruneResult, error)

PruneEnvs deletes the skill environments no skill needs any more (WorkspaceService.PruneEnvs).

func (*Remote) ReloadMemory

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

ReloadMemory reads the project memory files again and lists them (WorkspaceService.ReloadMemory).

func (*Remote) RemoveEnv

func (r *Remote) RemoveEnv(key string) error

RemoveEnv deletes one skill environment by key (WorkspaceService.RemoveEnv).

func (*Remote) RemovePermissionRule

func (r *Remote) RemovePermissionRule(rule string, save bool) (api.PermissionChange, error)

RemovePermissionRule removes a rule, from the session or, with save, from the configuration (WorkspaceService.RemovePermissionRule).

func (*Remote) RenameSession

func (r *Remote) RenameSession(title string) (api.SessionInfo, error)

RenameSession gives the active session a title (SessionService.RenameSession).

func (*Remote) RevokeApprovals

func (r *Remote) RevokeApprovals(keys ...string) int

RevokeApprovals revokes the approvals with keys and returns how many went (WorkspaceService.RevokeApprovals).

func (*Remote) Rewind

func (r *Remote) Rewind(ctx context.Context, index int, mode api.RewindMode, force bool) (api.RewindResult, error)

Rewind takes the active session back to one of its prompts.

func (*Remote) RewindPoints

func (r *Remote) RewindPoints() ([]api.RewindPoint, error)

RewindPoints lists the active session's prompts.

func (*Remote) Run

func (r *Remote) Run(ctx context.Context, sessionID string, t api.Turn, on func(api.Event)) (api.TurnResult, error)

Run runs a turn in the service, answering its approval requests and questions through the UI set with SetUI. OnFinished runs when the turn's last event arrives, after the service has collected unread steer messages; a message sent later waits for the agent's next turn.

func (*Remote) SandboxSummary

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

SandboxSummary describes the workspace's file, command and OS sandbox policy, a line each (WorkspaceService.GetSandbox) (on failure, warn is told and it returns nothing).

func (*Remote) SaveSnapshot

func (r *Remote) SaveSnapshot(name string, force bool) (api.SessionInfo, error)

SaveSnapshot saves the active session as the named snapshot; force replaces one of that name (SessionService.SaveSnapshot).

func (*Remote) SearchProvider

func (r *Remote) SearchProvider() (string, error)

SearchProvider names the web search provider the workspace uses (WorkspaceService.GetSearchProvider).

func (*Remote) SearchSession

func (r *Remote) SearchSession(terms string) (int, string)

SearchSession searches the session's history for terms and returns the number of passages found and a prompt with them (SessionService.SearchSession) (on failure, warn is told and it returns nothing).

func (*Remote) SearchSkills

func (r *Remote) SearchSkills(query string) []api.SkillInfo

SearchSkills lists the skills matching query (WorkspaceService.ListSkills).

func (*Remote) SearchWeb

func (r *Remote) SearchWeb(ctx context.Context, terms string) (api.WebSearch, error)

SearchWeb searches the web for terms and returns the links and the prompt that hands them to the agent (WorkspaceService.SearchWeb).

func (*Remote) SessionDiff

func (r *Remote) SessionDiff() string

SessionDiff is a unified diff of the files the session's turns changed (WorkspaceService.GetDiff) (on failure, warn is told and it returns nothing).

func (*Remote) SessionUsage

func (r *Remote) SessionUsage() (api.Usage, error)

SessionUsage is the active session's token use and cost (SessionService.GetUsage).

func (*Remote) Set

func (r *Remote) Set(ctx context.Context, key, value string) (string, error)

Set changes one run setting (such as effort or agency) and returns its key as applied (WorkspaceService.SetSetting).

func (*Remote) SetAgent

func (r *Remote) SetAgent(ctx context.Context, name string) (api.AgentInfo, error)

SetAgent switches the workspace to the named agent (WorkspaceService.SetAgent).

func (*Remote) SetLocale

func (r *Remote) SetLocale(ctx context.Context, input string) (api.LocaleChange, error)

SetLocale sets the language the model replies in from input (a tag or a name) (WorkspaceService.SetLocale).

func (*Remote) SetModel

func (r *Remote) SetModel(ctx context.Context, ref string) (string, error)

SetModel switches the workspace's model to ref ("provider/model" or a model); it returns the agent's pin that now overrides it, if any (WorkspaceService.SetModel).

func (*Remote) SetPermissionMode

func (r *Remote) SetPermissionMode(mode string) (string, error)

SetPermissionMode sets the permission mode (default, accept-edits, plan, dont-ask or bypass) and returns it (WorkspaceService.SetPermissionMode).

func (*Remote) SetUI

func (r *Remote) SetUI(approve api.Approver, ask api.UserPromptFunc)

SetUI sets how Run asks the user: approve for approval requests, ask for the agent's questions.

func (*Remote) Settings

func (r *Remote) Settings() api.Settings

Settings returns the workspace's run settings: agent, model, mode, effort, agency, language (WorkspaceService.GetSettings).

func (*Remote) Skill

func (r *Remote) Skill(name string) (api.SkillInfo, bool)

Skill returns the named skill, and whether it exists (WorkspaceService.GetSkill).

func (*Remote) Steer

func (r *Remote) Steer(ctx context.Context, sessionID, text string) error

Steer adds text to the turn running in sessionID, which the agent reads before its next step (SessionService.Steer).

func (*Remote) Undo

func (r *Remote) Undo(force bool) (api.UndoResult, error)

Undo restores the files the last turn changed; force overwrites files changed since (WorkspaceService.Undo).

func (*Remote) Unpin

func (r *Remote) Unpin(ctx context.Context, agent string) (api.PinResult, error)

Unpin returns agent to the workspace's model (WorkspaceService.UnpinModel).

func (*Remote) UpdateModelSettings

func (r *Remote) UpdateModelSettings(ref string, reset bool, changes []api.Setting) (api.ModelSettingsChange, error)

UpdateModelSettings changes a model's generation settings, or with reset clears them, and saves them (WorkspaceService.UpdateModelSettings).

type Workers

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

Workers are one workspace's workers in the service.

func AttachWorkers

func AttachWorkers(sock, dir string) *Workers

AttachWorkers reaches the workers of the workspace dir (absolute) in the service listening on sock.

func AttachWorkersHTTP

func AttachWorkersHTTP(hc connect.HTTPClient, baseURL, dir string) *Workers

AttachWorkersHTTP is AttachWorkers over any HTTP client.

func (*Workers) DisableWorker

func (w *Workers) DisableWorker(name string) (api.WorkerInfo, error)

DisableWorker stops the named worker's schedule (WorkerService.DisableWorker).

func (*Workers) EnableWorker

func (w *Workers) EnableWorker(name, hash string) (api.WorkerInfo, error)

EnableWorker enables the named worker as shown: hash is its content's, so an edit since it was shown is refused (WorkerService.EnableWorker).

func (*Workers) ListWorkers

func (w *Workers) ListWorkers() ([]api.WorkerInfo, error)

ListWorkers lists the workspace's workers with their state and schedule (WorkerService.ListWorkers).

func (*Workers) RunWorker

func (w *Workers) RunWorker(ctx context.Context, name string, on func(api.Event)) (api.Run, error)

RunWorker runs the worker now in the service, passes its events to on while it runs, and returns its record when it finishes.

func (*Workers) WorkerRuns

func (w *Workers) WorkerRuns(name string, limit int) ([]api.Run, error)

WorkerRuns lists the named worker's latest runs, at most limit, newest first (WorkerService.ListWorkerRuns).

Jump to

Keyboard shortcuts

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