access

package
v0.68.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: AGPL-3.0 Imports: 41 Imported by: 0

Documentation

Overview

Package access is the authoritative Session and Workspace application service. It owns durable session lookup, session-registry access, workspace materialization, and the policy enforcement point for those resources.

Transport code passes a trusted authz.Authority and typed input; it never receives a sqlc query handle, memory.SessionManager, config.Store, or asset store. Session and Workspace decisions are direct, domain-owned rules; every Agent gate is delegated to the Agent PEP so those rules live in one place.

Index

Constants

View Source
const (
	SessionStateIdle     = "idle"
	SessionStateRunning  = "running"
	SessionStateArchived = "archived"
)
View Source
const (
	// ListTool is the session action that lists what this agent can reach.
	// Error prose points at it, so a rename shows up here rather than in a
	// string.
	ListTool = "session_list"
)
View Source
const ToolPrefix = "session"

ToolPrefix is the family every generated session tool name starts with.

Variables

View Source
var (
	ErrForbidden   = errors.New("session access forbidden")
	ErrNotFound    = errors.New("session not found")
	ErrUnavailable = errors.New("session authorization unavailable")
)
View Source
var (
	ErrInvalid  = errors.New("invalid workspace request")
	ErrIsDir    = errors.New("workspace path is a directory")
	ErrBinary   = errors.New("workspace file appears to be binary")
	ErrTooLarge = errors.New("workspace file exceeds read limit")
)
View Source
var ErrSummaryNotFound = errors.New("session summary not found")

Functions

func DetectLanguage

func DetectLanguage(name string) string

func Dispatch added in v0.66.0

func Dispatch(ctx context.Context, h Handler, action string, args map[string]any) (any, error)

func NewAgentSessionAccess

func NewAgentSessionAccess(svc *Service) agent.SessionAccessService

NewAgentSessionAccess adapts Service to agent.Service's narrow session PEP port without making internal/agent import Session access.

func ToolNames added in v0.66.0

func ToolNames() []string

ToolNames lists every generated tool name, for callers that gate on names.

Types

type Access

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

Access captures one validated Authority for a single Session/Workspace use case. It holds no evaluation or revision; each decision reads the durable facts it needs when it runs. Do not retain it across use cases.

func (*Access) AdmitWorkspaceUpload added in v0.64.0

func (a *Access) AdmitWorkspaceUpload(ctx context.Context, agentID, sessionID string) error

AdmitWorkspaceUpload performs lightweight authorization before transport reads the request body. UploadWorkspacePath repeats the same decision at the publication boundary rather than treating this as a durable grant.

func (*Access) Archive

func (a *Access) Archive(ctx context.Context, info agentsession.Info) error

Archive persists archival after Delete has authorized the exact session.

func (*Access) ContextStats added in v0.63.3

func (a *Access) ContextStats(ctx context.Context, agentID, sessionID string) (ContextMeta, error)

ContextStats returns authorized context-window statistics without loading a transcript or materialized context page.

func (*Access) Create

func (a *Access) Create(ctx context.Context, userID, agentID, projectID string, kind agentsession.Kind, channel agentsession.Channel) (agentsession.Info, error)

Create creates a user-owned session after one create decision. It uses the registry rather than making a second, transport-owned persistence path.

func (*Access) CreateWorkspacePath

func (a *Access) CreateWorkspacePath(ctx context.Context, in WorkspaceCreateInput) (WorkspaceInfo, error)

func (*Access) Delete

func (a *Access) Delete(ctx context.Context, agentID, sessionID string) (agentsession.Info, error)

Delete resolves a routed session and authorizes archival/deletion.

func (*Access) DeleteWorkspacePath

func (a *Access) DeleteWorkspacePath(ctx context.Context, in WorkspacePathInput) error

func (*Access) Detail

func (a *Access) Detail(ctx context.Context, agentID, sessionID string) (Detail, error)

func (*Access) EnsureRead

func (a *Access) EnsureRead(ctx context.Context, req agentsession.Request) (agentsession.Info, error)

