Help us shape the future of Go! Take the 2026 Go Developer Survey

app

package
v0.1.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDeploymentListLimit    = 20
	MaxDeploymentListLimit        = 100
	DefaultDeploymentRunListLimit = 20
	MaxDeploymentRunListLimit     = 1000
	MaxDeploymentVaults           = 50
	MaxDeploymentInitialEvents    = 50
	ScheduleClaimLease            = 2 * time.Minute
)
View Source
const (
	DefaultEnvironmentWorkListLimit = 100
	MaxEnvironmentWorkListLimit     = 1000
	// MaxEnvironmentWorkTTLSeconds bounds the time a lost worker can retain a
	// Session execution lease. Healthy workers extend the lease continuously,
	// so longer individual TTLs only increase the stale-owner window.
	MaxEnvironmentWorkTTLSeconds = int64(300)
)
View Source
const (
	DefaultFileListLimit       = 20
	MaxFileListLimit           = 1000
	MaxFileBytes         int64 = 500 << 20
)
View Source
const (
	DefaultMemoryStoreListLimit   = 20
	MaxMemoryStoreListLimit       = 100
	DefaultMemoryListLimit        = 20
	MaxMemoryListLimit            = 100
	MaxFullMemoryListLimit        = 20
	DefaultMemoryVersionListLimit = 20
	MaxMemoryVersionListLimit     = 100
	MaxMemoriesPerStore           = 2000
	MaxMemoryContentBytes         = 102400
	MaxMemoryPathBytes            = 1024
)
View Source
const (
	// The Agent and Agent Version list bounds are documented by Mango's public
	// API.
	DefaultAgentListLimit = 20
	MaxAgentListLimit     = 100

	// The Environment list reference documents no default or maximum. Mango
	// applies its existing general list bounds as a local operational choice.
	DefaultEnvironmentListLimit = 100
	MaxEnvironmentListLimit     = 1000
)
View Source
const (
	// MaxSkillUploadBytes follows the upstream custom Skill requirement that a
	// complete upload remain below 30 MB.
	MaxSkillUploadBytes int64 = 30_000_000
	MaxSkillFiles       int   = 1000
)
View Source
const (
	MaxSessionSkills     = 500
	MaxSessionSkillBytes = 500 << 20
)
View Source
const (
	DefaultSkillListLimit        = 20
	MaxSkillListLimit            = 100
	DefaultSkillVersionListLimit = 20
	MaxSkillVersionListLimit     = 1000
)
View Source
const (
	DefaultVaultListLimit      = 20
	MaxVaultListLimit          = 100
	DefaultCredentialListLimit = 20
	MaxCredentialListLimit     = 100
	MaxCredentialsPerVault     = 20
)
View Source
const (
	DefaultWebhookPollInterval = time.Second
	DefaultWebhookClaimLease   = 2 * time.Minute
	DefaultWebhookHTTPTimeout  = 15 * time.Second
	DefaultWebhookBatchSize    = 25
	DefaultWebhookRetention    = 30 * 24 * time.Hour
	DefaultWebhookCleanupEvery = time.Hour
	MaxWebhookDeliveryAttempts = 3
)
View Source
const (
	DefaultWebhookListLimit = 20
	MaxWebhookListLimit     = 100
	MaxWebhooksPerWorkspace = 100
	MaxWebhookURLBytes      = 2048
	MaxWebhookEventTypes    = 64
)
View Source
const DefaultSessionThreadListLimit = 1000
View Source
const MaxToolOutputBytes = 32 << 20
View Source
const ToolOutputDirectory = ".mango-tool-results"
View Source
const UploadLeaseDuration = time.Minute

UploadLeaseDuration is measured by PostgreSQL, not an API process's clock. Each public upload has a unique immutable resource identity and one writer.

Variables

View Source
var ErrBlobNotWritten = errors.New("blob write did not start")

ErrBlobNotWritten positively identifies failure before any remote write. Other storage errors may mean the caller stopped waiting for a commit.

View Source
var ErrBlobTooLarge = errors.New("blob exceeds maximum size")

ErrBlobTooLarge lets a streaming blob implementation stop after one byte beyond MaxFileBytes without buffering the complete upload.

View Source
var ErrUploadLeaseLost = errors.New("upload ownership was lost")

ErrUploadLeaseLost is a definite ownership failure, distinct from an uncertain completion response that may already have committed.

Functions

func CanonicalMCPServerURL

func CanonicalMCPServerURL(raw string) (string, error)

CanonicalMCPServerURL is the single identity function used for stored MCP credential keys and, in the runtime PR, for MCP server lookup. It rejects plaintext transport and URL features that could redirect credentials to a different authority.

func OpenWebhookSigningSecret

func OpenWebhookSigningSecret(
	cipher secretcrypto.Cipher,
	webhookID string,
	envelope domain.SecretEnvelope,
) ([]byte, error)

func ResolveAgentSkillReferences

func ResolveAgentSkillReferences(
	ctx context.Context,
	resolver SkillReferenceResolver,
	references []domain.SkillReference,
) ([]domain.SkillReference, error)

ResolveAgentSkillReferences validates Mango's current Skill union and delegates custom Version lookup when the effective list is non-empty.

func SkillExpandedBudgetBytes

func SkillExpandedBudgetBytes(size int64) (int64, bool)

SkillExpandedBudgetBytes validates the exact sandbox footprint used for Session admission against the per-bundle limit.

func SupportedWebhookEventTypes

func SupportedWebhookEventTypes() []string

func ToolOutputPath

func ToolOutputPath(fileID string) string

func ValidateMetadata

func ValidateMetadata(metadata map[string]any) error

