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(ctx context.Context, conversation TranscriptConversation) (chord.Facet, error)
- type AgentCancelQueuedResponse
- type AgentCompactionRequest
- type AgentController
- type AgentControllerInitiator
- type AgentControllerProvider
- func (controller *AgentControllerProvider) Abort(ctx context.Context) error
- 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) Prompt(ctx context.Context, request AgentPromptRequest) (AgentOperationResponse, error)
- func (controller *AgentControllerProvider) Steer(ctx context.Context, request AgentPromptRequest) (AgentQueueResponse, error)
- func (controller *AgentControllerProvider) WaitForPrompt(ctx context.Context, operationID string) (AgentPromptResult, error)
- type AgentConversation
- type AgentDocument
- type AgentHarness
- type AgentOperationError
- type AgentOperationResponse
- type AgentPromptImage
- type AgentPromptRequest
- type AgentPromptResult
- type AgentQueueResponse
- type AgentState
- type AggregateError
- type BuiltInSlashCommandsOptions
- type ConversationConfiguration
- type ConversationView
- type ExperimentalServerServices
- type ExperimentalServerServicesOptions
- type ModelRef
- type ModelSummary
- type Models
- type ModelsCatalog
- type ModelsConfiguration
- type ModelsRefresh
- type ModelsRefreshResult
- type ModelsServiceConversation
- type ModelsServiceFacetOptions
- type ModelsServiceModelRuntime
- type ModelsServiceRuntime
- type ModelsServiceSettingsManager
- type ModelsState
- type PrepareSessionPluginsRequest
- type PreparedSessionPlugins
- type PresentationPlugins
- type PresentationSelectItem
- type PresentationUI
- type PromptSubmission
- 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 SessionWorkerConversation
- type SessionWorkerServices
- type SessionWorkerServicesOptions
- type SettledPrompt
- 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 TaskGraphActivity
- type Transcript
- type TranscriptConversation
- type TranscriptViewState
- type WorkerServiceScope
Constants ¶
const ( AgentDocKind = "pi.agent" LiveDocKind = "pi.live" InboxDocKind = "pi.inbox" )
Document kinds of a ConversationView.
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 = chord.DefineService[AgentController](AgentControllerID)
AgentControllerDefinition names the remote service token; Go shares type and value names.
var ModelsDefinition = chord.DefineService[Models]("pi.models")
ModelsDefinition is the pi.models token; Go types and values share a namespace.
var PresentationPluginsDefinition = chord.DefineService[PresentationPlugins]("pi.presentation-plugins")
PresentationPluginsDefinition is the pi.presentation-plugins token; Go types and values share a namespace.
var PresentationUIDefinition = chord.DefineServiceWithOptions[PresentationUI]("pi.local.presentation-ui", chord.ServiceOptions{Local: true})
PresentationUIDefinition names the local service; Go shares type and value names.
var SessionDirectoryDefinition = chord.DefineService[SessionDirectory]("pi.session-directory")
SessionDirectoryDefinition is the pi.session-directory token.
var SessionManagementDefinition = chord.DefineService[SessionManagement]("pi.session-management")
SessionManagementDefinition is the pi.session-management token.
var SessionPluginsDefinition = chord.DefineService[SessionPlugins]("pi.session-plugins")
SessionPluginsDefinition is the pi.session-plugins token.
var SlashCommandsDefinition = chord.DefineServiceWithOptions[SlashCommands]("pi.local.slash-commands", chord.ServiceOptions{Local: true})
SlashCommandsDefinition names the local service token; Go shares type and value names.
var TranscriptDefinition = chord.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. After setup it publishes the catalog with a background context and then follows the agent document, so configuration changes made by any client reach the replicated state.
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(ctx context.Context, conversation TranscriptConversation) (chord.Facet, error)
CreateTranscriptServiceFacet serves the conversation's durable view state. The facet owns the attached state and disposes it with the host.
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 starts a run; it is rejected with code "busy" while one is active.
Prompt(context.Context, AgentPromptRequest) (AgentOperationResponse, error)
// Steer steers the active run, or starts one when idle.
Steer(context.Context, AgentPromptRequest) (AgentQueueResponse, error)
// FollowUp queues input for after the active run, or starts one when idle.
FollowUp(context.Context, AgentPromptRequest) (AgentQueueResponse, error)
CancelQueued(context.Context, string) (AgentCancelQueuedResponse, error)
// Abort withdraws queued input and aborts the active run and compaction.
Abort(context.Context) error
Compact(context.Context, AgentCompactionRequest) (AgentOperationResponse, error)
// WaitForPrompt waits until the prompt with this operation ID is answered or settles unanswered.
WaitForPrompt(context.Context, string) (AgentPromptResult, error)
}
AgentController is the presentation-safe command facade over the worker-owned root conversation. Calls wait for the conversation's result, propagate context cancellation, and return transport errors separately from admission responses.
type AgentControllerInitiator ¶
type AgentControllerInitiator interface {
BeginPrompt(context.Context, AgentPromptRequest) (*chord.ServiceResultInvocation[AgentOperationResponse], error)
BeginAbort(context.Context) (*chord.ServiceInvocation, error)
BeginSteer(context.Context, AgentPromptRequest) (*chord.ServiceResultInvocation[AgentQueueResponse], error)
BeginFollowUp(context.Context, AgentPromptRequest) (*chord.ServiceResultInvocation[AgentQueueResponse], error)
BeginCancelQueued(context.Context, string) (*chord.ServiceResultInvocation[AgentCancelQueuedResponse], error)
BeginCompact(context.Context, AgentCompactionRequest) (*chord.ServiceResultInvocation[AgentOperationResponse], error)
BeginWaitForPrompt(context.Context, string) (*chord.ServiceResultInvocation[AgentPromptResult], 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 durable conversation outcomes without exposing worker-owned details.
func CreateAgentController ¶
func CreateAgentController(harness AgentHarness, conversation AgentConversation) *AgentControllerProvider
CreateAgentController creates the presentation-safe facade for one root conversation.
func (*AgentControllerProvider) Abort ¶
func (controller *AgentControllerProvider) Abort(ctx context.Context) error
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) Prompt ¶
func (controller *AgentControllerProvider) Prompt(ctx context.Context, request AgentPromptRequest) (AgentOperationResponse, error)
func (*AgentControllerProvider) Steer ¶
func (controller *AgentControllerProvider) Steer(ctx context.Context, request AgentPromptRequest) (AgentQueueResponse, error)
func (*AgentControllerProvider) WaitForPrompt ¶
func (controller *AgentControllerProvider) WaitForPrompt(ctx context.Context, operationID string) (AgentPromptResult, error)
type AgentConversation ¶
type AgentConversation interface {
ID() durable.ConversationId
Submit(ctx context.Context, content ai.UserContent, whenBusy durable.WhenBusy) (durable.SubmissionId, error)
Abort(context.Context) error
Compact(ctx context.Context, customInstructions *string) (int64, error)
}
AgentConversation is the root durable conversation boundary the controller drives. Submit adds one input and returns its submission; Compact starts a compaction task and returns its task ID.
type AgentDocument ¶
type AgentDocument interface {
Value() *AgentState
Subscribe(func(context.Context)) func()
Dispose()
}
AgentDocument is the conversation's replicated pi.agent document: its configuration follows every change, also those made by other clients. Value is nil until the document exists. Subscribe returns its unsubscribe function. The facet that acquired the document disposes it.
type AgentHarness ¶
type AgentHarness interface {
AbortSubmission(ctx context.Context, id durable.SubmissionId, conversationID durable.ConversationId) (durable.SubmissionAbortResult, error)
Submission(ctx context.Context, id durable.SubmissionId) (PromptSubmission, error)
AgentDocument(ctx context.Context, conversationID durable.ConversationId) (AgentDocument, error)
}
AgentHarness is the durable Harness boundary the worker services consult: queued and settled submissions for the controller, and a conversation's pi.agent document for the Models service. Submission returns (nil, nil) for an unknown ID; AgentDocument returns (nil, nil) for a conversation without one.
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 rejection. An accepted operation has an operation ID and no error; a rejected one has an error and no operation ID. OperationID identifies the durable submission of a prompt, or the task of a compaction.
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 AgentPromptResult ¶
type AgentPromptResult struct {
Status string `json:"status"`
Text *string `json:"text"`
Reason *string `json:"reason"`
}
AgentPromptResult is the settled outcome of a prompt: "done" with the answer's text, or "unanswered" with the reason it got none.
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. EntryID identifies the durable submission; CancelQueued withdraws it while it is still queued.
type AgentState ¶
type AgentState struct {
Model *ModelRef
ThinkingLevel ai.ThinkingLevel
}
AgentState is the part of the conversation's pi.agent document that the Models service follows. An empty ThinkingLevel is unset and reads as "off".
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, chord.JsonValue) error
}
BuiltInSlashCommandsOptions supplies the presentation generation reload. It waits for replacement and retired-generation disposal before returning.
type ConversationConfiguration ¶
type ConversationConfiguration struct {
Model *ModelRef
ThinkingLevel *ai.ThinkingLevel
}
ConversationConfiguration selects the model and thinking level to apply together; a nil member keeps its current value.
type ConversationView ¶
type ConversationView = harness.ConversationView
ConversationView is a durable conversation's active transcript and built-in documents: the raw active entries (the head marker, then the non-head entries from its head) and pi.agent, pi.live, pi.inbox and pi.usage by kind. It is the value of the Transcript service.
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) (chord.JsonValue, error)
}
ExperimentalServerServicesOptions supplies application-owned Session storage and plugin selection. Nil package paths select defaults; an empty slice selects no packages.
type ModelSummary ¶
ModelSummary is the catalog metadata exposed to clients.
type Models ¶
type Models interface {
State() chord.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 ModelsServiceConversation ¶
type ModelsServiceConversation interface {
Configure(context.Context, ConversationConfiguration) error
}
ModelsServiceConversation is the configuration boundary the Models service consumes from the root conversation.
type ModelsServiceFacetOptions ¶
type ModelsServiceFacetOptions struct {
Conversation ModelsServiceConversation
Agent AgentDocument
ModelRuntime ModelsServiceModelRuntime
SettingsManager ModelsServiceSettingsManager
}
ModelsServiceFacetOptions selects the conversation, its agent document and the optional runtime and settings collaborators. The facet owns Agent and disposes it with the host.
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 and to configuration changes of the agent document.
func CreateModelsService ¶
func CreateModelsService(conversation ModelsServiceConversation, agent AgentDocument, modelRuntime ModelsServiceModelRuntime, settingsManager ModelsServiceSettingsManager, createState func(*ModelsState) chord.MutableReplicatedStateOf[*ModelsState]) *ModelsServiceRuntime
CreateModelsService creates an inactive service over one conversation. Its configuration starts from the agent document and follows it after SyncConfiguration; state allocation and publication belong to the caller's Chord host.
func (*ModelsServiceRuntime) Activate ¶
func (runtime *ModelsServiceRuntime) Activate(ctx context.Context) error
Activate reads the current catalog and publishes it with an idle refresh. Upstream reads and publishes in one synchronous turn (models-provider.ts:114-120), so catalog revisions publish in order; the read runs inside the change, which the state serializes, so concurrent calls keep that order.
func (*ModelsServiceRuntime) SyncConfiguration ¶
func (runtime *ModelsServiceRuntime) SyncConfiguration(ctx context.Context) error
SyncConfiguration publishes the agent document's model and thinking level when they changed.
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) (chord.JsonValue, error)
Reload(context.Context) (chord.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 PromptSubmission ¶
type PromptSubmission interface {
// Wait returns once the submission is answered or settles unanswered.
Wait(context.Context) (SettledPrompt, error)
}
PromptSubmission is one durable submission that a prompt created.
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() chord.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 SessionWorkerConversation ¶
type SessionWorkerConversation interface {
AgentConversation
ModelsServiceConversation
TranscriptConversation
}
SessionWorkerConversation is the root conversation the worker services expose: the command, configuration and view capabilities their providers consume.
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 {
Harness AgentHarness
Conversation SessionWorkerConversation
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. Harness and Conversation are the Session's durable Harness and its root conversation. Publish sends a subscription update to its original attachment.
type SettledPrompt ¶
SettledPrompt is a prompt submission that finished: unanswered with a reason, or answered by Answer. Answer is the first model message of the answer entry; it is nil when the settled submission has no answer.
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.
Each subscription has its own queue of at most stateSubscriberQueueLimit deliveries and runs one callback at a time, so a callback that publishes sees its own later deliveries only after it returns. Unsubscribing drops the queued deliveries, even those of a publication that already snapshotted the subscription. A callback panic never reaches the publisher: it is reported and later deliveries continue. Go callbacks cannot return a Promise, so upstream's wait for one has no counterpart.
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 drops queued deliveries but does not stop a callback that is running. A callback that panics is reported and stays subscribed.
func (*SourceState[T]) Value ¶
func (state *SourceState[T]) Value() T
type TaskGraphActivity ¶
type TaskGraphActivity interface {
Subscribe(func(active bool)) func()
Dispose()
}
TaskGraphActivity reports whether the durable Harness has a live task. Subscribe delivers the current activity and then every change, and returns its unsubscribe function; Dispose detaches the observation.
type Transcript ¶
type Transcript interface {
State() chord.ReplicatedStateOf[ConversationView]
}
Transcript is the root conversation's durable view, replicated through Chord's operation stream: the active entries and its live, inbox, agent and usage documents.
type TranscriptConversation ¶
type TranscriptConversation interface {
ViewState(context.Context) (TranscriptViewState, error)
}
TranscriptConversation is the observation boundary the Transcript provider consumes from the root conversation.
type TranscriptViewState ¶
type TranscriptViewState interface {
chord.ReplicatedStateOf[ConversationView]
Dispose()
}
TranscriptViewState is the conversation's attached durable view state. The durable Harness publishes exact operations per commit, so the worker keeps no reducer of its own. Dispose detaches it.
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
- conversation_view.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