Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeAttachGrantPayload(payload json.RawMessage) (string, error)
- func Encode(frame Frame) ([]byte, error)
- func EventTypeAllowed(version int, eventType string, durable bool) bool
- func FileReferenceCapabilityFingerprint(capability FileReferenceCapabilityPayload) string
- func NegotiateHighestVersion(peerHighest, hubHighest int) (int, error)
- func NegotiateVersion(peer []int, supported []int) (int, error)
- func PeerEventTypeAllowed(eventType string) bool
- func SettingsCapabilityFingerprint(capability SettingsCapabilityPayload) string
- type AckStatus
- type AttentionBlocker
- type AttentionPermission
- type AttentionSubscribe
- type AttentionSummary
- type AttentionSummaryCapability
- type AttentionSummaryFrame
- type Command
- type CommandAck
- type CommandType
- type ConnectionAuthorityReceipt
- type CredentialRotationActivation
- type CredentialRotationCredential
- type CredentialRotationPossession
- type CredentialRotationRequest
- type Error
- type Event
- type EventReceipt
- type EventReceiptStatus
- type FileReferenceCapabilityPayload
- type FileReferenceDispositionCapability
- type FileReferenceHelloCapability
- type FileReferenceImageCapability
- type FileReferenceOutcomePayload
- type FileReferencePart
- type FileReferenceSendPayload
- type Frame
- type FrameName
- type Hello
- type HelloAck
- type HelloCapabilities
- type HistoryPageCapability
- type HistoryPageEvent
- type HistoryPageRequest
- type HistoryPageResponse
- type Ping
- type Pong
- type ProviderStart
- type ProviderStartAck
- type ProviderStartPrepare
- type ProviderStartStarted
- type ProviderStartStatus
- type Role
- type RunControlCapability
- type RunControlCapabilityPayload
- type RunControlOutcomePayload
- type SessionSummary
- type SettingsCapability
- type SettingsCapabilityChoice
- type SettingsCapabilityPayload
- type SettingsChange
- type SettingsDeliveryExecute
- type SettingsEffectivePayload
- type Subscription
- type TargetJoin
- type TargetJoinChallenge
- type TargetJoinCredential
Constants ¶
const ( ProtocolVersion = 1 ProtocolVersionV2 = 2 HubProtocolVersion = ProtocolVersionV2 LegacySettingsCapabilitySchemaVersion = 1 SettingsCapabilitySchemaVersion = 2 )
const ( HistoryPageMaxLimit = 100 // MaxWebSocketFrameBytes is the Hub transport's hard inbound frame limit. // Event payloads must stay below this value because the frame envelope also // carries type, session, proposal, and timestamp fields. MaxWebSocketFrameBytes = 64 * 1024 MaxEventPayloadBytes = 64 * 1024 MaxAttachGrantBytes = 64 * 1024 MinTargetJoinNonceBytes = 32 MaxTargetJoinNonceBytes = 128 MaxTargetJoinCredentialBytes = 4096 MaxCredentialRotationIDBytes = 256 MaxSettingsIdentifierBytes = 128 MaxSettingsCommandIDBytes = 255 )
Variables ¶
var ( ErrNoCompatibleVersion = errors.New("no compatible protocol version") ErrUnknownFrame = errors.New("unknown frame") )
Functions ¶
func DecodeAttachGrantPayload ¶ added in v0.1.7
func DecodeAttachGrantPayload(payload json.RawMessage) (string, error)
DecodeAttachGrantPayload accepts the deliberately narrow session.attach payload. The raw grant remains at Client-to-Hub ingress and must not be retained in a command/event or passed to downstream stores.
func EventTypeAllowed ¶ added in v0.1.7
func FileReferenceCapabilityFingerprint ¶ added in v0.1.7
func FileReferenceCapabilityFingerprint(capability FileReferenceCapabilityPayload) string
FileReferenceCapabilityFingerprint returns the versioned canonical digest specified for a valid capability. Invalid values return an empty string.
func NegotiateHighestVersion ¶ added in v0.1.7
func PeerEventTypeAllowed ¶ added in v0.1.7
func SettingsCapabilityFingerprint ¶ added in v0.1.10
func SettingsCapabilityFingerprint(capability SettingsCapabilityPayload) string
SettingsCapabilityFingerprint returns the canonical fingerprint for a validated capability payload. Callers still need DecodeSettingsCapabilityPayload to validate the complete grammar.
Types ¶
type AttentionBlocker ¶ added in v0.1.7
type AttentionPermission ¶ added in v0.1.7
type AttentionSubscribe ¶ added in v0.1.7
type AttentionSubscribe struct {
RequestID string `json:"request_id"`
}
AttentionSubscribe carries no Session ID or cursor. Membership is derived exclusively from the current Auth-owned attention grant.
func (*AttentionSubscribe) FrameName ¶ added in v0.1.7
func (*AttentionSubscribe) FrameName() FrameName
type AttentionSummary ¶ added in v0.1.7
type AttentionSummary struct {
SessionID string `json:"session_id"`
LatestSeq int64 `json:"latest_seq"`
State string `json:"state"`
Permission *AttentionPermission `json:"permission,omitempty"`
TerminalOutcome *string `json:"terminal_outcome,omitempty"`
LatestChangeSeq *int64 `json:"latest_change_seq,omitempty"`
Blocker *AttentionBlocker `json:"blocker,omitempty"`
SummaryVersion int64 `json:"summary_version"`
SummaryState string `json:"summary_state"`
}
type AttentionSummaryCapability ¶ added in v0.1.7
type AttentionSummaryCapability struct {
MaxSessions int `json:"max_sessions"`
}
type AttentionSummaryFrame ¶ added in v0.1.7
type AttentionSummaryFrame struct {
RequestID string `json:"request_id"`
Kind string `json:"kind"`
SubscriptionState string `json:"subscription_state"`
Summaries []AttentionSummary `json:"summaries"`
}
func (*AttentionSummaryFrame) FrameName ¶ added in v0.1.7
func (*AttentionSummaryFrame) FrameName() FrameName
type Command ¶
type Command struct {
CommandID string `json:"cmd_id"`
Type CommandType `json:"type"`
SessionID string `json:"session_id"`
Payload json.RawMessage `json:"payload"`
}
type CommandAck ¶
type CommandAck struct {
CommandID string `json:"cmd_id"`
Status AckStatus `json:"status"`
Reason string `json:"reason"`
}
func (*CommandAck) FrameName ¶
func (*CommandAck) FrameName() FrameName
type CommandType ¶
type CommandType string
const ( CommandSessionSend CommandType = "session.send" CommandPermissionRespond CommandType = "permission.respond" CommandSessionInterrupt CommandType = "session.interrupt" CommandSessionStop CommandType = "session.stop" CommandSessionAttach CommandType = "session.attach" CommandSettingsChange CommandType = "session.settings.change" )
type ConnectionAuthorityReceipt ¶ added in v0.1.7
type ConnectionAuthorityReceipt struct {
SessionID string `json:"session_id"`
ConnectionEpoch int64 `json:"connection_epoch"`
CredentialGeneration int64 `json:"credential_generation"`
AcceptedFence int64 `json:"accepted_fence"`
WriterLeaseID string `json:"writer_lease_id"`
ExpiresAt int64 `json:"expires_at"`
}
ConnectionAuthorityReceipt is a v2 Adapter-only, non-secret snapshot of the Store-proven live connection tuple. It is neither a bearer nor a capability: consumers must fail closed when the tuple stops matching trusted lifecycle state. It deliberately carries no Provider configuration, path, content, or summary data.
type CredentialRotationActivation ¶ added in v0.1.7
type CredentialRotationActivation struct {
RotationID string `json:"rotation_id"`
Generation int64 `json:"generation"`
ConnectionEpoch int64 `json:"connection_epoch"`
AcceptedFence int64 `json:"accepted_fence"`
}
func (*CredentialRotationActivation) FrameName ¶ added in v0.1.7
func (*CredentialRotationActivation) FrameName() FrameName
type CredentialRotationCredential ¶ added in v0.1.7
type CredentialRotationCredential struct {
SessionID string `json:"session_id"`
RotationID string `json:"rotation_id"`
Generation int64 `json:"generation"`
Credential string `json:"credential"`
ExpiresAt int64 `json:"expires_at"`
}
func (*CredentialRotationCredential) FrameName ¶ added in v0.1.7
func (*CredentialRotationCredential) FrameName() FrameName
type CredentialRotationPossession ¶ added in v0.1.7
type CredentialRotationPossession struct {
SessionID string `json:"session_id"`
RotationID string `json:"rotation_id"`
Generation int64 `json:"generation"`
AcceptedEpoch int64 `json:"accepted_epoch"`
}
func (*CredentialRotationPossession) FrameName ¶ added in v0.1.7
func (*CredentialRotationPossession) FrameName() FrameName
type CredentialRotationRequest ¶ added in v0.1.7
type CredentialRotationRequest struct {
RotationID string `json:"rotation_id"`
}
func (*CredentialRotationRequest) FrameName ¶ added in v0.1.7
func (*CredentialRotationRequest) FrameName() FrameName
type Error ¶
type Event ¶
type EventReceipt ¶ added in v0.1.7
type EventReceipt struct {
ProposalID string `json:"proposal_id"`
Seq int64 `json:"seq"`
Status EventReceiptStatus `json:"status"`
}
EventReceipt is the reference-only acknowledgement of one v2 Adapter durable event proposal. It intentionally does not carry event contents or any session, credential, provider, or grant material.
func (*EventReceipt) FrameName ¶ added in v0.1.7
func (*EventReceipt) FrameName() FrameName
type EventReceiptStatus ¶ added in v0.1.7
type EventReceiptStatus string
const EventReceiptAccepted EventReceiptStatus = "accepted"
type FileReferenceCapabilityPayload ¶ added in v0.1.7
type FileReferenceCapabilityPayload struct {
SchemaVersion int `json:"schema_version"`
Fingerprint string `json:"fingerprint"`
MaxReferences int `json:"max_references"`
MaxTotalBytes int64 `json:"max_total_bytes"`
File FileReferenceDispositionCapability `json:"file"`
Image FileReferenceImageCapability `json:"image"`
}
FileReferenceCapabilityPayload is the Adapter-owned, bounded capability proposal. It contains neither Provider objects nor workspace metadata.
func DecodeFileReferenceCapabilityPayload ¶ added in v0.1.7
func DecodeFileReferenceCapabilityPayload(payload json.RawMessage) (FileReferenceCapabilityPayload, error)
DecodeFileReferenceCapabilityPayload verifies the exact, bounded v2 capability proposal before the Hub commits it to its durable ledger.
type FileReferenceDispositionCapability ¶ added in v0.1.7
type FileReferenceHelloCapability ¶ added in v0.1.7
type FileReferenceHelloCapability struct {
SchemaVersion int `json:"schema_version"`
MaxReferences int `json:"max_references"`
MaxMetadataBytes int `json:"max_metadata_bytes"`
}
FileReferenceHelloCapability advertises the fixed v2 grammar. Per-Adapter support remains in the durable capability event.
type FileReferenceImageCapability ¶ added in v0.1.7
type FileReferenceOutcomePayload ¶ added in v0.1.7
type FileReferenceOutcomePayload struct {
MessageID string
CommandID string
Outcome string
ReferenceIndex *int
Reason *string
}
FileReferenceOutcomePayload is the Adapter's bounded, terminal delivery proposal. The Hub checks it against the ledger before it is persisted.
func DecodeFileReferenceOutcomePayload ¶ added in v0.1.7
func DecodeFileReferenceOutcomePayload(payload json.RawMessage) (FileReferenceOutcomePayload, error)
type FileReferencePart ¶ added in v0.1.7
type FileReferenceSendPayload ¶ added in v0.1.7
type FileReferenceSendPayload struct {
CapabilityFingerprint string
RequestFingerprint string
ReferenceCount int
HasReferences bool
References []FileReferencePart
}
FileReferenceSendPayload is the bounded part of a v2 session.send that contains references. RequestFingerprint is opaque Store metadata only.
func DecodeFileReferenceSendPayload ¶ added in v0.1.7
func DecodeFileReferenceSendPayload(payload json.RawMessage) (FileReferenceSendPayload, error)
DecodeFileReferenceSendPayload validates only the new v2 reference shape. Text-only session.send payloads retain their established permissive shape.
type FrameName ¶
type FrameName string
const ( FrameHello FrameName = "hello" FrameHelloAck FrameName = "hello.ack" FrameEvent FrameName = "event" FrameEventReceipt FrameName = "event.receipt" FrameCommand FrameName = "command" FrameCommandAck FrameName = "command.ack" FramePing FrameName = "ping" FramePong FrameName = "pong" FrameError FrameName = "error" FrameHistoryPage FrameName = "history.page" FrameAttentionSubscribe FrameName = "attention.subscribe" FrameAttentionSummary FrameName = "attention.summary" FrameTargetJoinChallenge FrameName = "target.join.challenge" FrameTargetJoin FrameName = "target.join" FrameTargetJoinCredential FrameName = "target.join.credential" FrameCredentialRotationRequest FrameName = "credential.rotation.request" FrameCredentialRotationCredential FrameName = "credential.rotation.credential" FrameCredentialRotationPossession FrameName = "credential.rotation.possession" FrameCredentialRotationActivation FrameName = "credential.rotation.activation" FrameSettingsDeliveryExecute FrameName = "settings.delivery.execute" FrameProviderStart FrameName = "provider.start" FrameProviderStartPrepare FrameName = "provider.start.prepare" FrameProviderStartStarted FrameName = "provider.start.started" FrameProviderStartAck FrameName = "provider.start.ack" )
type Hello ¶
type Hello struct {
ProtocolVersion int `json:"protocol_version"`
Role Role `json:"role"`
Token string `json:"token"`
Subscriptions []Subscription `json:"subscriptions,omitempty"`
SessionID string `json:"session_id,omitempty"`
Provider string `json:"provider,omitempty"`
Resume bool `json:"resume,omitempty"`
}
type HelloAck ¶
type HelloAck struct {
ProtocolVersion int `json:"protocol_version"`
Sessions []SessionSummary `json:"sessions"`
Capabilities *HelloCapabilities `json:"capabilities,omitempty"`
ConnectionAuthority *ConnectionAuthorityReceipt `json:"connection_authority,omitempty"`
}
type HelloCapabilities ¶ added in v0.1.7
type HelloCapabilities struct {
HistoryPage *HistoryPageCapability `json:"history_page,omitempty"`
AttentionSummary *AttentionSummaryCapability `json:"attention_summary,omitempty"`
Settings *SettingsCapability `json:"settings,omitempty"`
RunControl *RunControlCapability `json:"run_control,omitempty"`
FileReferences *FileReferenceHelloCapability `json:"file_references,omitempty"`
}
type HistoryPageCapability ¶ added in v0.1.7
type HistoryPageCapability struct {
MaxLimit int `json:"max_limit"`
}
type HistoryPageEvent ¶ added in v0.1.7
type HistoryPageRequest ¶ added in v0.1.7
type HistoryPageRequest struct {
RequestID string `json:"request_id"`
SessionID string `json:"session_id"`
BeforeSeq *int64 `json:"before_seq,omitempty"`
Limit int `json:"limit"`
}
func (*HistoryPageRequest) FrameName ¶ added in v0.1.7
func (*HistoryPageRequest) FrameName() FrameName
type HistoryPageResponse ¶ added in v0.1.7
type HistoryPageResponse struct {
RequestID string `json:"request_id"`
SessionID string `json:"session_id"`
Events []HistoryPageEvent `json:"events"`
LatestSeq int64 `json:"latest_seq"`
NextBeforeSeq *int64 `json:"next_before_seq"`
RetentionState string `json:"retention_state"`
}
func (*HistoryPageResponse) FrameName ¶ added in v0.1.7
func (*HistoryPageResponse) FrameName() FrameName
type ProviderStart ¶ added in v0.1.7
type ProviderStart struct {
Attempt int `json:"attempt,omitempty"`
}
ProviderStart requests one v2 Adapter-only Store-linearized child start. Attempt is strictly increasing for the authenticated connection; the Hub binds it to its current authority tuple and never accepts workspace input.
func (*ProviderStart) FrameName ¶ added in v0.1.7
func (*ProviderStart) FrameName() FrameName
type ProviderStartAck ¶ added in v0.1.7
type ProviderStartAck struct {
Attempt int `json:"attempt,omitempty"`
Status ProviderStartStatus `json:"status"`
RecoveryHandle string `json:"recovery_handle,omitempty"`
}
ProviderStartAck is deliberately reference-only. RecoveryHandle is an opaque, non-secret fencing reference emitted only after the Store commits admission; it neither reveals the selected workspace nor carries Provider configuration or credentials.
func (*ProviderStartAck) FrameName ¶ added in v0.1.7
func (*ProviderStartAck) FrameName() FrameName
type ProviderStartPrepare ¶ added in v0.1.7
type ProviderStartPrepare struct {
Attempt int `json:"attempt,omitempty"`
}
ProviderStartPrepare is Hub-to-Adapter only. It confirms that the Hub holds the bounded Store transaction for this exact attempt; it is not permission to forward work.
func (*ProviderStartPrepare) FrameName ¶ added in v0.1.7
func (*ProviderStartPrepare) FrameName() FrameName
type ProviderStartStarted ¶ added in v0.1.7
type ProviderStartStarted struct {
Attempt int `json:"attempt,omitempty"`
}
ProviderStartStarted confirms that the Adapter crossed the process-start boundary while the Hub's Store admission transaction remains open.
func (*ProviderStartStarted) FrameName ¶ added in v0.1.7
func (*ProviderStartStarted) FrameName() FrameName
type ProviderStartStatus ¶ added in v0.1.7
type ProviderStartStatus string
const ( ProviderStartAdmitted ProviderStartStatus = "admitted" ProviderStartRejected ProviderStartStatus = "rejected" )
type RunControlCapability ¶ added in v0.1.7
type RunControlCapability struct {
SchemaVersion int `json:"schema_version"`
MaxPending int `json:"max_pending"`
CompletionTimeoutSeconds int `json:"completion_timeout_seconds"`
}
RunControlCapability advertises the fixed v2 durable run-control contract. Per-Adapter support remains in the durable session.run.capabilities event.
type RunControlCapabilityPayload ¶ added in v0.1.7
type RunControlCapabilityPayload struct {
SchemaVersion int `json:"schema_version"`
InterruptSupported bool `json:"interrupt_supported"`
StopSupported bool `json:"stop_supported"`
}
RunControlCapabilityPayload is the exact Adapter-owned capability proposal. It deliberately contains no provider object or connection metadata.
func DecodeRunControlCapabilityPayload ¶ added in v0.1.7
func DecodeRunControlCapabilityPayload(payload json.RawMessage) (RunControlCapabilityPayload, error)
DecodeRunControlCapabilityPayload accepts only the exact v2 durable capability grammar before a Hub can update the run-control ledger.
type RunControlOutcomePayload ¶ added in v0.1.7
type RunControlOutcomePayload struct {
CommandID string
Operation string
Outcome string
CompletionState *string
ReasonCode *string
}
RunControlOutcomePayload is the exact Adapter completion proposal. The Hub resolves it through the Store before broadcasting the Store-derived event.
func DecodeRunControlOutcomePayload ¶ added in v0.1.7
func DecodeRunControlOutcomePayload(payload json.RawMessage) (RunControlOutcomePayload, error)
DecodeRunControlOutcomePayload accepts the exact public completion proposal. Reservation and writer fencing stay in Store metadata rather than this frame.
type SessionSummary ¶
type SettingsCapability ¶ added in v0.1.7
type SettingsCapability struct {
SchemaVersion int `json:"schema_version"`
MaxPendingChanges int `json:"max_pending_changes"`
ProviderResponseTimeoutSeconds int `json:"provider_response_timeout_seconds"`
}
SettingsCapability advertises fixed v2 protocol limits. It does not claim that a particular Adapter control is mutable.
type SettingsCapabilityChoice ¶ added in v0.1.7
type SettingsCapabilityPayload ¶ added in v0.1.7
type SettingsCapabilityPayload struct {
SchemaVersion int `json:"schema_version"`
Fingerprint string `json:"fingerprint"`
Models []SettingsCapabilityChoice `json:"models"`
ReasoningEfforts []SettingsCapabilityChoice `json:"reasoning_efforts,omitempty"`
PermissionModes []SettingsCapabilityChoice `json:"permission_modes"`
EffectiveModelID string `json:"effective_model_id"`
EffectiveReasoningEffortID *string `json:"effective_reasoning_effort_id,omitempty"`
EffectivePermissionModeID string `json:"effective_permission_mode_id"`
ModelChange string `json:"model_change"`
ReasoningEffortChange string `json:"reasoning_effort_change,omitempty"`
PermissionChange string `json:"permission_change"`
ModelReadOnlyReason *string `json:"model_read_only_reason"`
ReasoningEffortReadOnlyReason *string `json:"reasoning_effort_read_only_reason,omitempty"`
PermissionReadOnlyReason *string `json:"permission_read_only_reason"`
}
func DecodeSettingsCapabilityPayload ¶ added in v0.1.7
func DecodeSettingsCapabilityPayload(payload json.RawMessage) (SettingsCapabilityPayload, error)
DecodeSettingsCapabilityPayload validates the exact durable capability event grammar and recomputes its canonical fingerprint.
func (SettingsCapabilityPayload) MarshalJSON ¶ added in v0.1.10
func (p SettingsCapabilityPayload) MarshalJSON() ([]byte, error)
MarshalJSON keeps the historical schema-v1 event byte shape stable while making every schema-v2 reasoning member explicit, including [] and null for a Provider that does not expose a thought-level control.
type SettingsChange ¶ added in v0.1.7
type SettingsChange struct {
CapabilityFingerprint string
RequestedModelID *string
RequestedReasoningEffortID *string
RequestedPermissionModeID *string
}
SettingsChange is the bounded Client request interpreted by the Hub. It deliberately contains only opaque identifiers, never Provider objects.
func DecodeSettingsChangePayload ¶ added in v0.1.7
func DecodeSettingsChangePayload(payload json.RawMessage) (SettingsChange, error)
DecodeSettingsChangePayload validates the exact, provider-neutral command grammar before Hub routing can touch the durable Settings ledger.
type SettingsDeliveryExecute ¶ added in v0.1.7
type SettingsDeliveryExecute struct {
SessionID string `json:"session_id"`
CommandID string `json:"cmd_id"`
ReservationVersion int64 `json:"reservation_version"`
OperationTimeoutMS int64 `json:"operation_timeout_ms"`
}
func (*SettingsDeliveryExecute) FrameName ¶ added in v0.1.7
func (*SettingsDeliveryExecute) FrameName() FrameName
type SettingsEffectivePayload ¶ added in v0.1.7
type SettingsEffectivePayload struct {
CommandID string
RequestFingerprint string
EffectiveFingerprint string
Outcome string
EffectiveModelID string
EffectiveReasoningEffortID *string
EffectivePermissionModeID string
ReasonCode *string
}
SettingsEffectivePayload is the Adapter's bounded result proposal. The Hub resolves it to durable capability metadata before it can finalize a command.
func DecodeSettingsEffectivePayload ¶ added in v0.1.7
func DecodeSettingsEffectivePayload(payload json.RawMessage) (SettingsEffectivePayload, error)
DecodeSettingsEffectivePayload validates the exact terminal result grammar without allowing the Adapter to select durable outcome metadata itself.
type Subscription ¶
type TargetJoin ¶ added in v0.1.7
type TargetJoin struct {
ProtocolVersion int `json:"protocol_version"`
JoinNonce string `json:"join_nonce"`
}
TargetJoin is the sole client frame permitted on a pending target socket. It deliberately has no Session identity or bearer field.
func (*TargetJoin) FrameName ¶ added in v0.1.7
func (*TargetJoin) FrameName() FrameName
type TargetJoinChallenge ¶ added in v0.1.7
type TargetJoinChallenge struct {
TargetSessionID string `json:"target_session_id"`
JoinNonce string `json:"join_nonce"`
ExpiresAt int64 `json:"expires_at"`
}
TargetJoinChallenge contains only the opaque target reference and a one-time Hub nonce. It is delivered to the current bootstrap Adapter.
func (*TargetJoinChallenge) FrameName ¶ added in v0.1.7
func (*TargetJoinChallenge) FrameName() FrameName
type TargetJoinCredential ¶ added in v0.1.7
type TargetJoinCredential struct {
Credential string `json:"credential"`
TargetSessionID string `json:"target_session_id"`
TargetCredentialLineageRef string `json:"target_credential_lineage_ref"`
Generation int64 `json:"generation"`
ExpiresAt int64 `json:"expires_at"`
}
TargetJoinCredential is the sole server frame on a pending target socket.
func (*TargetJoinCredential) FrameName ¶ added in v0.1.7
func (*TargetJoinCredential) FrameName() FrameName