ValidateMetadata exposes the shared public-resource metadata contract to alternate control-plane service wiring.

Types

type AgentListPage

type AgentListPage struct {
	Agents  []domain.Agent
	HasNext bool
}

type AgentListQuery

type AgentListQuery struct {
	CreatedAtGte    *time.Time
	CreatedAtLte    *time.Time
	IncludeArchived bool
	After           *ResourcePageBoundary
	Limit           int
}

AgentListQuery is deliberately distinct from EnvironmentListQuery because the two public endpoints expose different filters.

type AgentRepository

AgentRepository is the persistence boundary for versioned Agent resources. The application service owns validation and timestamps; the repository owns atomic version allocation and lifecycle concurrency.

type AgentService

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

func NewAgentService

func NewAgentService(
	repo AgentRepository,
	ids domain.IDGenerator,
	clock domain.Clock,
	skillResolvers ...SkillReferenceResolver,
) *AgentService

func (*AgentService) Archive

func (s *AgentService) Archive(ctx context.Context, id string) (domain.Agent, error)

func (*AgentService) Create

func (s *AgentService) Create(ctx context.Context, a domain.Agent) (domain.Agent, error)

func (*AgentService) Get

func (s *AgentService) Get(ctx context.Context, id string) (domain.Agent, error)

func (*AgentService) List

func (*AgentService) Update

func (s *AgentService) Update(ctx context.Context, id string, patch domain.AgentPatch) (domain.Agent, error)

func (*AgentService) Versions

type AgentVersionListPage

type AgentVersionListPage struct {
	Versions []domain.Agent
	HasNext  bool
}

type AgentVersionListQuery

type AgentVersionListQuery struct {
	AfterVersion int
	Limit        int
}

AgentVersionListQuery pages forward through one Agent's immutable version history. Versions are returned in ascending numeric order.

type BlobCleanupIntent

type BlobCleanupIntent struct {
	BlobKey  string
	Revision int64
}

BlobCleanupIntent survives removal or reuse of the upload's metadata row. Revision fences an older cleanup acknowledgement from a newer late write.

type BlobCleanupRepository

type BlobCleanupRepository interface {
	RetainBlobCleanup(context.Context, string, bool) (BlobCleanupIntent, error)
	TouchBlobCleanup(context.Context, BlobCleanupIntent) error
	ListBlobCleanup(context.Context) ([]BlobCleanupIntent, error)
	RemoveBlobCleanup(context.Context, BlobCleanupIntent) error
}

type BlobInfo

type BlobInfo struct {
	SizeBytes      int64
	ChecksumSHA256 string
}

func ComputeBlobInfo

func ComputeBlobInfo(body []byte) BlobInfo

ComputeBlobInfo is shared by blob implementations and test doubles.

type BlobStore

type BlobStore interface {
	Put(context.Context, string, string, io.Reader, int64) (BlobInfo, error)
	Open(context.Context, string) (io.ReadCloser, error)
	Delete(context.Context, string) error
}

BlobStore is intentionally small so S3-compatible storage can back Files and immutable Skill archives without leaking provider types into the application or HTTP layers.

type CreateSessionInput

type CreateSessionInput struct {
	AgentID         string
	AgentVersion    *int
	Overrides       *domain.AgentOverrides
	EnvironmentID   string
	Title           string
	Metadata        map[string]any
	InitialEvents   []domain.EventDraft
	MemoryResources []MemorySessionResourceInput
	VaultIDs        []string
	Budget          *domain.SessionBudget
	DeploymentID    *string
	DeploymentRun   *domain.DeploymentRun
}

CreateSessionInput is the storage-independent command accepted by the control-plane session service.

type CredentialAuthCreateInput

type CredentialAuthCreateInput struct {
	Type         string
	MCPServerURL string
	Token        string
	AccessToken  string
	ExpiresAt    *time.Time
	Refresh      *OAuthRefreshCreateInput
}

type CredentialAuthUpdateInput

type CredentialAuthUpdateInput struct {
	Type        string
	Token       NullablePatch[string]
	AccessToken NullablePatch[string]
	ExpiresAt   NullablePatch[time.Time]
	Refresh     NullablePatch[OAuthRefreshUpdateInput]
}

type CredentialCreateInput

type CredentialCreateInput struct {
	DisplayName *string
	Metadata    map[string]string
	Auth        CredentialAuthCreateInput
}

type CredentialListPage

type CredentialListPage struct {
	Credentials []domain.VaultCredential
	HasNext     bool
}

type CredentialListQuery

type CredentialListQuery struct {
	IncludeArchived bool
	After           *ResourcePageBoundary
	Limit           int
}

type CredentialRefreshValidation

type CredentialRefreshValidation struct {
	Status       credentialruntime.OAuthRefreshStatus `json:"status"`
	HTTPResponse *credentialruntime.HTTPResponse      `json:"http_response"`
}

type CredentialUpdateInput

type CredentialUpdateInput struct {
	DisplayName NullablePatch[string]
	Metadata    NullablePatch[map[string]*string]
	Auth        *CredentialAuthUpdateInput
}

type CredentialValidation

type CredentialValidation struct {
	CredentialID    string
	VaultID         string
	ValidatedAt     time.Time
	HasRefreshToken bool
	Status          credentialruntime.Verdict
	MCPProbe        *credentialruntime.MCPProbeFailure
	Refresh         *CredentialRefreshValidation
}

type DeploymentCreateInput

type DeploymentCreateInput struct {
	AgentID       string
	AgentVersion  *int
	EnvironmentID string
	Name          string
	Description   string
	InitialEvents []domain.EventDraft
	Resources     []domain.DeploymentResource
	VaultIDs      []string
	Budget        *domain.SessionBudget
	Metadata      map[string]string
	Schedule      *domain.DeploymentSchedule
}