EnsureRead resolves or creates a session through the registry, then authorizes reading it. Channel session pre-resolution uses this to materialize the same durable facts later used by the turn.

func (*Access) EnsureUse

func (a *Access) EnsureUse(ctx context.Context, req agentsession.Request) (agentsession.Info, error)

EnsureUse resolves or creates a session through the registry, then authorizes executing a turn on the exact durable session. Exact-ID creation is allowed only when the caller's trusted Authority is already bound to that entry class (channel/group/worker/system); untrusted transports must use Create/ResolveMain.

func (*Access) GetSummary

func (a *Access) GetSummary(ctx context.Context, agentID, sessionID, summaryID string) (SummaryDetail, error)

GetSummary authorizes the session once, then loads a summary detail within that session's conversation.

func (*Access) List

func (a *Access) List(ctx context.Context, agentID string, opts agentsession.ListOptions) ([]agentsession.Info, error)

List lists the actor's sessions and filters every row through the same evaluation, so the collection can never show a row the actor could not read individually. The converse does not hold for an administrator: the durable query deliberately returns only their own sessions plus this agent's guest sessions, while allowSession still grants an admin Read on any single session they name. Discovery is narrower than access on purpose — an admin's own session list is not a directory of every user's private conversations.

func (*Access) ListCardPage added in v0.63.3

func (a *Access) ListCardPage(ctx context.Context, agentID string, opts agentsession.ListOptions, limit int) (CardPage, error)

ListCardPage preserves ListPage's authorization-aware cursor and performs exactly one summary-source query for the sessions returned on that page.

func (*Access) ListContextItems

func (a *Access) ListContextItems(ctx context.Context, in ContextItemListInput) (ContextItemPage, error)

ListContextItems authorizes the session once, then loads materialized context items. Old conversations without ctx_item rows fall back to raw messages.

func (*Access) ListMessages

func (a *Access) ListMessages(ctx context.Context, in MessageListInput) ([]Message, error)

ListMessages authorizes the session once, then loads transcript rows for it.

func (*Access) ListPage

func (a *Access) ListPage(ctx context.Context, agentID string, opts agentsession.ListOptions, limit int) (ListPage, error)

ListPage filters candidates through policy while retaining a cursor into the unfiltered durable result set. The next page therefore cannot be stranded by denied rows that happened to occupy the SQL page.

func (*Access) ListTranscriptPage added in v0.63.3

func (a *Access) ListTranscriptPage(ctx context.Context, in TranscriptPageInput) ([]Message, error)

ListTranscriptPage reads whole user turns from newest to oldest. AnchorSeq selects the turn containing (or immediately preceding) a find match; zero starts from the latest turn.

func (*Access) ListWorkspace

func (a *Access) ListWorkspace(ctx context.Context, in WorkspaceListInput) (WorkspaceInfo, error)

func (*Access) MoveWorkspacePath

func (a *Access) MoveWorkspacePath(ctx context.Context, in WorkspaceMoveInput) (WorkspaceInfo, error)

func (*Access) Read

func (a *Access) Read(ctx context.Context, agentID, sessionID string) (agentsession.Info, error)

Read resolves a routed session and authorizes reading it.

func (*Access) ReadCard added in v0.63.3

func (a *Access) ReadCard(ctx context.Context, agentID, sessionID string) (Card, error)

ReadCard authorizes one Session and projects the same compact shape used by list pages.

func (*Access) ReadMedia added in v0.61.0

func (a *Access) ReadMedia(ctx context.Context, agentID, sessionID, mediaID string) (Media, error)

ReadMedia authorizes the routed session before resolving a media reference that is actually attached to it. Blob failures are unavailable, never an authorization-shaped success.

func (*Access) ReadWorkspacePath

func (a *Access) ReadWorkspacePath(ctx context.Context, in WorkspaceReadInput) (WorkspaceReadResult, error)

func (*Access) ResolveChatChannel added in v0.61.0

func (a *Access) ResolveChatChannel(ctx context.Context, req agentsession.ChannelRequest) (agentsession.Info, error)

