Documentation
¶
Overview ¶
Package services contains the opt-in experimental presentation service contracts.
Ports packages/coding-agent/src/experimental/services/agent-controller.ts.
Package services defines opt-in experimental service contracts and local providers.
Ports packages/coding-agent/src/experimental/services/plugins.ts.
Ports packages/coding-agent/src/experimental/services/presentation-ui.ts.
Ports packages/coding-agent/src/experimental/services/slash-commands.ts.
Ports packages/coding-agent/src/experimental/services/slash-commands-provider.ts.
Ports packages/coding-agent/src/experimental/services/slash-commands-provider.ts.
Ports packages/coding-agent/src/experimental/services/worker.ts.
Index ¶
- Constants
- Variables
- func CreateBuiltInSlashCommandsFacet(options BuiltInSlashCommandsOptions) chord.Facet
- func CreateModelsServiceFacet(options ModelsServiceFacetOptions) chord.Facet
- func CreateSlashCommandsRuntimeFacet(registry *SlashCommandRegistry) chord.Facet
- func CreateTranscriptServiceFacet(lane TranscriptWatchLane) chord.Facet
- type AgentCancelQueuedResponse
- type AgentCompactionRequest
- type AgentController
- type AgentControllerInitiator
- type AgentControllerProvider
- func (controller *AgentControllerProvider) CancelQueued(ctx context.Context, entryID string) (AgentCancelQueuedResponse, error)
- func (controller *AgentControllerProvider) Compact(ctx context.Context, request AgentCompactionRequest) (AgentOperationResponse, error)
- func (controller *AgentControllerProvider) FollowUp(ctx context.Context, request AgentPromptRequest) (AgentQueueResponse, error)
- func (controller *AgentControllerProvider) Navigate(ctx context.Context, request AgentNavigationRequest) (AgentOperationResponse, error)
- func (controller *AgentControllerProvider) NextRun(ctx context.Context, request AgentPromptRequest) (AgentQueueResponse, error)
- func (controller *AgentControllerProvider) Prompt(ctx context.Context, request AgentPromptRequest) (AgentOperationResponse, error)
- func (controller *AgentControllerProvider) RequestAbort(ctx context.Context, operationID string) error
- func (controller *AgentControllerProvider) Resume(ctx context.Context) (AgentOperationResponse, error)
- func (controller *AgentControllerProvider) Steer(ctx context.Context, request AgentPromptRequest) (AgentQueueResponse, error)
- type AgentLane
- type AgentNavigationRequest
- type AgentOperationError
- type AgentOperationResponse
- type AgentPromptImage
- type AgentPromptRequest
- type AgentQueueResponse
- type AggregateError
- type BuiltInSlashCommandsOptions
- type ExperimentalServerServices
- type ExperimentalServerServicesOptions
- type LaneCompactionOptions
- type LaneNavigateOptions
- type LaneOperation
- type ModelRef
- type ModelSummary
- type Models
- type ModelsCatalog
- type ModelsConfiguration
- type ModelsRefresh
- type ModelsRefreshResult
- type ModelsServiceFacetOptions
- type ModelsServiceLane
- type ModelsServiceModelRuntime
- type ModelsServiceRuntime
- type ModelsServiceSettingsManager
- type ModelsState
- type PrepareSessionPluginsRequest
- type PreparedSessionPlugins
- type PresentationPlugins
- type PresentationSelectItem
- type PresentationUI
- type RemoteServiceBinding
- type RemoteServiceBindingOptions
- type ReplicatedStateDelivery
- type RoutedServerPresentation
- type RoutedServerServiceAttachment
- type RoutedServerServiceHost
- type RoutedServiceBinding
- func (binding *RoutedServiceBinding) BeginReady(ctx context.Context) func() error
- func (binding *RoutedServiceBinding) Dispose(ctx context.Context) error
- func (binding *RoutedServiceBinding) Observe(service Service, handler func(context.Context, any) error) (func(), error)
- func (binding *RoutedServiceBinding) Ready(ctx context.Context) error
- func (binding *RoutedServiceBinding) Use(service Service) (any, error)
- type ServerConnectionState
- type ServerServiceSource
- func (*ServerServiceSource) AcceptsUnavailableServices() bool
- func (source *ServerServiceSource) Catalogue(ctx context.Context) ([]ServiceCatalogueEntry, error)
- func (source *ServerServiceSource) Dispose(ctx context.Context) error
- func (source *ServerServiceSource) Open(options ServiceBindingOptions) (*RoutedServiceBinding, error)
- type Service
- type ServiceBindingOptions
- type ServiceCatalogueEntry
- type ServiceClient
- type ServiceSourceOptions
- type ServiceTarget
- type SessionAddress
- type SessionAttachmentState
- type SessionCreateOptions
- type SessionDirectory
- type SessionDirectoryState
- type SessionManagement
- type SessionPlugins
- type SessionServiceSource
- func (source *SessionServiceSource) AcceptsUnavailableServices() bool
- func (source *SessionServiceSource) Catalogue(ctx context.Context) ([]ServiceCatalogueEntry, error)
- func (source *SessionServiceSource) Dispose(ctx context.Context) error
- func (source *SessionServiceSource) Open(options ServiceBindingOptions) (*RoutedServiceBinding, error)
- func (source *SessionServiceSource) WhenAttached(sessionID string, ctx context.Context) error
- func (source *SessionServiceSource) WhenDetached(ctx context.Context) error
- type SessionSummary
- type SessionTarget
- type SessionWorkerServiceLane
- type SessionWorkerServices
- type SessionWorkerServicesOptions
- type SlashCommandCompletion
- type SlashCommandContribution
- type SlashCommandOrigin
- type SlashCommandRegistrationIdentity
- type SlashCommandRegistry
- func (registry *SlashCommandRegistry) List() []SlashCommandContribution
- func (registry *SlashCommandRegistry) Register(command SlashCommandContribution) (func(), error)
- func (registry *SlashCommandRegistry) Replace(command SlashCommandContribution) (func(), error)
- func (registry *SlashCommandRegistry) Subscribe(callback func([]SlashCommandContribution)) func()
- type SlashCommandRunResult
- type SlashCommands
- type SourceState
- type Transcript
- type TranscriptRuntime
- type TranscriptState
- type TranscriptWatchLane
- type WorkerServiceScope
Constants ¶
const AgentControllerID = "pi.agent-controller"
AgentControllerID identifies the remote service. Go's shared type/value namespace requires a separate name for the service token.
Variables ¶
var AgentControllerDefinition = pico3.DefineService[AgentController](AgentControllerID)
AgentControllerDefinition names the remote service token; Go shares type and value names.
var ModelsDefinition = pico3.DefineService[Models]("pi.models")
ModelsDefinition is the pi.models token; Go types and values share a namespace.
var PresentationPluginsDefinition = pico3.DefineService[PresentationPlugins]("pi.presentation-plugins")
PresentationPluginsDefinition is the pi.presentation-plugins token; Go types and values share a namespace.
var PresentationUIDefinition = pico3.DefineServiceWithOptions[PresentationUI]("pi.local.presentation-ui", pico3.ServiceOptions{Local: true})
PresentationUIDefinition names the local service; Go shares type and value names.
var SessionDirectoryDefinition = pico3.DefineService[SessionDirectory]("pi.session-directory")
SessionDirectoryDefinition is the pi.session-directory token.
var SessionManagementDefinition = pico3.DefineService[SessionManagement]("pi.session-management")
SessionManagementDefinition is the pi.session-management token.
var SessionPluginsDefinition = pico3.DefineService[SessionPlugins]("pi.session-plugins")
SessionPluginsDefinition is the pi.session-plugins token.
var SlashCommandsDefinition = pico3.DefineServiceWithOptions[SlashCommands]("pi.local.slash-commands", pico3.ServiceOptions{Local: true})
SlashCommandsDefinition names the local service token; Go shares type and value names.
var TranscriptDefinition = pico3.DefineService[Transcript]("pi.transcript")
Functions ¶
func CreateBuiltInSlashCommandsFacet ¶
func CreateBuiltInSlashCommandsFacet(options BuiltInSlashCommandsOptions) chord.Facet
CreateBuiltInSlashCommandsFacet installs model, thinking, compact and reload contributions, in that order. Activation and disposal run on the command registry's owner executor; command bodies may block and must run off the TUI input loop.
func CreateModelsServiceFacet ¶
func CreateModelsServiceFacet(options ModelsServiceFacetOptions) chord.Facet
CreateModelsServiceFacet declares a Models provider on the Chord host and activates it with a background context after setup completes.
func CreateSlashCommandsRuntimeFacet ¶
func CreateSlashCommandsRuntimeFacet(registry *SlashCommandRegistry) chord.Facet
CreateSlashCommandsRuntimeFacet provides the local command registry without activating commands. A nil registry selects a new empty registry, as upstream's omitted argument does.
func CreateTranscriptServiceFacet ¶
func CreateTranscriptServiceFacet(lane TranscriptWatchLane) chord.Facet
Types ¶
type AgentCancelQueuedResponse ¶
type AgentCancelQueuedResponse struct {
Outcome string `json:"outcome"`
}
AgentCancelQueuedResponse reports "cancelled", "already_consumed", or "not_found".
type AgentCompactionRequest ¶
type AgentCompactionRequest struct {
CustomInstructions *string `json:"customInstructions"`
}
AgentCompactionRequest uses null to select the default instructions.
type AgentController ¶
type AgentController interface {
Prompt(context.Context, AgentPromptRequest) (AgentOperationResponse, error)
RequestAbort(context.Context, string) error
Steer(context.Context, AgentPromptRequest) (AgentQueueResponse, error)
FollowUp(context.Context, AgentPromptRequest) (AgentQueueResponse, error)
NextRun(context.Context, AgentPromptRequest) (AgentQueueResponse, error)
CancelQueued(context.Context, string) (AgentCancelQueuedResponse, error)
Resume(context.Context) (AgentOperationResponse, error)
Compact(context.Context, AgentCompactionRequest) (AgentOperationResponse, error)
}
AgentController is the presentation-safe command facade over the worker-owned main AgentLane. Calls wait for the lane result, propagate context cancellation, and return transport/rejection errors separately from admission responses.
type AgentControllerInitiator ¶
type AgentControllerInitiator interface {
BeginPrompt(context.Context, AgentPromptRequest) (*chord.ServiceResultInvocation[AgentOperationResponse], error)
BeginRequestAbort(context.Context, string) (*chord.ServiceInvocation, error)
BeginSteer(context.Context, AgentPromptRequest) (*chord.ServiceResultInvocation[AgentQueueResponse], error)
BeginFollowUp(context.Context, AgentPromptRequest) (*chord.ServiceResultInvocation[AgentQueueResponse], error)
BeginNextRun(context.Context, AgentPromptRequest) (*chord.ServiceResultInvocation[AgentQueueResponse], error)
BeginCancelQueued(context.Context, string) (*chord.ServiceResultInvocation[AgentCancelQueuedResponse], error)
BeginResume(context.Context) (*chord.ServiceResultInvocation[AgentOperationResponse], error)
BeginCompact(context.Context, AgentCompactionRequest) (*chord.ServiceResultInvocation[AgentOperationResponse], error)
}
AgentControllerInitiator separates the admitted Promise from its observer without changing the AgentController wire contract. Begin methods preserve the operation context; Wait uses a separate observer context. A selected local override must expose its own admission boundary.
type AgentControllerProvider ¶
type AgentControllerProvider struct {
// contains filtered or unexported fields
}
AgentControllerProvider adapts lane outcomes without exposing worker-owned result details.
func CreateAgentController ¶
func CreateAgentController(lane AgentLane) *AgentControllerProvider
CreateAgentController creates the presentation-safe facade for one lane.
func (*AgentControllerProvider) CancelQueued ¶
func (controller *AgentControllerProvider) CancelQueued(ctx context.Context, entryID string) (AgentCancelQueuedResponse, error)
func (*AgentControllerProvider) Compact ¶
func (controller *AgentControllerProvider) Compact(ctx context.Context, request AgentCompactionRequest) (AgentOperationResponse, error)
func (*AgentControllerProvider) FollowUp ¶
func (controller *AgentControllerProvider) FollowUp(ctx context.Context, request AgentPromptRequest) (AgentQueueResponse, error)
func (*AgentControllerProvider) Navigate ¶
func (controller *AgentControllerProvider) Navigate(ctx context.Context, request AgentNavigationRequest) (AgentOperationResponse, error)
func (*AgentControllerProvider) NextRun ¶
func (controller *AgentControllerProvider) NextRun(ctx context.Context, request AgentPromptRequest) (AgentQueueResponse, error)
func (*AgentControllerProvider) Prompt ¶
func (controller *AgentControllerProvider) Prompt(ctx context.Context, request AgentPromptRequest) (AgentOperationResponse, error)
func (*AgentControllerProvider) RequestAbort ¶
func (controller *AgentControllerProvider) RequestAbort(ctx context.Context, operationID string) error
func (*AgentControllerProvider) Resume ¶
func (controller *AgentControllerProvider) Resume(ctx context.Context) (AgentOperationResponse, error)
func (*AgentControllerProvider) Steer ¶
func (controller *AgentControllerProvider) Steer(ctx context.Context, request AgentPromptRequest) (AgentQueueResponse, error)
type AgentLane ¶
type AgentLane interface {
Prompt(context.Context, string, []ai.ImageContent) (LaneOperation, error)
RequestAbort(context.Context, string) error
Steer(context.Context, string, []ai.ImageContent) (string, error)
FollowUp(context.Context, string, []ai.ImageContent) (string, error)
NextRun(context.Context, string, []ai.ImageContent) (string, error)
CancelQueued(context.Context, string) (string, error)
Resume(context.Context) (LaneOperation, error)
Compact(context.Context, *LaneCompactionOptions) (LaneOperation, error)
}
AgentLane is the controller's consumer-owned lane boundary. Implementations unwrap Result failures as harness.TaggedError and return rejected Promises as ordinary errors. Queue methods return value.entryId; CancelQueued returns value.kind. RequestAbort discards the successful observation, not its completion.
type AgentNavigationRequest ¶
type AgentNavigationRequest struct {
}
AgentNavigationRequest selects a target and optional summary instructions. A null target selects the root.
type AgentOperationError ¶
AgentOperationError is the presentation-safe code and message of a failure.
type AgentOperationResponse ¶
type AgentOperationResponse struct {
Accepted bool `json:"accepted"`
OperationID *string `json:"operationId"`
Error *AgentOperationError `json:"error"`
}
AgentOperationResponse distinguishes admission from completion. Accepted operations have an operation ID and may carry a terminal error; rejected operations always carry an error and may identify an existing operation.
type AgentPromptImage ¶
type AgentPromptImage struct {
Type string `json:"type"`
Data string `json:"data"`
MimeType string `json:"mimeType"`
}
AgentPromptImage carries an image in a presentation prompt. Type is "image".
type AgentPromptRequest ¶
type AgentPromptRequest struct {
Message string `json:"message"`
Images []AgentPromptImage `json:"images"`
}
AgentPromptRequest preserves null images separately from an empty image list.
type AgentQueueResponse ¶
type AgentQueueResponse struct {
Accepted bool `json:"accepted"`
EntryID *string `json:"entryId"`
Error *AgentOperationError `json:"error"`
}
AgentQueueResponse has an entry ID and no error when accepted, or an error and no entry ID when rejected.
type AggregateError ¶
type AggregateError = chord.AggregateError
AggregateError retains every failure while exposing the upstream aggregate message.
type BuiltInSlashCommandsOptions ¶
type BuiltInSlashCommandsOptions struct {
ReloadPresentationPlugins func(context.Context, pico3.JsonValue) error
}
BuiltInSlashCommandsOptions supplies the presentation generation reload. It waits for replacement and retired-generation disposal before returning.
type ExperimentalServerServices ¶
type ExperimentalServerServices struct {
Host *RoutedServerServiceHost
}
ExperimentalServerServices owns a shared directory and one service endpoint per attached presentation. It has no listener or default CLI activation.
func CreateExperimentalServerServices ¶
func CreateExperimentalServerServices(options ExperimentalServerServicesOptions) (*ExperimentalServerServices, error)
CreateExperimentalServerServices reads the initial directory in the background context. Application operations remain opt-in through the returned host.
func (*ExperimentalServerServices) Dispose ¶
func (services *ExperimentalServerServices) Dispose() error
Dispose releases every current attachment before waiting for queued mutations. In-flight operations retain their application context and are not cancelled.
type ExperimentalServerServicesOptions ¶
type ExperimentalServerServicesOptions struct {
List func(context.Context) ([]SessionSummary, error)
Create func(context.Context, SessionCreateOptions) (SessionSummary, error)
Remove func(context.Context, string) error
PrepareSessionPlugins func(context.Context, string, []string) (PreparedSessionPlugins, error)
ReloadPresentationPlugins func(context.Context, []string) (pico3.JsonValue, error)
}
ExperimentalServerServicesOptions supplies application-owned Session storage and plugin selection. Nil package paths select defaults; an empty slice selects no packages.
type LaneCompactionOptions ¶
type LaneCompactionOptions struct {
CustomInstructions *string
}
LaneCompactionOptions preserves absent options separately from empty instructions.
type LaneNavigateOptions ¶
type LaneNavigateOptions struct {
}
LaneNavigateOptions carries the options consumed by navigateTree.
type LaneOperation ¶
type LaneOperation struct {
OperationID string
Status string
Error *AgentOperationError
}
LaneOperation is the portion of OperationResultRecord or SuspendedRun consumed by the presentation facade. A lane adapter projects compaction.compaction and navigation.navigation into the same observation.
type ModelSummary ¶
ModelSummary is the catalog metadata exposed to clients.
type Models ¶
type Models interface {
State() pico3.ReplicatedStateOf[*ModelsState]
CycleThinking(context.Context) error
GetThinkingLevels(context.Context) ([]ai.ThinkingLevel, error)
Refresh(context.Context) error
Select(context.Context, ModelRef) error
SelectThinking(context.Context, ai.ThinkingLevel) error
}
Models is the model-selection service. Each call waits for its publications and propagates errors to the caller.
type ModelsCatalog ¶
type ModelsCatalog struct {
Revision int `json:"revision"`
AvailableModels []ModelSummary `json:"availableModels"`
}
ModelsCatalog preserves runtime order and includes an otherwise unavailable selected model.
type ModelsConfiguration ¶
type ModelsConfiguration struct {
Model *ModelRef `json:"model"`
ThinkingLevel ai.ThinkingLevel `json:"thinkingLevel"`
}
ModelsConfiguration uses a nil Model for an unconfigured lane.
type ModelsRefresh ¶
type ModelsRefresh struct {
Status string `json:"status"`
Errors map[string]string `json:"errors,omitzero"`
}
ModelsRefresh reports idle, refreshing, done, or warning with provider errors.
type ModelsRefreshResult ¶
ModelsRefreshResult carries refresh diagnostics. An aborted result is not itself a rejected operation.
type ModelsServiceFacetOptions ¶
type ModelsServiceFacetOptions struct {
Lane ModelsServiceLane
ModelRuntime ModelsServiceModelRuntime
SettingsManager ModelsServiceSettingsManager
}
ModelsServiceFacetOptions selects the lane and optional runtime and settings collaborators.
type ModelsServiceLane ¶
type ModelsServiceLane interface {
GetModel(context.Context) (*ai.Model, error)
SetModel(context.Context, ModelRef) error
GetThinkingLevel(context.Context) (ai.ThinkingLevel, error)
SetThinkingLevel(context.Context, ai.ThinkingLevel) error
}
ModelsServiceLane is the configuration boundary consumed from an AgentLane.
type ModelsServiceModelRuntime ¶
type ModelsServiceModelRuntime interface {
GetAvailableSnapshot() []*ai.Model
GetModel(provider, modelId string) *ai.Model
Refresh(context.Context) (ModelsRefreshResult, error)
}
ModelsServiceModelRuntime supplies snapshots and lookup without contacting a provider during reads. Refresh policy belongs to the supplied runtime.
type ModelsServiceRuntime ¶
type ModelsServiceRuntime struct {
Service Models
// contains filtered or unexported fields
}
ModelsServiceRuntime binds one Models service to its activation operation.
func CreateModelsService ¶
func CreateModelsService(lane ModelsServiceLane, modelRuntime ModelsServiceModelRuntime, settingsManager ModelsServiceSettingsManager, createState func(*ModelsState) pico3.MutableReplicatedStateOf[*ModelsState]) *ModelsServiceRuntime
CreateModelsService creates an inactive service with an empty catalog and no selected model. State allocation and publication belong to the caller's Chord host.
type ModelsServiceSettingsManager ¶
type ModelsServiceSettingsManager interface {
SetDefaultModelAndProvider(provider, model string) error
Flush() error
}
ModelsServiceSettingsManager persists model selection before publication.
type ModelsState ¶
type ModelsState struct {
Catalog ModelsCatalog `json:"catalog"`
Configuration ModelsConfiguration `json:"configuration"`
Refresh ModelsRefresh `json:"refresh"`
}
ModelsState is the replicated model catalog, lane configuration, and refresh outcome.
type PrepareSessionPluginsRequest ¶
type PrepareSessionPluginsRequest struct {
SessionId string `json:"sessionId"`
PackagePaths []string `json:"packagePaths"`
}
PrepareSessionPluginsRequest selects packages for a Session. Nil PackagePaths selects defaults; an empty slice selects no packages.
type PreparedSessionPlugins ¶
PreparedSessionPlugins contains the resolved package selection and its presentation artifacts.
type PresentationPlugins ¶
type PresentationPlugins interface {
PrepareSession(context.Context, PrepareSessionPluginsRequest) (pico3.JsonValue, error)
Reload(context.Context) (pico3.JsonValue, error)
}
PresentationPlugins exposes server-built plugin generations to presentations. Calls wait for completion and propagate errors to the caller.
type PresentationSelectItem ¶
PresentationSelectItem is a local selector choice. Nil Description preserves omission.
type PresentationUI ¶
type PresentationUI interface {
Select(context.Context, string, []PresentationSelectItem, *string) (*string, error)
ShowStatus(context.Context, string) error
}
PresentationUI supplies process-local presentation capabilities. Select waits for selection or cancellation; nil means the selector was cancelled. ShowStatus completes after the owner loop applies the status.
type RemoteServiceBinding ¶
type RemoteServiceBinding interface {
Use(Service) (any, error)
Observe(Service, func(context.Context, any) error) (func(), error)
Ready(context.Context, func(error))
Rebind(context.Context, bool, func(error))
Dispose(context.Context) error
}
RemoteServiceBinding is supplied by the Chord host. Rebind synchronously starts invalidation and calls its completion exactly once after hydration/release. Ready synchronously registers a waiter for current hydration/release and calls its completion exactly once, inline if already settled. Both methods return promptly; invocation order preserves the synchronous prefix of the upstream Promise API. Cancelling Ready releases only its waiter, and completion follows waiter cleanup. Implementations honor caller cancellation and make Dispose idempotent. Use and Observe retain the host's typed service handles and access checks.
type RemoteServiceBindingOptions ¶
type RemoteServiceBindingOptions struct {
ServiceBindingOptions
GetTarget func() *ServiceTarget
Bound bool
}
RemoteServiceBindingOptions supplies the host with lazy routing and an initially unbound service set. GetTarget returns nil while detached.
type ReplicatedStateDelivery ¶
ReplicatedStateDelivery distinguishes initial hydration from ordered updates.
type RoutedServerPresentation ¶
type RoutedServerPresentation interface {
AttachSession(context.Context, string) error
DetachSession(context.Context) error
PrepareSessionRemoval(context.Context, string) error
}
RoutedServerPresentation supplies the presentation-scoped routing capabilities used by server management.
type RoutedServerServiceAttachment ¶
type RoutedServerServiceAttachment struct {
// contains filtered or unexported fields
}
RoutedServerServiceAttachment owns the provider and subscriptions for one presentation connection.
func (*RoutedServerServiceAttachment) InvokeService ¶
func (attachment *RoutedServerServiceAttachment) InvokeService(ctx context.Context, call chord.ServiceCall, publish chord.ServiceUpdatePublisher) (json.RawMessage, error)
InvokeService forwards a service call while the attachment is live. Release rejects new calls but does not abort admitted calls.
type RoutedServerServiceHost ¶
type RoutedServerServiceHost struct {
// contains filtered or unexported fields
}
RoutedServerServiceHost serializes all application mutations across its presentation attachments.
func (*RoutedServerServiceHost) AttachClient ¶
func (host *RoutedServerServiceHost) AttachClient(_ context.Context, presentation RoutedServerPresentation) (*RoutedServerServiceAttachment, error)
AttachClient creates the three server-scoped services with independent plugin selection and subscriptions. Only the directory state and mutation queue are shared.
type RoutedServiceBinding ¶
type RoutedServiceBinding struct {
// contains filtered or unexported fields
}
RoutedServiceBinding activates a source-owned host binding on first Ready.
func (*RoutedServiceBinding) BeginReady ¶
func (binding *RoutedServiceBinding) BeginReady(ctx context.Context) func() error
BeginReady starts first-activation fencing before returning its continuation. The caller runs that continuation exactly once and owns any goroutine used to await it.
func (*RoutedServiceBinding) Dispose ¶
func (binding *RoutedServiceBinding) Dispose(ctx context.Context) error
type ServerConnectionState ¶
type ServerConnectionState struct {
Status string
Attempt int
Since string
Reason string
RetryAt *string
}
ServerConnectionState is discriminated by Status: connecting has Attempt; connected has Since; disconnected has Since, Reason, and nullable RetryAt.
func (ServerConnectionState) MarshalJSON ¶
func (state ServerConnectionState) MarshalJSON() ([]byte, error)
type ServerServiceSource ¶
type ServerServiceSource struct {
Connection *SourceState[ServerConnectionState]
// contains filtered or unexported fields
}
ServerServiceSource owns server-scoped bindings and serializes reconnect transitions. It does not connect or close the client.
func CreateServerServiceSource ¶
func CreateServerServiceSource(client ServiceClient, options ServiceSourceOptions) *ServerServiceSource
func (*ServerServiceSource) AcceptsUnavailableServices ¶
func (*ServerServiceSource) AcceptsUnavailableServices() bool
func (*ServerServiceSource) Catalogue ¶
func (source *ServerServiceSource) Catalogue(ctx context.Context) ([]ServiceCatalogueEntry, error)
func (*ServerServiceSource) Dispose ¶
func (source *ServerServiceSource) Dispose(ctx context.Context) error
func (*ServerServiceSource) Open ¶
func (source *ServerServiceSource) Open(options ServiceBindingOptions) (*RoutedServiceBinding, error)
type ServiceBindingOptions ¶
type ServiceBindingOptions struct {
Services []Service
AssertAccess func() error
OnError func(error)
}
ServiceBindingOptions configures one source-owned remote binding.
type ServiceCatalogueEntry ¶
ServiceCatalogueEntry describes an available singleton or keyed service.
type ServiceClient ¶
type ServiceClient interface {
ServerID() string
ConnectionState() string
Attachment() *SessionTarget
ServiceCatalogue(context.Context, ServiceTarget, func([]ServiceCatalogueEntry, error))
OnConnectionStateChange(func(string, error)) func()
OnAttachmentChange(func(*SessionTarget)) func()
}
ServiceClient is the source's consumer-owned client boundary. Getters return snapshots. Event listeners run in event order and observe already-committed client state; removing a listener prevents new invocations. ServiceCatalogue starts a client-owned request and calls its completion exactly once. The client owns cancellation and shutdown draining, including requests that outlive a source.
type ServiceSourceOptions ¶
type ServiceSourceOptions struct {
OnError func(error)
NewBinding func(RemoteServiceBindingOptions) RemoteServiceBinding
}
ServiceSourceOptions supplies the external Chord binding implementation and asynchronous error sink. Sources own bindings, not the client or its transport. NewBinding must return an independent binding for every call.
type ServiceTarget ¶
type ServiceTarget struct {
ServerID string `json:"serverId"`
SessionID *string `json:"sessionId,omitempty"`
AttachmentID *string `json:"attachmentId,omitempty"`
}
ServiceTarget routes either to the server or to an exact Session attachment.
type SessionAddress ¶
type SessionAddress struct {
ServerId string `json:"serverId"`
SessionId string `json:"sessionId"`
}
SessionAddress identifies a Session on a server.
type SessionAttachmentState ¶
type SessionAttachmentState struct {
Status string `json:"status"`
SessionID string `json:"sessionId"`
}
SessionAttachmentState has a SessionID only while attaching, attached, or degraded.
func (SessionAttachmentState) MarshalJSON ¶
func (state SessionAttachmentState) MarshalJSON() ([]byte, error)
type SessionCreateOptions ¶
type SessionCreateOptions struct {
Id *string `json:"id,omitempty"`
}
SessionCreateOptions distinguishes an omitted id from an explicitly empty id.
type SessionDirectory ¶
type SessionDirectory interface {
State() pico3.ReplicatedStateOf[*SessionDirectoryState]
}
SessionDirectory exposes replicated Session discovery without mutation operations.
type SessionDirectoryState ¶
type SessionDirectoryState struct {
Revision int `json:"revision"`
Sessions []SessionSummary `json:"sessions"`
}
SessionDirectoryState is the ordered, revisioned set of Sessions advertised by a server.
type SessionManagement ¶
type SessionManagement interface {
Create(context.Context, SessionCreateOptions) (SessionSummary, error)
Remove(context.Context, string) error
Attach(context.Context, string) error
Detach(context.Context) error
}
SessionManagement creates, removes, and selects Sessions. Calls wait for completion and return operation errors.
type SessionPlugins ¶
SessionPlugins reloads plugin facets in the currently attached Session worker. Reload waits for completion and propagates errors to the caller.
type SessionServiceSource ¶
type SessionServiceSource struct {
Attachment *SourceState[SessionAttachmentState]
// contains filtered or unexported fields
}
SessionServiceSource owns bindings for the selected attachment. Readiness is fenced by both the local revision and the server/Session/attachment identity.
func CreateSessionServiceSource ¶
func CreateSessionServiceSource(client ServiceClient, options ServiceSourceOptions) *SessionServiceSource
func (*SessionServiceSource) AcceptsUnavailableServices ¶
func (source *SessionServiceSource) AcceptsUnavailableServices() bool
func (*SessionServiceSource) Catalogue ¶
func (source *SessionServiceSource) Catalogue(ctx context.Context) ([]ServiceCatalogueEntry, error)
func (*SessionServiceSource) Dispose ¶
func (source *SessionServiceSource) Dispose(ctx context.Context) error
func (*SessionServiceSource) Open ¶
func (source *SessionServiceSource) Open(options ServiceBindingOptions) (*RoutedServiceBinding, error)
func (*SessionServiceSource) WhenAttached ¶
func (source *SessionServiceSource) WhenAttached(sessionID string, ctx context.Context) error
WhenAttached waits for the exact current attachment generation to finish hydrating. Cancelling the wait does not cancel shared binding work.
func (*SessionServiceSource) WhenDetached ¶
func (source *SessionServiceSource) WhenDetached(ctx context.Context) error
WhenDetached waits for every binding to finish releasing the previous attachment.
type SessionSummary ¶
type SessionSummary struct {
SessionAddress
CreatedAt float64 `json:"createdAt"`
}
SessionSummary adds the creation timestamp in milliseconds.
type SessionTarget ¶
type SessionTarget struct {
ServerID string `json:"serverId"`
SessionID string `json:"sessionId"`
AttachmentID string `json:"attachmentId"`
}
SessionTarget identifies one attachment generation, not just a Session.
type SessionWorkerServiceLane ¶
type SessionWorkerServiceLane interface {
AgentLane
ModelsServiceLane
TranscriptWatchLane
}
SessionWorkerServiceLane supplies the command, configuration, and watch capabilities consumed by worker services.
type SessionWorkerServices ¶
type SessionWorkerServices struct {
// contains filtered or unexported fields
}
SessionWorkerServices owns the worker's facet generations and attachment-scoped endpoints. Reload calls wait in admission order; Dispose drains that work before releasing both facet sets.
func CreateSessionWorkerServices ¶
func CreateSessionWorkerServices(options SessionWorkerServicesOptions) (*SessionWorkerServices, error)
CreateSessionWorkerServices activates controller, plugin-reload, Models, Transcript, and supplied plugin facets. It returns only after activation finishes; initialization and reload use the background context as upstream's context-free calls do.
func (*SessionWorkerServices) Dispose ¶
func (services *SessionWorkerServices) Dispose() error
Dispose removes subscriptions, waits for queued reloads, disposes the host, and releases every loaded set even after an earlier cleanup failure.
func (*SessionWorkerServices) Invoke ¶
func (services *SessionWorkerServices) Invoke(ctx context.Context, call chord.ServiceCall, scope WorkerServiceScope) (json.RawMessage, error)
Invoke routes a service call through the endpoint belonging to scope, creating it on first use. It returns the original call's result or error.
func (*SessionWorkerServices) RemoveSubscriptions ¶
func (services *SessionWorkerServices) RemoveSubscriptions(matches func(WorkerServiceScope) bool)
RemoveSubscriptions closes endpoints whose attachment scopes match, in their creation order.
type SessionWorkerServicesOptions ¶
type SessionWorkerServicesOptions struct {
Lane SessionWorkerServiceLane
ModelRuntime ModelsServiceModelRuntime
SettingsManager ModelsServiceSettingsManager
FacetLoader chord.FacetLoader
Publish func(context.Context, WorkerServiceScope, string, chord.ServiceProviderUpdate) error
}
SessionWorkerServicesOptions selects a worker's built-in and plugin facets. Publish sends a subscription update to its original attachment.
type SlashCommandCompletion ¶
SlashCommandCompletion is one argument completion. A nil description is omitted.
type SlashCommandContribution ¶
type SlashCommandContribution struct {
Name string
Description *string
ArgumentHint *string
GetArgumentCompletions func(string) ([]SlashCommandCompletion, error)
Run func(context.Context, string) (SlashCommandRunResult, error)
// contains filtered or unexported fields
}
SlashCommandContribution supplies a command and its optional completion callback. Callbacks block until the upstream Promise settles and return its rejection as an error. Nil completions preserve the upstream null result.
func (SlashCommandContribution) Origin ¶
func (command SlashCommandContribution) Origin() (SlashCommandOrigin, bool)
Origin returns the supplied runtime callback identity, if this contribution came from a bridge.
func (SlashCommandContribution) RegistrationIdentity ¶
func (command SlashCommandContribution) RegistrationIdentity() *SlashCommandRegistrationIdentity
RegistrationIdentity remains stable across List snapshots and changes on every registration or replacement admission.
func (SlashCommandContribution) WithOrigin ¶
func (command SlashCommandContribution) WithOrigin(origin SlashCommandOrigin) (SlashCommandContribution, error)
WithOrigin returns a contribution carrying the bridge's owner/handle identity. The registry still assigns a fresh command-object identity when it admits the contribution.
type SlashCommandOrigin ¶
SlashCommandOrigin identifies an originating callback object inside one isolated runtime, without exposing or comparing Go function pointers.
type SlashCommandRegistrationIdentity ¶
type SlashCommandRegistrationIdentity struct {
// contains filtered or unexported fields
}
SlashCommandRegistrationIdentity is the opaque identity of one frozen registry command object. Its nonzero size preserves distinct live Go pointer identities.
type SlashCommandRegistry ¶
type SlashCommandRegistry struct {
// contains filtered or unexported fields
}
SlashCommandRegistry retains the first live registration for each name in insertion order. Methods and listeners run synchronously on the owning presentation executor; listeners may register, replace, or unsubscribe reentrantly.
func NewSlashCommandRegistry ¶
func NewSlashCommandRegistry() *SlashCommandRegistry
NewSlashCommandRegistry creates an empty contribution registry.
func (*SlashCommandRegistry) List ¶
func (registry *SlashCommandRegistry) List() []SlashCommandContribution
List returns a detached snapshot of visible contributions in name insertion order.
func (*SlashCommandRegistry) Register ¶
func (registry *SlashCommandRegistry) Register(command SlashCommandContribution) (func(), error)
Register rejects an invalid name or an existing registration, including a staged replacement.
func (*SlashCommandRegistry) Replace ¶
func (registry *SlashCommandRegistry) Replace(command SlashCommandContribution) (func(), error)
Replace stages a same-name contribution until the preceding registration closes.
func (*SlashCommandRegistry) Subscribe ¶
func (registry *SlashCommandRegistry) Subscribe(callback func([]SlashCommandContribution)) func()
Subscribe hydrates the listener immediately and returns an idempotent unsubscriber.
type SlashCommandRunResult ¶
type SlashCommandRunResult interface {
// contains filtered or unexported methods
}
SlashCommandRunResult is an operation response, a queue response, or nil for no response.
type SlashCommands ¶
type SlashCommands interface {
Register(SlashCommandContribution) (func(), error)
Replace(SlashCommandContribution) (func(), error)
List() []SlashCommandContribution
Subscribe(func([]SlashCommandContribution)) func()
}
SlashCommands owns ordered local contributions. Replace stages a generation until its predecessor retires. Listener hydration and publications are synchronous on the presentation's owner executor.
type SourceState ¶
type SourceState[T comparable] struct { // contains filtered or unexported fields }
SourceState is a read-only lifecycle snapshot with ordered, context-bearing subscriptions. Equal replacements do not publish. Subscribers must not mutate pointer fields. Callbacks run outside source locks and should return promptly.
func (*SourceState[T]) Subscribe ¶
func (state *SourceState[T]) Subscribe(listener func(T, context.Context, ReplicatedStateDelivery)) func()
Subscribe synchronously hydrates the listener and returns an idempotent removal function. Removal affects publications that have not started delivery, not the current listener snapshot. A listener that panics during hydration is removed before the panic propagates.
func (*SourceState[T]) Value ¶
func (state *SourceState[T]) Value() T
type Transcript ¶
type Transcript interface {
State() pico3.ReplicatedStateOf[*TranscriptState]
}
Transcript is the main-lane state replicated through Chord's operation stream.
type TranscriptRuntime ¶
type TranscriptRuntime struct {
Service Transcript
// contains filtered or unexported fields
}
TranscriptRuntime owns a lane watch and any in-flight rebase. Dispose joins the rebase before unsubscribing; rebase errors also reach subsequent event delivery.
func CreateTranscriptService ¶
func CreateTranscriptService(lane TranscriptWatchLane) (*TranscriptRuntime, error)
func (*TranscriptRuntime) Activate ¶
func (r *TranscriptRuntime) Activate() error
func (*TranscriptRuntime) Dispose ¶
func (r *TranscriptRuntime) Dispose() error
type TranscriptState ¶
type TranscriptState struct {
Snapshot *agentharness.LaneSnapshot `json:"snapshot"`
Event json.RawMessage `json:"event"`
}
TranscriptState publishes a coherent lane snapshot and the source event. Hydration and rebases have a null event; event JSON preserves the closed upstream LaneWatchEvent wire shape.
type TranscriptWatchLane ¶
type TranscriptWatchLane interface {
Watch(context.Context) (agentharness.WatchHandle[agentharness.LaneSnapshot], error)
}
TranscriptWatchLane is the durable observation boundary consumed by the Transcript provider.
type WorkerServiceScope ¶
WorkerServiceScope binds one endpoint to an attachment on a server connection.
Source Files
¶
- agent_controller.go
- agent_controller_adapters.go
- agent_controller_invocation.go
- agent_controller_provider.go
- connection.go
- connection_types.go
- models.go
- models_adapters.go
- models_provider.go
- plugins.go
- plugins_adapters.go
- presentation_ui.go
- server.go
- sessions.go
- sessions_adapters.go
- slash_commands.go
- slash_commands_builtin.go
- slash_commands_provider.go
- transcript.go
- transcript_provider.go
- worker.go