type DeploymentListBoundary

type DeploymentListBoundary struct {
	CreatedAt time.Time
	ID        string
}

type DeploymentListPage

type DeploymentListPage struct {
	Deployments []domain.Deployment
	HasMore     bool
}

type DeploymentListQuery

type DeploymentListQuery struct {
	AgentID         string
	CreatedAtGte    *time.Time
	CreatedAtLte    *time.Time
	IncludeArchived bool
	Status          string
	Boundary        *DeploymentListBoundary
	Limit           int
}

type DeploymentMemoryReader

type DeploymentMemoryReader interface {
	GetStore(context.Context, string) (domain.MemoryStore, error)
}

type DeploymentReconciler

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

func NewDeploymentReconciler

func NewDeploymentReconciler(runner ScheduledDeploymentRunner) *DeploymentReconciler

func (*DeploymentReconciler) Run

Run claims due cron occurrences through PostgreSQL and creates their Sessions. Token-fenced claims are renewed during admission and scheduled run rows are unique per occurrence, so multiple worker replicas can run this loop safely and a crashed worker is retried without exposing duplicate successful Sessions.

type DeploymentRunListBoundary

type DeploymentRunListBoundary struct {
	CreatedAt time.Time
	ID        string
}

type DeploymentRunListPage

type DeploymentRunListPage struct {
	Runs    []domain.DeploymentRun
	HasMore bool
}

type DeploymentRunListQuery

type DeploymentRunListQuery struct {
	CreatedAtGt  *time.Time
	CreatedAtGte *time.Time
	CreatedAtLt  *time.Time
	CreatedAtLte *time.Time
	DeploymentID *string
	HasError     *bool
	TriggerType  string
	Boundary     *DeploymentRunListBoundary
	Limit        int
}

type DeploymentScheduleClaim

type DeploymentScheduleClaim struct {
	WorkspaceID  string
	DeploymentID string
	ScheduledAt  time.Time
	Token        string
}

type DeploymentService

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

func NewDeploymentService

func NewDeploymentService(config DeploymentServiceConfig) *DeploymentService

func (*DeploymentService) Archive

func (*DeploymentService) ClaimDue

func (s *DeploymentService) ClaimDue(
	ctx context.Context,
	limit int,
) ([]DeploymentScheduleClaim, error)

func (*DeploymentService) Create

func (*DeploymentService) Get

func (*DeploymentService) GetRun

func (*DeploymentService) List

func (*DeploymentService) ListRuns

func (*DeploymentService) Pause

func (*DeploymentService) RenewClaim

func (s *DeploymentService) RenewClaim(
	ctx context.Context,
	claim DeploymentScheduleClaim,
) error

func (*DeploymentService) Run

func (*DeploymentService) RunScheduled

func (s *DeploymentService) RunScheduled(
	ctx context.Context,
	id string,
	scheduledAt time.Time,
) (domain.DeploymentRun, error)

func (*DeploymentService) Unpause

func (*DeploymentService) Update

type DeploymentServiceConfig

type DeploymentServiceConfig struct {
	Repository   DeploymentRepository
	Agents       AgentRepository
	Environments EnvironmentRepository
	Sessions     DeploymentSessionCreator
	Memory       DeploymentMemoryReader
	Vaults       DeploymentVaultReader
	IDGenerator  domain.IDGenerator
	Clock        domain.Clock
}

type DeploymentSessionCreator

type DeploymentSessionCreator interface {
	Create(context.Context, CreateSessionInput) (domain.Session, error)
}

type DeploymentVaultReader

type DeploymentVaultReader interface {
	GetVault(context.Context, string) (domain.Vault, error)
}

type EnvironmentListPage

type EnvironmentListPage struct {
	Environments []domain.Environment
	HasNext      bool
}

type EnvironmentListQuery

type EnvironmentListQuery struct {
	IncludeArchived bool
	After           *ResourcePageBoundary
	Limit           int
}

EnvironmentListQuery exposes only the parameters documented for GET /v1/environments: include_archived, limit, and page.

type EnvironmentRepository

EnvironmentRepository is the persistence boundary for Environment resources. DeleteIfUnreferenced must make the delete/reference check atomic.

type EnvironmentService

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

func NewEnvironmentService

func NewEnvironmentService(
	env EnvironmentRepository,
	ids domain.IDGenerator,
	clock domain.Clock,
) *EnvironmentService

func (*EnvironmentService) Archive

func (*EnvironmentService) Create

func (*EnvironmentService) Delete

func (s *EnvironmentService) Delete(ctx context.Context, id string) error

func (*EnvironmentService) Get

func (*EnvironmentService) List

func (*EnvironmentService) Update

type EnvironmentWorkListPage

type EnvironmentWorkListPage struct {
	Work    []domain.EnvironmentWork
	HasNext bool
}

type EnvironmentWorkListQuery

type EnvironmentWorkListQuery struct {
	After *ResourcePageBoundary
	Limit int
}

type EnvironmentWorkPollInput

type EnvironmentWorkPollInput struct {
	WorkerID   string
	ReclaimAge time.Duration
}

type EnvironmentWorkService

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

EnvironmentWorkService exposes Mango's self-hosted Environment worker protocol over the same durable Session ledger used by the managed runtime.

func NewEnvironmentWorkService

func NewEnvironmentWorkService(
	repository EnvironmentWorkRepository,
	environments EnvironmentRepository,
) *EnvironmentWorkService

func (*EnvironmentWorkService) Ack

func (s *EnvironmentWorkService) Ack(
	ctx context.Context,
	environmentID, workID string,
) (domain.EnvironmentWork, error)