ResolveChatChannel resolves the session a chat channel is currently bound to, creating one when the binding has none yet. It is the channel adapters' entry point: unlike EnsureUse it never treats a derived key as a session id, so the chat can rotate onto a successor without changing identity.

func (*Access) ResolveMain

func (a *Access) ResolveMain(ctx context.Context, userID, agentID string) (agentsession.Info, error)

ResolveMain resolves the caller's durable main session in this Access.

func (*Access) RotateChannel added in v0.61.0

func (a *Access) RotateChannel(ctx context.Context, req agentsession.ChannelRequest) (agentsession.Info, error)

RotateChannel archives a chat channel's current session and returns its successor. Both halves are decided here under one evaluation — Delete on the session being retired and Create on the one replacing it — because the successor does not exist yet and the predecessor is chosen by the registry. req.ExpectedSessionID, when set, makes this a compare-and-rotate.

func (*Access) RotateMain added in v0.61.0

func (a *Access) RotateMain(ctx context.Context, userID, agentID, expectedSessionID string) (agentsession.Info, error)

RotateMain archives the caller's current main session and returns its successor. Both halves are decided here under one evaluation — Delete on the session being retired and Create on the one replacing it — because the successor does not exist yet and the predecessor is chosen by the registry: no caller can pre-authorize an Info and hand it to the lifecycle layer. expectedSessionID, when set, makes this a compare-and-rotate.

func (*Access) SessionRunning added in v0.63.0

func (a *Access) SessionRunning(info agentsession.Info) bool

SessionRunning reports process-local turn state for an already-authorized session record. Durable terminal state remains on Info.

func (*Access) UpdateTitle

func (a *Access) UpdateTitle(ctx context.Context, info agentsession.Info, title string) error

UpdateTitle persists a title after Write has authorized the exact session.

func (*Access) UploadWorkspacePath

func (a *Access) UploadWorkspacePath(ctx context.Context, in WorkspaceUploadInput) (WorkspaceUploadResult, error)

func (*Access) Usage added in v0.65.0

func (a *Access) Usage(ctx context.Context, agentID, sessionID string) (Usage, error)

Usage reads accounting only after the ordinary Session read decision. The SQL query is intentionally unscoped because this PEP has already bound the session to its durable owner and route agent.

func (*Access) Use

func (a *Access) Use(ctx context.Context, agentID, sessionID string) (agentsession.Info, error)

Use resolves a routed session and authorizes a turn on it.

func (*Access) Workspace

func (a *Access) Workspace(ctx context.Context, agentID, sessionID string, action authz.Action) (agentsession.Info, error)

Workspace authorizes a workspace operation under the session's durable facts. It reuses the Session read gate and then applies the direct Workspace rule in this same Access; there is deliberately no second Begin between them.

func (*Access) Write

func (a *Access) Write(ctx context.Context, agentID, sessionID string) (agentsession.Info, error)

Write resolves a routed session and authorizes a metadata mutation.

func (*Access) WriteWorkspacePath

func (a *Access) WriteWorkspacePath(ctx context.Context, in WorkspaceWriteInput) (WorkspaceReadResult, error)

type ActionTool added in v0.66.0

type ActionTool = toolmeta.ActionTool

ActionTool describes one generated tool: an exact schema bound to one action.

func ActionTools added in v0.66.0

func ActionTools() []ActionTool

ActionTools lists every generated tool in a stable order.

type AgentServiceManager

type AgentServiceManager interface {
	GetService(agentID string) *agent.Service
	Default() *agent.Service
}

AgentServiceManager is the production pool shape. The adapter keeps the Session access port narrow despite agent.PoolManager returning concrete services from its public API.

type AgentSystemPrompt added in v0.67.0

type AgentSystemPrompt func(ctx context.Context, agentID string) (string, error)

AgentSystemPrompt reads one agent's configured system prompt. It is a func rather than a port because the builder's other config-shaped deps (Projects, Skills) already are, and because a failure here is non-fatal: the prompt is simply built without the agent's own instructions.

func ConfigAgentSystemPrompt added in v0.67.0

func ConfigAgentSystemPrompt(store config.Store) AgentSystemPrompt

ConfigAgentSystemPrompt reads the system prompt from the deployment config store.