func (*EnvironmentWorkService) CompleteHealthcheck

func (s *EnvironmentWorkService) CompleteHealthcheck(ctx context.Context, environmentID, workID string, result domain.EnvironmentWorkResult) (domain.EnvironmentWork, error)

func (*EnvironmentWorkService) CreateHealthcheck

func (s *EnvironmentWorkService) CreateHealthcheck(ctx context.Context, environmentID string) (domain.EnvironmentWork, error)

func (*EnvironmentWorkService) Fail

func (s *EnvironmentWorkService) Fail(
	ctx context.Context,
	environmentID, workID, message string,
) error

func (*EnvironmentWorkService) Get

func (s *EnvironmentWorkService) Get(
	ctx context.Context,
	environmentID, workID string,
) (domain.EnvironmentWork, error)

func (*EnvironmentWorkService) Heartbeat

func (s *EnvironmentWorkService) Heartbeat(
	ctx context.Context,
	environmentID, workID string,
	expected *string,
	desiredTTL *int64,
) (domain.EnvironmentWorkHeartbeat, error)

func (*EnvironmentWorkService) List

func (*EnvironmentWorkService) Poll

func (s *EnvironmentWorkService) Poll(
	ctx context.Context,
	environmentID, workerID string,
	block time.Duration,
	reclaimAge *time.Duration,
) (*domain.EnvironmentWork, error)

func (*EnvironmentWorkService) Stats

func (*EnvironmentWorkService) Stop

func (s *EnvironmentWorkService) Stop(
	ctx context.Context,
	environmentID, workID string,
	force bool,
	expectedIdleEventID *string,
) error

func (*EnvironmentWorkService) Update

func (s *EnvironmentWorkService) Update(
	ctx context.Context,
	environmentID, workID string,
	metadata map[string]*string,
) (domain.EnvironmentWork, error)

type EventPageBoundary

type EventPageBoundary struct {
	ProcessedAt *time.Time
	Sequence    int64
}

EventPageBoundary is the complete key carried by an opaque List Events cursor. ProcessedAt is nil for events that have not been processed yet; Sequence is the deterministic tie-breaker for equal (including nil) timestamps.

type EventQuery

type EventQuery struct {
	// ThreadID selects one Thread ledger. Empty means the primary Thread, which
	// is the public Session event surface.
	ThreadID       string
	Boundary       *EventPageBoundary
	Limit          int
	Desc           bool
	Types          []string
	ProcessedAtGt  *time.Time
	ProcessedAtGte *time.Time
	ProcessedAtLt  *time.Time
	ProcessedAtLte *time.Time
}

EventQuery expresses the public List Events filters. Mango retains the created_at query name from its original surface but applies those filters, ordering, and pagination to the event processed_at value.

type FileBlobStore

type FileBlobStore = BlobStore

FileBlobStore preserves the original Files application boundary name for callers while the underlying store is shared with other blob-backed resources.

type FileDownload

type FileDownload struct {
	File domain.File
	Body io.ReadCloser
}

type FileListPage

type FileListPage struct {
	Files   []domain.File
	HasMore bool
}

type FileListQuery

type FileListQuery struct {
	AfterID  string
	BeforeID string
	Limit    int
}

type FileRepository

type FileRepository interface {
	BlobCleanupRepository
	BeginUpload(context.Context, domain.File) error
	CompleteUpload(context.Context, string, BlobInfo) (domain.File, error)
	RenewUpload(context.Context, string) error
	ReleaseUpload(context.Context, string, string, bool) error
	Get(context.Context, string) (domain.File, error)
	List(context.Context, FileListQuery) (FileListPage, error)
	BeginDelete(context.Context, string) (domain.File, error)
	RemoveIncomplete(context.Context, string) error
	ListIncomplete(context.Context) ([]domain.File, error)
	ClaimIncomplete(context.Context, string) (domain.File, bool, error)
}

FileRepository owns workspace-scoped metadata and lifecycle intents. BeginUpload must commit before blob I/O; CompleteUpload is the only transition that makes a file visible. Get returns only ready Files, and BeginDelete hides a file before object deletion begins.

type FileService

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

func NewFileService

func NewFileService(
	repo FileRepository,
	blobs FileBlobStore,
	ids domain.IDGenerator,
	clock domain.Clock,
) *FileService

func (*FileService) Delete

func (s *FileService) Delete(ctx context.Context, id string) (domain.File, error)

func (*FileService) Download

func (s *FileService) Download(ctx context.Context, id string) (FileDownload, error)

func (*FileService) Get

func (s *FileService) Get(ctx context.Context, id string) (domain.File, error)

func (*FileService) List

func (s *FileService) List(ctx context.Context, query FileListQuery) (FileListPage, error)

func (*FileService) ReadMessageFile

func (s *FileService) ReadMessageFile(
	ctx context.Context,
	id string,
) (domain.FileMessageContent, error)

ReadMessageFile returns a bounded, integrity-checked snapshot for a user.message document source. Generic application/octet-stream is accepted so generic uploads and source files without a registered media type can still be projected after their bytes pass UTF-8 validation.

func (*FileService) ReadOutcomeRubric

func (s *FileService) ReadOutcomeRubric(ctx context.Context, id string) (string, error)

ReadOutcomeRubric validates an immutable File for use as model input. Admission reads stay bounded to the largest valid UTF-8 encoding of the documented character limit, independently of the binary download endpoint.

func (*FileService) Reconcile

func (s *FileService) Reconcile(ctx context.Context) error

Reconcile atomically claims ended/expired uploads and unfinished deletes. Listing alone is not authority to delete: another process may still own the upload or may have completed it since the list was read.

func (*FileService) StoreToolOutput

func (s *FileService) StoreToolOutput(ctx context.Context, sessionID, fileID, text string) error

StoreToolOutput publishes a journaled MCP receipt as a regular File. The ID is allocated before receipt persistence; only storage is retried. Session association pins bytes until Session deletion and constrains Work-token reads.

func (*FileService) Upload

func (s *FileService) Upload(ctx context.Context, input FileUploadInput) (domain.File, error)

type FileUploadInput

type FileUploadInput struct {
	Filename string
	MimeType string
	Body     io.Reader
}

type Frame

type Frame struct {
	Event   *domain.Event
	Preview *domain.PreviewFrame
}

Frame is the unit delivered to a stream subscriber. Exactly one of Event or Preview is non-nil. Event carries a persisted event (delivered to every subscriber); Preview carries a stream-only preview frame (delivered only to subscribers that opted in for its event type). Preview frames are never persisted and never appear in event history.

The Event/Preview pointees MUST be treated as read-only by consumers: a single Publish/PublishPreview sends the same Frame (and thus the same inner pointer) to every matching subscriber, so mutating through the pointer would race and corrupt other subscribers' view. Copy before mutating if ever needed.

type Hub

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

func NewHub

func NewHub(bufferSize int) *Hub

func (*Hub) CloseSession

func (h *Hub) CloseSession(sessionID string, terminal domain.Event)

CloseSession publishes a final event and closes every subscriber atomically.

func (*Hub) Publish

func (h *Hub) Publish(sessionID string, e domain.Event)

func (*Hub) PublishPreview

func (h *Hub) PublishPreview(sessionID string, pf domain.PreviewFrame)

PublishPreview delivers a stream-only preview frame to subscribers that opted in for its event type. Preview frames are never persisted. Subscribers that did not opt in for f.EventType are skipped entirely (they see no frame). The slow-consumer drop policy still applies to opted-in subscribers.

func (*Hub) Subscribe

func (h *Hub) Subscribe(sessionID string, deltaOptIn map[string]bool) (<-chan Frame, func())

Subscribe registers a subscriber for a session. deltaOptIn selects which event types this subscriber wants preview frames for; a nil/empty map means preview frames are never delivered to it. Persisted events are always delivered regardless of deltaOptIn.

func (*Hub) SubscribeContext

func (h *Hub) SubscribeContext(
	_ context.Context,
	sessionID string,
	deltaOptIn map[string]bool,
) (<-chan Frame, func(), error)

SubscribeContext adapts the process-local Hub to the HTTP stream boundary. Subscription has no fallible setup; request cancellation remains owned by the handler and cleanup uses the returned cancel function.

type ListPage

type ListPage struct {
	AgentID         string
	AgentVersion    *int
	CreatedAtGt     *time.Time
	CreatedAtGte    *time.Time
	CreatedAtLt     *time.Time
	CreatedAtLte    *time.Time
	IncludeArchived bool
	Statuses        []domain.Status
	DeploymentID    *string
	MemoryStoreID   *string
	Boundary        *SessionPageBoundary
	Limit           int
	Desc            bool
}

ListPage describes a keyset-paginated session query.

type MemoryCreateInput

type MemoryCreateInput struct {
	Path    string
	Content string
	Actor   domain.MemoryActor
}

type MemoryListPage

type MemoryListPage struct {
	Items   []domain.MemoryListItem
	HasNext bool
}

type MemoryListQuery

type MemoryListQuery struct {
	PathPrefix string
	Depth      int
	AfterPath  string
	Limit      int
	Full       bool
}

type MemoryService

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

func NewMemoryService

func NewMemoryService(repo MemoryRepository, ids domain.IDGenerator, clock domain.Clock) *MemoryService

func (*MemoryService) ArchiveStore

func (s *MemoryService) ArchiveStore(ctx context.Context, id string) (domain.MemoryStore, error)

func (*MemoryService) CreateMemory

func (s *MemoryService) CreateMemory(ctx context.Context, storeID string, input MemoryCreateInput) (domain.Memory, error)

func (*MemoryService) CreateStore

func (*MemoryService) DeleteMemory

func (s *MemoryService) DeleteMemory(ctx context.Context, storeID, memoryID string, expected *string, actor domain.MemoryActor) (domain.Memory, error)

func (*MemoryService) DeleteStore

func (s *MemoryService) DeleteStore(ctx context.Context, id string) error

func (*MemoryService) GetMemory

func (s *MemoryService) GetMemory(ctx context.Context, storeID, memoryID string) (domain.Memory, error)

func (*MemoryService) GetMemoryVersion

func (s *MemoryService) GetMemoryVersion(ctx context.Context, storeID, versionID string) (domain.MemoryVersion, error)

func (*MemoryService) GetStore

func (s *MemoryService) GetStore(ctx context.Context, id string) (domain.MemoryStore, error)

func (*MemoryService) ListMemories

func (s *MemoryService) ListMemories(ctx context.Context, storeID string, query MemoryListQuery) (MemoryListPage, error)

func (*MemoryService) ListMemoryVersions

func (s *MemoryService) ListMemoryVersions(ctx context.Context, storeID string, query MemoryVersionListQuery) (MemoryVersionListPage, error)

func (*MemoryService) ListStores

func (*MemoryService) RedactMemoryVersion

func (s *MemoryService) RedactMemoryVersion(ctx context.Context, storeID, versionID string, actor domain.MemoryActor) (domain.MemoryVersion, error)

func (*MemoryService) RuntimeHeads

func (s *MemoryService) RuntimeHeads(ctx context.Context, storeID string) ([]domain.Memory, error)