type AttachInput

type AttachInput struct {
	Authority authz.Authority
	AgentID   string
	SessionID string
}

type AttachResult

type AttachResult struct {
	Events               <-chan agent.Event
	Cancel               func()
	Live                 bool
	BeforeProtectedEvent func(context.Context) error
}

type Card added in v0.63.3

type Card struct {
	ID            string
	Title         string
	Summary       string
	State         string
	Sendable      bool
	LastActive    time.Time
	TurnStartedAt time.Time
}

Card is the reusable, model-safe Session projection. Kind remains available on Info for internal routing but deliberately does not cross this boundary.

type CardPage added in v0.63.3

type CardPage struct {
	Sessions   []Card
	NextOffset int
	HasMore    bool
	// contains filtered or unexported fields
}

type ContextItem

type ContextItem struct {
	Ordinal   int
	EventType *string
	Message   *ContextMessage
	Summary   *Summary
}

type ContextItemListInput

type ContextItemListInput struct {
	AgentID   string
	SessionID string
	PageSize  int
	Offset    int
}

type ContextItemPage

type ContextItemPage struct {
	Items         []ContextItem
	Meta          ContextMeta
	NextOffset    int
	HasNextOffset bool
}

type ContextMessage

type ContextMessage struct {
	ID              string
	Seq             int
	Role            string
	EventType       *string
	Content         *string
	Timestamp       time.Time
	TokenCount      int
	ActorType       string
	ActorID         string
	SourceSessionID string
}

type ContextMeta

type ContextMeta struct {
	MessageCount     int
	SourceTokenCount int
	ActiveTokenCount int
	SummaryCount     int
	SummaryDepth     int
	OldestAt         *time.Time
	NewestAt         *time.Time
}

type Detail

type Detail struct {
	Info      agentsession.Info
	AgentName string
}

Detail resolves an authorized session and the non-sensitive display facts the HTTP representation needs. Configuration lookup remains inside the domain service; transports never reach config.Store for a session.

type Handler added in v0.66.0

type ListPage

type ListPage struct {
	Sessions   []agentsession.Info
	NextOffset int
	HasMore    bool
}

type MarkViewedInput added in v0.63.0

type MarkViewedInput struct {
	Authority authz.Authority
	AgentID   string
	SessionID string
}

type Media added in v0.61.0

type Media struct {
	ID       string
	MimeType string
	SHA256   [sha256.Size]byte
	Data     []byte
}

Media is one authorized immutable media object ready for an HTTP response. Its digest is retained solely to form an ETag; no storage path is exposed.

type Message

type Message struct {
	ID              string
	Seq             int64
	Role            string
	EventType       string
	Content         string
	Parts           []MessagePart
	TokenCount      int64
	CreatedAt       time.Time
	ActorType       string
	ActorID         string
	SourceSessionID string
}

type MessageListInput

type MessageListInput struct {
	AgentID   string
	SessionID string
	Limit     int
	Skip      int
	After     *string
	Before    *string
	SeqFrom   *int
	SeqTo     *int
}

type MessagePart added in v0.61.0

type MessagePart struct {
	Type     string
	Text     string
	MediaID  string
	MimeType string
}

MessagePart is the transcript-safe projection of an ordered durable part. Image parts intentionally expose only an authenticated media reference.

type ModelUsage added in v0.65.0

type ModelUsage struct {
	Provider          string
	Model             string
	CallCount         int64
	ReportedCallCount int64
	PricedCallCount   int64
	InputTokens       *int64
	OutputTokens      *int64
	CacheReadTokens   *int64
	CacheWriteTokens  *int64
	CostUSD           *float64
}

ModelUsage is the exact provider-reported accounting for one model within a session. Nil totals are deliberate: partial data is not a session total.

type Option

type Option func(*Service)

func WithHomeWorkspace added in v0.64.0

func WithHomeWorkspace(opener home.RootOpener) Option

func WithSystemPromptBuilder

func WithSystemPromptBuilder(builder *SystemPromptBuilder) Option

func WithUsageProgress added in v0.65.0