RuntimeHeads returns the complete canonical snapshot used to populate a Session mount. It intentionally bypasses public pagination while preserving the Store existence check in the repository.

func (*MemoryService) SyncRuntimeSnapshot

func (s *MemoryService) SyncRuntimeSnapshot(
	ctx context.Context,
	storeID string,
	baseline []MemoryStoreSyncBaseline,
	current []MemoryStoreSyncContent,
	actor domain.MemoryActor,
) ([]domain.Memory, error)

SyncRuntimeSnapshot atomically persists all file changes made by one sandbox tool against the baseline that was last published to that sandbox.

func (*MemoryService) UpdateMemory

func (s *MemoryService) UpdateMemory(ctx context.Context, storeID, memoryID string, input MemoryUpdateInput) (domain.Memory, error)

func (*MemoryService) UpdateStore

type MemorySessionResourceInput

type MemorySessionResourceInput struct {
	MemoryStoreID string
	Access        string
	Instructions  string
}

type MemoryStoreCreateInput

type MemoryStoreCreateInput struct {
	Name        string
	Description string
	Metadata    map[string]string
}

type MemoryStoreListPage

type MemoryStoreListPage struct {
	Stores  []domain.MemoryStore
	HasNext bool
}

type MemoryStoreListQuery

type MemoryStoreListQuery struct {
	CreatedAtGte    *time.Time
	CreatedAtLte    *time.Time
	IncludeArchived bool
	After           *ResourcePageBoundary
	Limit           int
}

type MemoryStoreSyncBaseline

type MemoryStoreSyncBaseline struct {
	MemoryID      string
	Path          string
	ContentSHA256 string
}

type MemoryStoreSyncContent

type MemoryStoreSyncContent struct {
	Path    string
	Content string
}

type MemoryStoreUpdateInput

type MemoryStoreUpdateInput struct {
	Name        *string
	Description *string
	Metadata    map[string]*string
}

type MemoryUpdateInput

type MemoryUpdateInput struct {
	Path               *string
	Content            *string
	ExpectedContentSHA *string
	Actor              domain.MemoryActor
}

type MemoryVersionListPage

type MemoryVersionListPage struct {
	Versions []domain.MemoryVersion
	HasNext  bool
}

type MemoryVersionListQuery

type MemoryVersionListQuery struct {
	APIKeyID     string
	SessionID    string
	MemoryID     string
	Operation    string
	CreatedAtGte *time.Time
	CreatedAtLte *time.Time
	After        *ResourcePageBoundary
	Limit        int
}

type NullablePatch

type NullablePatch[T any] struct {
	Present bool
	Value   *T
}

NullablePatch preserves the three states used by nullable update fields: omitted (Present=false), explicit JSON null (Present=true, Value=nil), and a concrete value. A pointer alone cannot distinguish omission from null.

func PatchNull

func PatchNull[T any]() NullablePatch[T]

func PatchValue

func PatchValue[T any](value T) NullablePatch[T]

type OAuthRefreshCreateInput

type OAuthRefreshCreateInput struct {
	ClientID          string
	RefreshToken      string
	TokenEndpoint     string
	TokenEndpointAuth string
	ClientSecret      *string
	Resource          *string
	Scope             *string
}

type OAuthRefreshUpdateInput

type OAuthRefreshUpdateInput struct {
	RefreshToken      NullablePatch[string]
	Scope             NullablePatch[string]
	TokenEndpointAuth *OAuthTokenEndpointAuthUpdateInput
}

type OAuthTokenEndpointAuthUpdateInput

type OAuthTokenEndpointAuthUpdateInput struct {
	Type         string
	ClientSecret NullablePatch[string]
}

type PreparedSessionResource

type PreparedSessionResource struct {
	Resource domain.SessionResource
}

type ResourcePageBoundary

type ResourcePageBoundary struct {
	CreatedAt time.Time
	ID        string
}

ResourcePageBoundary is the last (created_at, id) pair returned by a forward-only resource page.

type ScheduledDeploymentRunner

type ScheduledDeploymentRunner interface {
	ClaimDue(context.Context, int) ([]DeploymentScheduleClaim, error)
	RenewClaim(context.Context, DeploymentScheduleClaim) error
	RunScheduled(context.Context, string, time.Time) (domain.DeploymentRun, error)
}

type SessionListPage

type SessionListPage struct {
	Sessions []domain.Session
	HasPrev  bool
	HasNext  bool
}

type SessionPageBoundary

type SessionPageBoundary struct {
	CreatedAt time.Time
	ID        string
	Backward  bool
}

type SessionSkillMaterializer

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

SessionSkillMaterializer validates and reads immutable custom Skill archives for model-context injection. The external worker independently prepares the same pinned bundles in its own workspace.

func NewSessionSkillMaterializer

func NewSessionSkillMaterializer(
	skills SessionSkillMountRepository,
	blobs BlobStore,
) *SessionSkillMaterializer

func (*SessionSkillMaterializer) LoadSkillInstructions

func (m *SessionSkillMaterializer) LoadSkillInstructions(
	ctx context.Context,
	version domain.SkillVersion,
) ([]byte, error)

LoadSkillInstructions reads the immutable SKILL.md directly from Mango's canonical bundle. The orchestration layer owns the Agent loop, so activating a Skill must not require reverse access to the worker's filesystem. The worker independently materializes the same pinned bundle for later read/bash access to supporting files.

func (*SessionSkillMaterializer) SupportsSkillRuntime

func (m *SessionSkillMaterializer) SupportsSkillRuntime() bool

SupportsSkillRuntime reports whether immutable Skill instructions can load.

type SessionSkillMountRepository