func WithUsageProgress(progress UsageProgress) Option

type PromptPlugins

type PromptPlugins interface {
	SessionPluginView(context.Context) (pkgplugins.SessionPluginView, error)
	SystemPromptSections(context.Context, pkgplugins.SystemPromptContext) ([]pkgplugins.SystemPromptSection, error)
	ManifestPluginPrompts() []pkgplugins.SystemPromptSection
}

type RuntimeManager

type RuntimeManager interface {
	GetService(agentID string) RuntimeService
	Default() RuntimeService
}

RuntimeManager is the typed runtime lookup port used by session Send/Attach. Tests can provide a deterministic in-memory implementation; production wraps the agent pool with NewRuntimeManager.

func NewRuntimeManager

func NewRuntimeManager(inner AgentServiceManager) RuntimeManager

type RuntimeService

type RuntimeService interface {
	Chat(context.Context, agent.ChatRequest) <-chan agent.Event
	RunManagedSession(context.Context, delegatetool.ManagedSessionRequest) (delegatetool.ManagedSessionResult, error)
	RunConversationSession(context.Context, agentsession.Info, agent.MessageContent) <-chan agent.Event
	StopSession(context.Context, string) bool
	SubscribeSession(sessionID string) (<-chan agent.Event, func())
	SessionLive(sessionID string) bool
	CompactAuthorizedSession(context.Context, agentsession.Info) (string, error)
}

RuntimeService is the narrow live-turn port Session access needs from the agent runtime. It deliberately excludes session lookup and policy concerns.

type SendInput

type SendInput struct {
	Authority     authz.Authority
	AgentID       string
	SessionID     string
	Message       agent.MessageContent
	ExcludedTools []string
}

type SendResult

type SendResult struct {
	Events     <-chan agent.Event
	PlainReply string
}

type Service

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

Service owns Session/Workspace use cases and their narrow persistence ports. Agent authorization is delegated wholesale to agents so the two domains cannot drift; this service never re-implements an Agent rule.

func NewService

func NewService(mem memory.Provider, db sqlc.DBTX, store config.Store, assets *asset.Store, agents *agentaccess.Service, opts ...Option) (*Service, error)

NewService constructs the only Session/Workspace PEP. The registry remains the canonical lifecycle owner; this service owns its policy-scoped use and routes every Agent decision through the shared Agent PEP.

func (*Service) Attach

func (s *Service) Attach(ctx context.Context, in AttachInput) (AttachResult, error)

Attach authorizes read access and subscribes to an existing live turn. It never starts a turn. The returned guard starts a fresh Access and Read immediately before each non-store event is encoded, so revocation cannot leak the protected source event that triggered the check.

func (*Service) Begin

func (s *Service) Begin(_ context.Context, authority authz.Authority) (*Access, error)

Begin validates the Authority for one Session/Workspace use case. The context is unused today; it stays in the signature so the agent runtime's session PEP port and every transport caller remain identical.

func (*Service) BindRuntimeManager

func (s *Service) BindRuntimeManager(runtime RuntimeManager) error

BindRuntimeManager wires the live runtime port after the pool has been constructed. It is a one-time composition-root bind; handlers must not look up agent services directly.

func (*Service) GetSystemPrompt

func (s *Service) GetSystemPrompt(ctx context.Context, in SystemPromptInput) (string, error)

GetSystemPrompt resolves, authorizes, and builds a session's effective system prompt behind the session PEP.

func (*Service) MarkViewed added in v0.63.0

func (s *Service) MarkViewed(ctx context.Context, in MarkViewedInput) error

MarkViewed clears terminal status for a session the caller can read.

func (*Service) ReadRecall added in v0.63.3

func (s *Service) ReadRecall(ctx context.Context, authority authz.Authority, agentID string, ref memory.RecallReference, tokenCap int) (memory.RecallDocument, error)

ReadRecall implements memory.RecallSource through the Session PEP.

func (*Service) ResolveInboxDelivery added in v0.63.3

func (s *Service) ResolveInboxDelivery(ctx context.Context, sourceSessionID, targetSessionID, actorID string) (agentsession.Info, error)

ResolveInboxDelivery freshly authorizes both endpoints of one recovered Agent-originated input. It returns only the target scope; recovery remains append-only and cannot reach a runtime through this interface.

func (*Service) SearchRecall added in v0.63.3

func (s *Service) SearchRecall(ctx context.Context, authority authz.Authority, agentID, query string, limit int) ([]memory.RecallSearchResult, error)

SearchRecall implements memory.RecallSource through the Session PEP.

func (*Service) Send

func (s *Service) Send(ctx, runCtx context.Context, in SendInput) (SendResult, error)

Send authorizes and starts exactly one foreground turn. The returned event chunks are not re-authorized by Session access; the single Access evaluation covers the turn initiation, matching the send semantics expected by the UI.

func (*Service) Stop added in v0.63.0

func (s *Service) Stop(ctx context.Context, in StopInput) error

Stop authorizes use of a session and explicitly cancels its active turn. It is idempotent: stopping an idle session succeeds without inventing state.

type SessionCreateInput added in v0.66.0

type SessionCreateInput struct {
	Message string `json:"message,omitempty"`
	Preset  string `json:"preset,omitempty"`
	Wait    *bool  `json:"wait,omitempty"`
}

type SessionGetInput added in v0.66.0

type SessionGetInput struct {
	Cursor             string `json:"cursor,omitempty"`
	SessionId          string `json:"session_id,omitempty"`
	TranscriptPageSize int    `json:"transcript_page_size,omitempty"`
}

type SessionListInput added in v0.66.0

type SessionListInput struct {
	IncludeArchived *bool  `json:"include_archived,omitempty"`
	PageSize        int    `json:"page_size,omitempty"`
	PageToken       string `json:"page_token,omitempty"`
}

type SessionSendInput added in v0.66.0

type SessionSendInput struct {
	Message   string `json:"message,omitempty"`
	SessionId string `json:"session_id,omitempty"`
	Wait      *bool  `json:"wait,omitempty"`
}

type StopInput added in v0.63.0

type StopInput struct {
	Authority authz.Authority
	AgentID   string
	SessionID string
}

type Summary

type Summary struct {
	ID                      string
	Kind                    string
	Depth                   int
	Content                 string
	TokenCount              int
	EarliestAt              *time.Time
	LatestAt                *time.Time
	DescendantCount         int
	DescendantTokenCount    int
	SourceMessageTokenCount int
	CreatedAt               time.Time
}

type SummaryDetail

type SummaryDetail struct {
	Summary        Summary
	Children       []Summary
	MessageSeqFrom int
	MessageSeqTo   int
}

type SystemPromptBuildInput

type SystemPromptBuildInput struct {
	Info agentsession.Info
}

type SystemPromptBuilder

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

SystemPromptBuilder assembles a session's effective system prompt from the deps it was constructed with. Its deps are the seams; the builder itself has exactly one behaviour.

func NewSystemPromptBuilder

func NewSystemPromptBuilder(deps SystemPromptDeps) (*SystemPromptBuilder, error)

func (*SystemPromptBuilder) BuildSessionSystemPrompt

func (b *SystemPromptBuilder) BuildSessionSystemPrompt(ctx context.Context, in SystemPromptBuildInput) (string, error)

type SystemPromptDeps

type SystemPromptDeps struct {
	Memory    memory.Provider
	Agents    AgentSystemPrompt
	Projects  agent.ProjectResolverFunc
	Workspace home.RootOpener
	Plugins   PromptPlugins
	Skills    PromptSkillSectionBuilder
}

type SystemPromptInput

type SystemPromptInput struct {
	Authority authz.Authority
	AgentID   string
	SessionID string
}

SystemPromptInput is the transport-owned identity and route tuple for the session system-prompt read use case.

type Tool added in v0.63.0

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

Tool is one generated session action. The tool name carries the action, so the provider validates arguments against an exact schema before dispatch. Identity always comes from the runtime context; model arguments cannot select another principal or Agent.

func NewTool added in v0.63.0

func NewTool(svc *Service, spec ActionTool) *Tool

NewTool builds one session action tool.