type SessionSkillMountRepository interface {
	SessionSkillsForRuntime(context.Context, string) ([]domain.SkillVersion, error)
}

SessionSkillMountRepository exposes the immutable Version metadata retained by a Session's relational pins.

type SessionThreadListQuery

type SessionThreadListQuery struct {
	Limit    int
	Boundary *SessionThreadPageBoundary
	Statuses []domain.Status
}

type SessionThreadPageBoundary

type SessionThreadPageBoundary struct {
	CreatedAt time.Time
	ID        string
}

type SessionThreadSkillMountRepository

type SessionThreadSkillMountRepository interface {
	SessionThreadSkillRuntime(
		context.Context,
		string,
		string,
	) (domain.SkillRuntime, error)
}

type SkillCreateInput

type SkillCreateInput struct {
	DisplayTitle *string
	Files        []SkillUploadFile
}

type SkillListPage

type SkillListPage struct {
	Skills  []domain.Skill
	HasNext bool
}

type SkillListQuery

type SkillListQuery struct {
	Source string
	After  *ResourcePageBoundary
	Limit  int
}

type SkillReferenceResolver

type SkillReferenceResolver interface {
	ResolveSkillReferences(
		context.Context,
		[]domain.SkillReference,
	) ([]domain.SkillReference, error)
}

SkillReferenceResolver resolves request-time aliases to immutable custom Skill Versions. The Agent and Session services share this boundary so every persisted public snapshot contains concrete Version identifiers.

type SkillRepository

SkillRepository owns metadata and durable object-store lifecycle intents. Begin operations commit before blob I/O; CompleteVersion is the visibility boundary for an immutable archive.

type SkillService

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

func NewSkillService

func NewSkillService(
	repo SkillRepository,
	blobs BlobStore,
	ids domain.IDGenerator,
	clock domain.Clock,
) *SkillService

func (*SkillService) Create

func (s *SkillService) Create(ctx context.Context, input SkillCreateInput) (domain.Skill, error)

func (*SkillService) CreateVersion

func (s *SkillService) CreateVersion(
	ctx context.Context,
	skillID string,
	files []SkillUploadFile,
) (domain.SkillVersion, error)

func (*SkillService) Delete

func (s *SkillService) Delete(ctx context.Context, id string) (domain.Skill, error)

func (*SkillService) DeleteVersion

func (s *SkillService) DeleteVersion(
	ctx context.Context,
	skillID string,
	version string,
) (domain.SkillVersion, error)

func (*SkillService) Download

func (s *SkillService) Download(
	ctx context.Context,
	skillID string,
	version string,
) (SkillVersionDownload, error)

func (*SkillService) Get

func (s *SkillService) Get(ctx context.Context, id string) (domain.Skill, error)

func (*SkillService) GetVersion

func (s *SkillService) GetVersion(
	ctx context.Context,
	skillID string,
	version string,
) (domain.SkillVersion, error)

func (*SkillService) List

func (*SkillService) ListVersions

func (s *SkillService) ListVersions(
	ctx context.Context,
	skillID string,
	query SkillVersionListQuery,
) (SkillVersionListPage, error)

func (*SkillService) Reconcile

func (s *SkillService) Reconcile(ctx context.Context) error

func (*SkillService) ResolveSkillReferences

func (s *SkillService) ResolveSkillReferences(
	ctx context.Context,
	references []domain.SkillReference,
) ([]domain.SkillReference, error)

ResolveSkillReferences replaces omitted or "latest" aliases with concrete ready custom Skill Versions. Agent and Session persistence therefore never depends on a mutable latest-version pointer.

type SkillUploadFile

type SkillUploadFile struct {
	Filename string
	Body     []byte
}

type SkillVersionDownload

type SkillVersionDownload struct {
	Version domain.SkillVersion
	Body    io.ReadCloser
}

type SkillVersionListPage

type SkillVersionListPage struct {
	Versions []domain.SkillVersion
	HasNext  bool
}

type SkillVersionListQuery

type SkillVersionListQuery struct {
	After *ResourcePageBoundary
	Limit int
}

type VaultCreateInput

type VaultCreateInput struct {
	DisplayName string
	Metadata    map[string]string
}

type VaultListPage

type VaultListPage struct {
	Vaults  []domain.Vault
	HasNext bool
}

type VaultListQuery

type VaultListQuery struct {
	IncludeArchived bool
	After           *ResourcePageBoundary
	Limit           int
}

type VaultRuntimeRepository

type VaultRuntimeRepository interface {
	ResolveSessionCredentials(context.Context, string) ([]domain.VaultCredential, error)
}

type VaultService

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

func NewVaultService

func NewVaultService(config VaultServiceConfig) *VaultService

func (*VaultService) ArchiveCredential

func (s *VaultService) ArchiveCredential(ctx context.Context, vaultID, credentialID string) (domain.VaultCredential, error)

func (*VaultService) ArchiveVault

func (s *VaultService) ArchiveVault(ctx context.Context, id string) (domain.Vault, error)

func (*VaultService) CreateCredential

func (s *VaultService) CreateCredential(ctx context.Context, vaultID string, input CredentialCreateInput) (domain.VaultCredential, error)

func (*VaultService) CreateVault

func (s *VaultService) CreateVault(ctx context.Context, input VaultCreateInput) (domain.Vault, error)

func (*VaultService) DeleteCredential

func (s *VaultService) DeleteCredential(ctx context.Context, vaultID, credentialID string) error

func (*VaultService) DeleteVault

func (s *VaultService) DeleteVault(ctx context.Context, id string) error

func (*VaultService) GetCredential

func (s *VaultService) GetCredential(ctx context.Context, vaultID, credentialID string) (domain.VaultCredential, error)

func (*VaultService) GetVault

func (s *VaultService) GetVault(ctx context.Context, id string) (domain.Vault, error)

func (*VaultService) ListCredentials

func (s *VaultService) ListCredentials(ctx context.Context, vaultID string, query CredentialListQuery) (CredentialListPage, error)

func (*VaultService) ListVaults

func (s *VaultService) ListVaults(ctx context.Context, query VaultListQuery) (VaultListPage, error)

func (*VaultService) ResolveMCPBearer

func (s *VaultService) ResolveMCPBearer(
	ctx context.Context,
	sessionID string,
	mcpServerURL string,
) (credentialruntime.BearerCredential, bool, error)

ResolveMCPBearer returns the first matching credential according to the Session's immutable Vault order. Credential plaintext exists only for this call and is never returned through the control-plane API.

func (*VaultService) UpdateCredential

func (s *VaultService) UpdateCredential(ctx context.Context, vaultID, credentialID string, input CredentialUpdateInput) (domain.VaultCredential, error)

func (*VaultService) UpdateVault

func (s *VaultService) UpdateVault(ctx context.Context, id string, input VaultUpdateInput) (domain.Vault, error)

func (*VaultService) ValidateMCPOAuthCredential

func (s *VaultService) ValidateMCPOAuthCredential(
	ctx context.Context,
	vaultID string,
	credentialID string,
) (CredentialValidation, error)

ValidateMCPOAuthCredential live-probes an OAuth credential and, when the current access token is expired or rejected, attempts the configured refresh exchange before probing once more. Successful refreshes are persisted so the next Session resolution observes the rotated token.

type VaultServiceConfig

type VaultServiceConfig struct {
	Repository     VaultRepository
	Cipher         secretcrypto.Cipher
	IDGenerator    domain.IDGenerator
	Clock          domain.Clock
	OAuthRefresher credentialruntime.OAuthRefresher
	MCPValidator   credentialruntime.MCPValidator
}

type VaultUpdateInput

type VaultUpdateInput struct {
	DisplayName NullablePatch[string]
	Metadata    NullablePatch[map[string]*string]
}

type WebhookCreateInput

type WebhookCreateInput struct {
	URL        string
	EventTypes []string
}

type WebhookDeliveryRepository

type WebhookDeliveryRepository interface {
	ClaimWebhookDeliveries(
		context.Context, time.Time, time.Time, string, int,
	) ([]domain.WebhookDelivery, error)
	CompleteWebhookDelivery(context.Context, WebhookDeliveryResult) (bool, error)
	CleanupWebhookEvents(context.Context, time.Time, int) (int64, error)
}

type WebhookDeliveryResult

type WebhookDeliveryResult struct {
	WebhookID      string
	EventID        string
	ClaimID        string
	AttemptedAt    time.Time
	CompletedAt    time.Time
	Succeeded      bool
	ResponseStatus *int
	Error          string
	NextAttemptAt  *time.Time
	DisableReason  *string
}

type WebhookDispatcher

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

func (*WebhookDispatcher) Run

func (d *WebhookDispatcher) Run(ctx context.Context) error

func (*WebhookDispatcher) RunOnce

func (d *WebhookDispatcher) RunOnce(ctx context.Context) error

type WebhookHTTPDoer

type WebhookHTTPDoer interface {
	Do(*http.Request) (*http.Response, error)
}

type WebhookListPage

type WebhookListPage struct {
	Webhooks []domain.Webhook
	HasNext  bool
}

type WebhookListQuery

type WebhookListQuery struct {
	After *ResourcePageBoundary
	Limit int
}

type WebhookRepository

type WebhookRepository interface {
	CreateWebhook(context.Context, domain.Webhook, int) (domain.Webhook, error)
	GetWebhook(context.Context, string) (domain.Webhook, error)
	UpdateWebhook(context.Context, string, func(domain.Webhook) (domain.Webhook, bool, error)) (domain.Webhook, error)
	ListWebhooks(context.Context, WebhookListQuery) (WebhookListPage, error)
	DeleteWebhook(context.Context, string) error
}

type WebhookSecretResult

type WebhookSecretResult struct {
	Webhook       domain.Webhook
	SigningSecret string
}

type WebhookService

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

func NewWebhookService

func NewWebhookService(
	repo WebhookRepository,
	cipher secretcrypto.Cipher,
	ids domain.IDGenerator,
	clock domain.Clock,
) *WebhookService

func (*WebhookService) CreateWebhook

func (s *WebhookService) CreateWebhook(
	ctx context.Context,
	input WebhookCreateInput,
) (WebhookSecretResult, error)

func (*WebhookService) DeleteWebhook

func (s *WebhookService) DeleteWebhook(ctx context.Context, id string) error

func (*WebhookService) GetWebhook

func (s *WebhookService) GetWebhook(ctx context.Context, id string) (domain.Webhook, error)

func (*WebhookService) ListWebhooks

func (s *WebhookService) ListWebhooks(
	ctx context.Context,
	query WebhookListQuery,
) (WebhookListPage, error)

func (*WebhookService) RegenerateSigningSecret

func (s *WebhookService) RegenerateSigningSecret(
	ctx context.Context,
	id string,
) (WebhookSecretResult, error)

func (*WebhookService) UpdateWebhook

func (s *WebhookService) UpdateWebhook(
	ctx context.Context,
	id string,
	input WebhookUpdateInput,
) (domain.Webhook, error)

type WebhookUpdateInput

type WebhookUpdateInput struct {
	URL        *string
	EventTypes *[]string
	Status     *domain.WebhookStatus
}

Jump to

Keyboard shortcuts

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