func (*Tool) Definition added in v0.63.0

func (t *Tool) Definition() tools.Definition

func (*Tool) Execute added in v0.63.0

func (t *Tool) Execute(ctx context.Context, args map[string]any) (string, error)

type TranscriptPageInput added in v0.63.3

type TranscriptPageInput struct {
	AgentID   string
	SessionID string
	AnchorSeq int64
	// SnapshotSeq caps the visible transcript before logical turns are formed.
	// Zero keeps a live view; session.get cursors set an exact snapshot sequence.
	SnapshotSeq int64
	Offset      int
	Limit       int
}

type Usage added in v0.65.0

type Usage struct {
	PendingCallCount  int64
	CallCount         int64
	ReportedCallCount int64
	PricedCallCount   int64
	InputTokens       *int64
	OutputTokens      *int64
	CacheReadTokens   *int64
	CacheWriteTokens  *int64
	CostUSD           *float64
	Models            []ModelUsage
}

Usage is the session-wide rollup plus its per-model breakdown.

type UsageProgress added in v0.65.0

type UsageProgress interface {
	PendingCallCount(sessionID string) int64
}

UsageProgress exposes only the completion state of asynchronously persisted usage. Accounting rows remain owned by the session service's query port.

type WorkspaceCreateInput

type WorkspaceCreateInput struct {
	AgentID   string
	SessionID string
	Scope     WorkspaceScope
	Path      string
	Content   string
	IsDir     bool
}

type WorkspaceInfo

type WorkspaceInfo struct {
	Root       string   `json:"root"`
	Paths      []string `json:"paths"`
	TotalFiles int      `json:"total_files"`
	TotalDirs  int      `json:"total_dirs"`
	TotalBytes int64    `json:"total_bytes"`
}

type WorkspaceListInput

type WorkspaceListInput struct {
	AgentID    string
	SessionID  string
	Scope      WorkspaceScope
	ShowHidden bool
	Path       string
	Depth      int
}

type WorkspaceMoveInput

type WorkspaceMoveInput struct {
	AgentID   string
	SessionID string
	Scope     WorkspaceScope
	Path      string
	NewPath   string
}

type WorkspacePathInput

type WorkspacePathInput struct {
	AgentID   string
	SessionID string
	Scope     WorkspaceScope
	Path      string
}

type WorkspaceReadInput

type WorkspaceReadInput struct {
	AgentID   string
	SessionID string
	Scope     WorkspaceScope
	Path      string
	Raw       bool
	// MaxBytes bounds allocation at the authorized file boundary. Zero leaves
	// existing workspace read behavior unchanged.
	MaxBytes int64
}

type WorkspaceReadResult

type WorkspaceReadResult struct {
	Path         string    `json:"path"`
	Content      string    `json:"content,omitempty"`
	Language     string    `json:"language,omitempty"`
	Raw          bool      `json:"-"`
	RawName      string    `json:"-"`
	RawMediaType string    `json:"-"`
	RawContent   []byte    `json:"-"`
	RawModTime   time.Time `json:"-"`
}

type WorkspaceScope

type WorkspaceScope string
const (
	WorkspaceScopeAgent WorkspaceScope = "agent"
	WorkspaceScopeUser  WorkspaceScope = "user"
)

type WorkspaceUploadInput

type WorkspaceUploadInput struct {
	AgentID       string
	SessionID     string
	Filename      string
	Reader        io.Reader
	ContentLength *int64
	Now           time.Time
}

type WorkspaceUploadResult

type WorkspaceUploadResult struct {
	// Path is a portable logical path expression, never a host coordinate.
	Path string `json:"path"`
	// RelativePath is the upload location relative to its workspace root.
	// Combine with Scope to build a workspace file-content read URL.
	RelativePath string `json:"relative_path"`
	// Scope is the workspace root the file was written to.
	Scope WorkspaceScope `json:"scope"`
}

type WorkspaceWriteInput

type WorkspaceWriteInput struct {
	AgentID   string
	SessionID string
	Scope     WorkspaceScope
	Path      string
	Content   string
}

Jump to

Keyboard shortcuts

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