conversation

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package conversation defines Fort's durable shared-conversation model. It is deliberately independent of storage, HTTP, and concrete runtimes.

Index

Constants

View Source
const (
	MinGroupAgents        = 2
	MaxGroupAgents        = 6
	MaxGroupAgentMessages = 10
	MaxGroupHandoffDepth  = 3
)
View Source
const (
	AuthorityChatSubscriptionIsolatedV1    = "chat_subscription_isolated_v1"
	PolicyCodexSubscriptionChatV1          = "codex-subscription-chat-v1"
	RuntimeContractCodexSubscriptionExecV1 = "codex_subscription_exec_v1"
	AdapterCodexSubscription               = "model.chat.text-only.codex-subscription"
	AccountTypeChatGPT                     = "chatgpt"
	ThreadModeEphemeral                    = "ephemeral"
	SandboxModeReadOnly                    = "readOnly"
	ApprovalPolicyNever                    = "never"
	WorkdirModeEmptyPerTarget              = "empty_per_target"
	ToolsModeNone                          = "none"
	ResourcePolicyDenyAndFail              = "deny_and_fail"
	UnknownProviderIdentity                = "unknown"
	UsageSourceCodexExecJSONL              = "codex_exec_jsonl"
)
View Source
const (
	RoutineTriggerSchedule RoutineTrigger = "schedule"
	RoutineTriggerEvent    RoutineTrigger = "event"

	RoutineApprovalNone                     = "none"
	RoutineApprovalBeforeExternalSideEffect = "before_external_side_effect"
	RoutineLatenessWithin90Seconds          = "within_90s"
	RoutineLatenessNone                     = "none"
)
View Source
const MaxContextBytes = 65_536
View Source
const MaxHandoffContextReferences = 64

Variables

View Source
var (
	ErrContextTooLarge    = errors.New("conversation context exceeds 65536 bytes")
	ErrConversationActive = errors.New("conversation has active targets")
)
View Source
var ErrGroupNeedsYou = errors.New("Group Turn needs human attention")
View Source
var ErrHandoffNeedsYou = errors.New("Handoff needs human attention")

Functions

func AgentChannelID added in v1.0.4

func AgentChannelID(binding AgentBinding) (string, error)

AgentChannelID derives one stable logical ID from the complete immutable binding. encoding/json sorts string-map keys, keeping the digest canonical.

func CanTransition

func CanTransition(from, to TargetState) bool

CanTransition keeps target lifecycle reporting explicit and monotonic.

func CompileContext

func CompileContext(conversationID string, throughMessageID int64, participants []Participant, messages []Message) (string, error)

CompileContext creates the frozen provider prompt shared by every target in a turn. Sorting copies by durable participant position/ID and message ID makes the JSON canonical. The size check rejects the whole turn; history is never silently truncated.

func CompileParticipantPrompt

func CompileParticipantPrompt(contextJSON string, participant Participant) (string, error)

func NewBoundedError added in v1.0.4

func NewBoundedError(code ErrorCode, err error) error

func ValidateAgentRevisionSet added in v1.0.4

func ValidateAgentRevisionSet(agent Agent, profile AgentProfileRevision, behavior AgentBehaviorRevision, binding AgentBindingRevision, conversations []AgentConversation) error

ValidateAgentRevisionSet checks the public aggregate boundary used when an Agent and its currently selected revisions are committed together.

func ValidateContextManifest added in v1.0.4

func ValidateContextManifest(accountID string, rootGrant AuthorityGrant, manifest ContextManifest) error

ValidateContextManifest accepts only immutable Fort messages and finalized, digest-verified Fort artifacts explicitly authorized by the root grant.

func ValidateProjectName

func ValidateProjectName(name string) (string, error)

func ValidateRoutineSchedule added in v1.0.4

func ValidateRoutineSchedule(expression, timezone string) error

ValidateRoutineSchedule accepts only the exact six-field cron and IANA timezone contract used by the cloud scheduler. It intentionally rejects descriptor aliases and normalized-but-not-canonical whitespace.

Types

type Agent added in v1.0.4

type Agent struct {
	ID                        string     `json:"id"`
	AccountID                 string     `json:"account_id"`
	State                     AgentState `json:"state"`
	CurrentProfileRevisionID  string     `json:"current_profile_revision_id"`
	CurrentBehaviorRevisionID string     `json:"current_behavior_revision_id"`
	CurrentBindingRevisionID  string     `json:"current_binding_revision_id"`
	CanonicalConversationID   string     `json:"canonical_conversation_id"`
	CreatedAt                 time.Time  `json:"created_at"`
}

Agent is the stable Fort identity. Its current revision links may advance, while its ID and canonical Conversation remain unchanged.

func (Agent) Validate added in v1.0.4

func (a Agent) Validate() error

type AgentAuthoritySnapshot added in v1.0.4

type AgentAuthoritySnapshot struct {
	RequestedModel  string            `json:"requested_model"`
	ResolvedModel   string            `json:"resolved_model"`
	Authority       string            `json:"authority"`
	PolicyID        string            `json:"policy_id"`
	PolicyRevision  string            `json:"policy_revision"`
	AdapterID       string            `json:"adapter_id"`
	AdapterRevision string            `json:"adapter_revision"`
	RuntimeContract string            `json:"runtime_contract"`
	SessionMode     string            `json:"session_mode"`
	MemoryMode      string            `json:"memory_mode"`
	ExecutionPolicy map[string]string `json:"execution_policy"`
}

AgentAuthoritySnapshot is the accepted, non-secret adapter contract for an Agent Channel. ExecutionPolicy keeps adapter-specific normalized fields exact without coupling the conversation domain to a concrete provider.

type AgentBehaviorRevision added in v1.0.4

type AgentBehaviorRevision struct {
	ID                   string    `json:"id"`
	AgentID              string    `json:"agent_id"`
	Revision             int       `json:"revision"`
	Role                 string    `json:"role"`
	StandingInstructions string    `json:"standing_instructions,omitempty"`
	EnabledSkills        []string  `json:"enabled_skills"`
	EnabledTools         []string  `json:"enabled_tools"`
	PromptMaterial       string    `json:"prompt_material,omitempty"`
	CreatedAt            time.Time `json:"created_at"`
}

func (AgentBehaviorRevision) Validate added in v1.0.4

func (r AgentBehaviorRevision) Validate() error

type AgentBinding added in v1.0.4

type AgentBinding struct {
	Seat      AgentSeatIdentity      `json:"seat"`
	Authority AgentAuthoritySnapshot `json:"authority"`
}

func (AgentBinding) Validate added in v1.0.4

func (binding AgentBinding) Validate() error

type AgentBindingRevision added in v1.0.4

type AgentBindingRevision struct {
	ID                        string    `json:"id"`
	AgentID                   string    `json:"agent_id"`
	Revision                  int       `json:"revision"`
	BehaviorRevisionID        string    `json:"behavior_revision_id"`
	ExecutionSourceID         string    `json:"execution_source_id"`
	SourceAgentID             string    `json:"source_agent_id"`
	SeatID                    string    `json:"seat_id"`
	FortProfile               string    `json:"fort_profile"`
	Provider                  string    `json:"provider"`
	RequestedModel            string    `json:"requested_model"`
	ResolvedModel             string    `json:"resolved_model"`
	ComputerID                string    `json:"computer_id,omitempty"`
	CloudRuntime              string    `json:"cloud_runtime,omitempty"`
	AdapterID                 string    `json:"adapter_id"`
	AdapterRevision           string    `json:"adapter_revision"`
	SourceConfigDigest        string    `json:"source_config_digest"`
	AuthorityID               string    `json:"authority_id"`
	AuthorityRevision         string    `json:"authority_revision"`
	PolicyID                  string    `json:"policy_id"`
	PolicyRevision            string    `json:"policy_revision"`
	SessionBehavior           string    `json:"session_behavior"`
	MemoryBehavior            string    `json:"memory_behavior"`
	CapabilityEvidence        []string  `json:"capability_evidence"`
	ReadinessContractID       string    `json:"readiness_contract_id"`
	ReadinessContractRevision string    `json:"readiness_contract_revision"`
	SupersedesRevisionID      string    `json:"supersedes_revision_id,omitempty"`
	ActivatedAt               time.Time `json:"activated_at"`
	RetiredAt                 time.Time `json:"retired_at,omitempty"`
}

func (AgentBindingRevision) Validate added in v1.0.4

func (r AgentBindingRevision) Validate() error

type AgentChannel added in v1.0.4

type AgentChannel struct {
	ID        string            `json:"id"`
	Name      string            `json:"name"`
	State     AgentChannelState `json:"state"`
	OptionID  string            `json:"option_id"`
	Binding   AgentBinding      `json:"binding"`
	CreatedAt time.Time         `json:"created_at"`
}

func (AgentChannel) Validate added in v1.0.4

func (channel AgentChannel) Validate() error

type AgentChannelConversation added in v1.0.4

type AgentChannelConversation struct {
	AgentChannelID string    `json:"agent_channel_id"`
	ConversationID string    `json:"conversation_id"`
	CreatedAt      time.Time `json:"created_at"`
}

type AgentChannelDetail added in v1.0.4

type AgentChannelDetail struct {
	Channel       AgentChannel               `json:"channel"`
	Conversations []AgentConversationSummary `json:"conversations"`
}

type AgentChannelState added in v1.0.4

type AgentChannelState string
const (
	AgentChannelOpen     AgentChannelState = "open"
	AgentChannelArchived AgentChannelState = "archived"

	AgentMemoryEphemeral = "ephemeral"
)

type AgentConversation added in v1.0.4

type AgentConversation struct {
	AgentID        string                `json:"agent_id"`
	ConversationID string                `json:"conversation_id"`
	Kind           AgentConversationKind `json:"kind"`
	CreatedAt      time.Time             `json:"created_at"`
}

func (AgentConversation) Validate added in v1.0.4

func (c AgentConversation) Validate() error

type AgentConversationKind added in v1.0.4

type AgentConversationKind string
const (
	AgentConversationCanonical AgentConversationKind = "canonical"
	AgentConversationSecondary AgentConversationKind = "secondary"
)

type AgentConversationPin added in v1.0.4

type AgentConversationPin struct {
	ConversationID string    `json:"conversation_id"`
	PinnedAt       time.Time `json:"pinned_at"`
}

type AgentConversationSummary added in v1.0.4

type AgentConversationSummary struct {
	Conversation Conversation `json:"conversation"`
	Participant  Participant  `json:"participant"`
	Pinned       bool         `json:"pinned"`
	PinnedAt     time.Time    `json:"pinned_at,omitempty"`
}

type AgentProfileRevision added in v1.0.4

type AgentProfileRevision struct {
	ID        string    `json:"id"`
	AgentID   string    `json:"agent_id"`
	Revision  int       `json:"revision"`
	Name      string    `json:"name"`
	Title     string    `json:"title,omitempty"`
	AvatarURL string    `json:"avatar_url,omitempty"`
	Hidden    bool      `json:"hidden"`
	Pinned    bool      `json:"pinned"`
	SortOrder int       `json:"sort_order"`
	CreatedAt time.Time `json:"created_at"`
}

func (AgentProfileRevision) Validate added in v1.0.4

func (r AgentProfileRevision) Validate() error

type AgentSeatIdentity added in v1.0.4

type AgentSeatIdentity struct {
	ID      string `json:"id"`
	Profile string `json:"profile"`
	Agent   string `json:"agent"`
	Model   string `json:"model"`
	Machine string `json:"machine"`
}

AgentSeatIdentity is the immutable dispatch identity stored by an Agent Channel. Presentation and live readiness deliberately live elsewhere.

type AgentState added in v1.0.4

type AgentState string
const (
	AgentOpen     AgentState = "open"
	AgentArchived AgentState = "archived"
)

type AuthorKind

type AuthorKind string
const (
	AuthorHuman     AuthorKind = "human"
	AuthorAssistant AuthorKind = "agent"
	AuthorSystem    AuthorKind = "system"
)

type AuthorityGrant added in v1.0.4

type AuthorityGrant struct {
	ID               string   `json:"id"`
	Permissions      []string `json:"permissions"`
	ContextRecordIDs []string `json:"context_record_ids"`
}

AuthorityGrant is one immutable delegation or policy layer. Permissions are opaque Fort-owned capability identifiers; no layer can add a permission missing from another applicable layer.

func ComputeEffectiveAuthority added in v1.0.4

func ComputeEffectiveAuthority(requested []string, layers ...AuthorityGrant) (AuthorityGrant, error)

ComputeEffectiveAuthority intersects every persisted authority layer and rejects requested permissions outside the resulting grant.

func (AuthorityGrant) Validate added in v1.0.4

func (g AuthorityGrant) Validate() error

type BoundedError added in v1.0.4

type BoundedError struct {
	Code ErrorCode
	Err  error
}

BoundedError carries one closed conversation error code without coupling the domain to HTTP. Transports may project Code while errors.Is/As can still inspect the underlying cause.

func (*BoundedError) Error added in v1.0.4

func (e *BoundedError) Error() string

func (*BoundedError) Unwrap added in v1.0.4

func (e *BoundedError) Unwrap() error

type ContextManifest added in v1.0.4

type ContextManifest struct {
	References []ContextReference `json:"references"`
}

type ContextReference added in v1.0.4

type ContextReference struct {
	Kind           ContextReferenceKind `json:"kind"`
	ID             string               `json:"id"`
	AccountID      string               `json:"account_id"`
	Immutable      bool                 `json:"immutable"`
	Finalized      bool                 `json:"finalized,omitempty"`
	Digest         string               `json:"digest,omitempty"`
	ObservedDigest string               `json:"observed_digest,omitempty"`
	Size           int64                `json:"size,omitempty"`
	ObservedSize   int64                `json:"observed_size,omitempty"`
}

func (ContextReference) Key added in v1.0.4

func (r ContextReference) Key() string

type ContextReferenceKind added in v1.0.4

type ContextReferenceKind string
const (
	ContextMessage        ContextReferenceKind = "message"
	ContextArtifact       ContextReferenceKind = "context_artifact"
	ContextOutputArtifact ContextReferenceKind = "output_artifact"
)

type Conversation

type Conversation struct {
	ID        string            `json:"id"`
	ProjectID string            `json:"project_id,omitempty"`
	Title     string            `json:"title"`
	State     ConversationState `json:"state"`
	CreatedAt time.Time         `json:"created_at"`
	UpdatedAt time.Time         `json:"updated_at"`
}

type ConversationState

type ConversationState string
const (
	ConversationOpen     ConversationState = "open"
	ConversationArchived ConversationState = "archived"
)

type ErrorCode added in v1.0.4

type ErrorCode string
const (
	ErrorSeatUnknown        ErrorCode = "seat_unknown"
	ErrorSeatUnready        ErrorCode = "seat_unready"
	ErrorParticipantUnknown ErrorCode = "participant_unknown"
	ErrorParticipantRemoved ErrorCode = "participant_removed"
	ErrorConversationActive ErrorCode = "conversation_active"
)

type ExecutionSource added in v1.0.4

type ExecutionSource struct {
	ID              string                    `json:"id"`
	AccountID       string                    `json:"account_id"`
	Framework       string                    `json:"framework"`
	InstanceID      string                    `json:"instance_id"`
	GatewayID       string                    `json:"gateway_id"`
	DisplayName     string                    `json:"display_name"`
	ResourceSharing ResourceSharingDisclosure `json:"resource_sharing"`
	LastSeenAt      time.Time                 `json:"last_seen_at,omitempty"`
}

func (ExecutionSource) Validate added in v1.0.4

func (s ExecutionSource) Validate() error

type GroupConcurrencyPolicy added in v1.0.4

type GroupConcurrencyPolicy string
const (
	GroupSequential GroupConcurrencyPolicy = "sequential"
	GroupConcurrent GroupConcurrencyPolicy = "concurrent"
)

type GroupConversation added in v1.0.4

type GroupConversation struct {
	ID                          string            `json:"id"`
	AccountID                   string            `json:"account_id"`
	ConversationID              string            `json:"conversation_id"`
	State                       ConversationState `json:"state"`
	CurrentMembershipRevisionID string            `json:"current_membership_revision_id"`
	CreatedAt                   time.Time         `json:"created_at"`
}

func (GroupConversation) Validate added in v1.0.4

func (g GroupConversation) Validate() error

type GroupInitialTarget added in v1.0.4

type GroupInitialTarget struct {
	GroupTurnID        string `json:"group_turn_id"`
	Wave               int    `json:"wave"`
	AgentID            string `json:"agent_id"`
	BehaviorRevisionID string `json:"behavior_revision_id"`
	BindingRevisionID  string `json:"binding_revision_id"`
	ParticipantID      string `json:"participant_id"`
}

type GroupMember added in v1.0.4

type GroupMember struct {
	AgentID  string `json:"agent_id"`
	Position int    `json:"position"`
}

type GroupMembershipRevision added in v1.0.4

type GroupMembershipRevision struct {
	ID        string        `json:"id"`
	GroupID   string        `json:"group_id"`
	Revision  int           `json:"revision"`
	Members   []GroupMember `json:"members"`
	CreatedAt time.Time     `json:"created_at"`
}

func (GroupMembershipRevision) Validate added in v1.0.4

type GroupRecipient added in v1.0.4

type GroupRecipient struct {
	AgentID            string `json:"agent_id"`
	BehaviorRevisionID string `json:"behavior_revision_id"`
	BindingRevisionID  string `json:"binding_revision_id"`
	ParticipantID      string `json:"participant_id"`
}

type GroupRecipientSelection added in v1.0.4

type GroupRecipientSelection string
const (
	GroupRecipientSelectionExplicit GroupRecipientSelection = "explicit"
	GroupRecipientSelectionEveryone GroupRecipientSelection = "everyone"
)

type GroupTurnEnvelope added in v1.0.4

type GroupTurnEnvelope struct {
	ID                         string                  `json:"id"`
	GroupID                    string                  `json:"group_id"`
	ConversationID             string                  `json:"conversation_id"`
	ClientTurnID               string                  `json:"client_turn_id"`
	IdempotencyKey             string                  `json:"idempotency_key"`
	MembershipRevisionID       string                  `json:"membership_revision_id"`
	Selection                  GroupRecipientSelection `json:"selection"`
	Recipients                 []GroupRecipient        `json:"recipients"`
	ContextSnapshotID          string                  `json:"context_snapshot_id"`
	RootDelegationGrant        AuthorityGrant          `json:"root_delegation_grant"`
	ConcurrencyPolicy          GroupConcurrencyPolicy  `json:"concurrency_policy"`
	CancellationPolicyID       string                  `json:"cancellation_policy_id"`
	CancellationPolicyRevision string                  `json:"cancellation_policy_revision"`
	ApprovalPolicyID           string                  `json:"approval_policy_id"`
	ApprovalPolicyRevision     string                  `json:"approval_policy_revision"`
	MaxAgentMessages           int                     `json:"max_agent_messages"`
	MaxHandoffDepth            int                     `json:"max_handoff_depth"`
	CostLimitClass             LimitClassification     `json:"cost_limit_class"`
	CostLimitEvidenceID        string                  `json:"cost_limit_evidence_id,omitempty"`
	TokenLimitClass            LimitClassification     `json:"token_limit_class"`
	TokenLimitEvidenceID       string                  `json:"token_limit_evidence_id,omitempty"`
	Deadline                   time.Time               `json:"deadline"`
	CreatedAt                  time.Time               `json:"created_at"`
}

func (GroupTurnEnvelope) CanStart added in v1.0.4

func (e GroupTurnEnvelope) CanStart(
	group GroupConversation,
	membership GroupMembershipRevision,
	now time.Time,
	agentMessages int,
) error

CanStart applies the shared first-release message and deadline bounds before any initial target or accepted Handoff starts a provider. agentMessages is the persisted total across the initial wave and its Handoff chain.

func (GroupTurnEnvelope) InitialTargets added in v1.0.4

func (e GroupTurnEnvelope) InitialTargets(group GroupConversation, membership GroupMembershipRevision) ([]GroupInitialTarget, error)

InitialTargets exposes the only first-release fan-out wave. Agent output, prose mentions, and silence have no API here that can create another wave.

func (GroupTurnEnvelope) Validate added in v1.0.4

func (e GroupTurnEnvelope) Validate(group GroupConversation, membership GroupMembershipRevision) error

type Handoff added in v1.0.4

type Handoff struct {
	ID                          string              `json:"id"`
	AccountID                   string              `json:"account_id"`
	IdempotencyKey              string              `json:"idempotency_key"`
	State                       HandoffState        `json:"state"`
	CreatedByKind               HandoffActorKind    `json:"created_by_kind"`
	CreatedByID                 string              `json:"created_by_id"`
	GroupTurnID                 string              `json:"group_turn_id,omitempty"`
	SourceMessageID             string              `json:"source_message_id"`
	SourceAgentID               string              `json:"source_agent_id,omitempty"`
	SourceBehaviorRevisionID    string              `json:"source_behavior_revision_id,omitempty"`
	SourceBindingRevisionID     string              `json:"source_binding_revision_id,omitempty"`
	RecipientAgentID            string              `json:"recipient_agent_id"`
	RecipientBehaviorRevisionID string              `json:"recipient_behavior_revision_id"`
	RecipientBindingRevisionID  string              `json:"recipient_binding_revision_id"`
	SourceConversationID        string              `json:"source_conversation_id"`
	OutputConversationID        string              `json:"output_conversation_id"`
	Context                     ContextManifest     `json:"context"`
	RequestedResult             string              `json:"requested_result"`
	ReplyToMessageID            string              `json:"reply_to_message_id,omitempty"`
	RootDelegationGrant         AuthorityGrant      `json:"root_delegation_grant"`
	ParentStageAuthority        *AuthorityGrant     `json:"parent_stage_authority,omitempty"`
	HandoffPolicy               AuthorityGrant      `json:"handoff_policy"`
	RecipientBindingPolicy      AuthorityGrant      `json:"recipient_binding_policy"`
	EmitterRequest              *AuthorityGrant     `json:"emitter_request,omitempty"`
	ApprovalRequired            bool                `json:"approval_required"`
	ApprovalReceipt             *AuthorityGrant     `json:"approval_receipt,omitempty"`
	RequestedAuthority          []string            `json:"requested_authority"`
	EffectiveAuthority          AuthorityGrant      `json:"effective_authority"`
	StructuredEmitterID         string              `json:"structured_emitter_id,omitempty"`
	BudgetClass                 LimitClassification `json:"budget_class"`
	BudgetLimitEvidenceID       string              `json:"budget_limit_evidence_id,omitempty"`
	MaxAgentMessages            int                 `json:"max_agent_messages"`
	MaxDepth                    int                 `json:"max_depth"`
	Depth                       int                 `json:"depth"`
	Deadline                    time.Time           `json:"deadline"`
	AncestorAgentIDs            []string            `json:"ancestor_agent_ids"`
	ParentHandoffID             string              `json:"parent_handoff_id,omitempty"`
	CreatedAt                   time.Time           `json:"created_at"`
}

func (Handoff) CanStart added in v1.0.4

func (h Handoff) CanStart(now time.Time, agentMessages int) error

CanStart applies the shared hard message/depth/deadline bounds immediately before provider start. Exhaustion is actionable rather than silently ignored.

func (Handoff) ReferenceProjection added in v1.0.4

func (h Handoff) ReferenceProjection(conversationID string, result HandoffResult) (HandoffProjection, error)

func (Handoff) Validate added in v1.0.4

func (h Handoff) Validate() error

type HandoffActorKind added in v1.0.4

type HandoffActorKind string
const (
	HandoffActorHuman HandoffActorKind = "human"
	HandoffActorAgent HandoffActorKind = "agent"
)

type HandoffProjection added in v1.0.4

type HandoffProjection struct {
	HandoffID              string       `json:"handoff_id"`
	ConversationID         string       `json:"conversation_id"`
	OutputConversationID   string       `json:"output_conversation_id"`
	AuthoritativeMessageID string       `json:"authoritative_message_id"`
	State                  HandoffState `json:"state"`
}

HandoffProjection is reference-only by construction: it contains linkage to the one authoritative message but no result or context body field.

type HandoffResult added in v1.0.4

type HandoffResult struct {
	HandoffID            string `json:"handoff_id"`
	OutputConversationID string `json:"output_conversation_id"`
	MessageID            string `json:"message_id"`
	Body                 string `json:"body"`
}

func (HandoffResult) ValidateFor added in v1.0.4

func (r HandoffResult) ValidateFor(h Handoff) error

type HandoffState added in v1.0.4

type HandoffState string
const (
	HandoffQueued    HandoffState = "queued"
	HandoffNeedsYou  HandoffState = "needs_you"
	HandoffWorking   HandoffState = "working"
	HandoffCompleted HandoffState = "completed"
	HandoffFailed    HandoffState = "failed"
	HandoffCanceled  HandoffState = "canceled"
)

func (HandoffState) Valid added in v1.0.4

func (s HandoffState) Valid() bool

type LimitClassification added in v1.0.4

type LimitClassification string
const (
	LimitHard    LimitClassification = "hard"
	LimitUnknown LimitClassification = "unknown"
)

func (LimitClassification) Valid added in v1.0.4

func (c LimitClassification) Valid() bool

type Message

type Message struct {
	ID             int64      `json:"id"`
	ConversationID string     `json:"conversation_id"`
	TurnID         string     `json:"turn_id,omitempty"`
	TargetID       string     `json:"target_id,omitempty"`
	AuthorKind     AuthorKind `json:"author_kind"`
	AuthorID       string     `json:"author_id"`
	Body           string     `json:"body"`
	CreatedAt      time.Time  `json:"created_at"`
}

type Participant

type Participant struct {
	ID             string           `json:"id"`
	ConversationID string           `json:"conversation_id"`
	SeatID         string           `json:"seat_id"`
	Profile        string           `json:"profile"`
	Agent          string           `json:"agent"`
	Model          string           `json:"model,omitempty"`
	Machine        string           `json:"machine"`
	DisplayName    string           `json:"display_name"`
	Position       int              `json:"position"`
	State          ParticipantState `json:"state"`
	CreatedAt      time.Time        `json:"created_at"`
	RemovedAt      time.Time        `json:"removed_at,omitempty"`
}

type ParticipantState

type ParticipantState string
const (
	ParticipantActive  ParticipantState = "active"
	ParticipantRemoved ParticipantState = "removed"
)

type PrimaryAgentSetting added in v1.0.4

type PrimaryAgentSetting struct {
	OptionID  string             `json:"option_id"`
	Seat      Seat               `json:"seat"`
	Authority string             `json:"authority"`
	Policy    SubscriptionPolicy `json:"policy"`
	UpdatedAt time.Time          `json:"updated_at"`
}

PrimaryAgentSetting is the singleton selection used only for Channels created after it is written. Existing Channels retain their own snapshot.

func (PrimaryAgentSetting) Validate added in v1.0.4

func (s PrimaryAgentSetting) Validate() error

type PrimaryChannel added in v1.0.4

type PrimaryChannel struct {
	ConversationID string             `json:"conversation_id"`
	ParticipantID  string             `json:"participant_id"`
	Authority      string             `json:"authority"`
	Policy         SubscriptionPolicy `json:"policy"`
	CreatedAt      time.Time          `json:"created_at"`
}

PrimaryChannel marks one canonical conversation as a private Channel and binds it to exactly one immutable participant and subscription policy.

func (PrimaryChannel) Validate added in v1.0.4

func (c PrimaryChannel) Validate() error

type PrimaryChannelSummary added in v1.0.4

type PrimaryChannelSummary struct {
	Conversation Conversation   `json:"conversation"`
	Participant  Participant    `json:"participant"`
	Identity     PrimaryChannel `json:"primary_identity"`
	Pinned       bool           `json:"pinned"`
	PinnedAt     time.Time      `json:"pinned_at,omitempty"`
}

type Project

type Project struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ResourceSharingDisclosure added in v1.0.4

type ResourceSharingDisclosure struct {
	ProviderCredentials ResourceSharingScope `json:"provider_credentials"`
	Filesystem          ResourceSharingScope `json:"filesystem"`
	BrowserSessions     ResourceSharingScope `json:"browser_sessions"`
	FrameworkSessions   ResourceSharingScope `json:"framework_sessions"`
	SourceMemory        ResourceSharingScope `json:"source_memory"`
	ToolConfiguration   ResourceSharingScope `json:"tool_configuration"`
}

type ResourceSharingScope added in v1.0.4

type ResourceSharingScope string
const (
	ResourceProfileScoped ResourceSharingScope = "profile_scoped"
	ResourceMachineShared ResourceSharingScope = "machine_shared"
	ResourceAccountShared ResourceSharingScope = "account_shared"
	ResourceUnknown       ResourceSharingScope = "unknown"
)

func (ResourceSharingScope) Valid added in v1.0.4

func (s ResourceSharingScope) Valid() bool

type Routine added in v1.0.4

type Routine struct {
	ID                string       `json:"id"`
	AccountID         string       `json:"account_id"`
	AgentID           string       `json:"agent_id"`
	CurrentRevisionID string       `json:"current_revision_id"`
	State             RoutineState `json:"state"`
	CreatedAt         time.Time    `json:"created_at"`
}

func (Routine) Validate added in v1.0.4

func (r Routine) Validate(revision RoutineRevision) error

type RoutineAuthority added in v1.0.4

type RoutineAuthority string
const RoutineAuthorityFortCloud RoutineAuthority = "fort_cloud"

type RoutineRevision added in v1.0.4

type RoutineRevision struct {
	ID                   string           `json:"id"`
	RoutineID            string           `json:"routine_id"`
	Revision             int              `json:"revision"`
	AgentID              string           `json:"agent_id"`
	BehaviorRevisionID   string           `json:"behavior_revision_id"`
	BindingRevisionID    string           `json:"binding_revision_id"`
	Authority            RoutineAuthority `json:"authority"`
	Trigger              RoutineTrigger   `json:"trigger"`
	Schedule             string           `json:"schedule,omitempty"`
	Timezone             string           `json:"timezone,omitempty"`
	NextOccurrence       time.Time        `json:"next_occurrence,omitempty"`
	InputSource          string           `json:"input_source"`
	FreshnessSeconds     int64            `json:"freshness_seconds"`
	ExpectedResult       string           `json:"expected_result"`
	ResultConversationID string           `json:"result_conversation_id"`
	ApprovalBoundary     string           `json:"approval_boundary"`
	MissingInputBehavior string           `json:"missing_input_behavior"`
	RetryPolicy          string           `json:"retry_policy"`
	CatchUpPolicy        string           `json:"catch_up_policy"`
	LatenessPolicy       string           `json:"lateness_policy"`
	CreatedAt            time.Time        `json:"created_at"`
}

func (RoutineRevision) NeedsRevalidation added in v1.0.4

func (r RoutineRevision) NeedsRevalidation(agent Agent) bool

NeedsRevalidation identifies a Routine whose pinned Behavior or Binding is no longer the owning Agent's current accepted revision.

func (RoutineRevision) Validate added in v1.0.4

func (r RoutineRevision) Validate() error

type RoutineRun added in v1.0.4

type RoutineRun struct {
	ID                 string          `json:"id"`
	RoutineID          string          `json:"routine_id"`
	RoutineRevisionID  string          `json:"routine_revision_id"`
	AgentID            string          `json:"agent_id"`
	BehaviorRevisionID string          `json:"behavior_revision_id"`
	BindingRevisionID  string          `json:"binding_revision_id"`
	OccurrenceID       string          `json:"occurrence_id"`
	Kind               RoutineRunKind  `json:"kind"`
	State              RoutineRunState `json:"state"`
	NormalizedResult   string          `json:"normalized_result,omitempty"`
	ResultMessageID    string          `json:"result_message_id,omitempty"`
	CreatedAt          time.Time       `json:"created_at"`
}

func (RoutineRun) ValidateFor added in v1.0.4

func (r RoutineRun) ValidateFor(routine Routine, revision RoutineRevision) error

type RoutineRunKind added in v1.0.4

type RoutineRunKind string
const (
	RoutineRunScheduled RoutineRunKind = "scheduled"
	RoutineRunTest      RoutineRunKind = "test"
)

type RoutineRunState added in v1.0.4

type RoutineRunState string
const (
	RoutineRunQueued    RoutineRunState = "queued"
	RoutineRunWorking   RoutineRunState = "working"
	RoutineRunNeedsYou  RoutineRunState = "needs_you"
	RoutineRunSucceeded RoutineRunState = "succeeded"
	RoutineRunFailed    RoutineRunState = "failed"
	RoutineRunCanceled  RoutineRunState = "canceled"
)

func (RoutineRunState) Valid added in v1.0.4

func (s RoutineRunState) Valid() bool

type RoutineState added in v1.0.4

type RoutineState string
const (
	RoutineActive   RoutineState = "active"
	RoutinePaused   RoutineState = "paused"
	RoutineArchived RoutineState = "archived"
)

type RoutineTrigger added in v1.0.4

type RoutineTrigger string
type ScheduleChannelLink struct {
	ScheduleID     string    `json:"schedule_id"`
	ConversationID string    `json:"conversation_id"`
	CreatedAt      time.Time `json:"created_at"`
}

type Seat

type Seat struct {
	ID          string `json:"id"`
	Profile     string `json:"profile"`
	Agent       string `json:"agent"`
	Model       string `json:"model,omitempty"`
	Machine     string `json:"machine"`
	DisplayName string `json:"display_name"`
	State       string `json:"state"`
	Reason      string `json:"reason,omitempty"`
}

Seat is one exact profile + provider/model + machine choice advertised by the capability inventory. A conversation persists the resolved fields, not merely this ephemeral identifier.

type SourceAgent added in v1.0.4

type SourceAgent struct {
	ID                  string    `json:"id"`
	ExecutionSourceID   string    `json:"execution_source_id"`
	OpaqueSourceAgentID string    `json:"opaque_source_agent_id"`
	DisplayName         string    `json:"display_name"`
	LastSeenAt          time.Time `json:"last_seen_at,omitempty"`
}

func (SourceAgent) Identity added in v1.0.4

func (a SourceAgent) Identity() (SourceAgentIdentity, error)

func (SourceAgent) Validate added in v1.0.4

func (a SourceAgent) Validate() error

type SourceAgentIdentity added in v1.0.4

type SourceAgentIdentity struct {
	ExecutionSourceID   string
	OpaqueSourceAgentID string
}

SourceAgentIdentity is deliberately source-qualified. Display names are not part of identity and cannot merge two framework-native Agents.

type SubscriptionPolicy added in v1.0.4

type SubscriptionPolicy struct {
	PolicyID                     string `json:"policy_id"`
	PolicyRevision               string `json:"policy_revision"`
	AdapterID                    string `json:"adapter_id"`
	AdapterRevision              string `json:"adapter_revision"`
	CodexVersion                 string `json:"codex_version"`
	CodexExecutableRevision      string `json:"codex_executable_revision"`
	CodexSchemaRevision          string `json:"codex_schema_revision"`
	RuntimeContract              string `json:"runtime_contract"`
	ReasoningEffort              string `json:"reasoning_effort"`
	ReasoningContext             string `json:"reasoning_context"`
	RequestTimeoutMillis         int    `json:"request_timeout_millis"`
	DeveloperInstructionRevision string `json:"developer_instruction_revision"`
	AccountType                  string `json:"account_type"`
	AccountPlan                  string `json:"account_plan"`
	ThreadMode                   string `json:"thread_mode"`
	SandboxMode                  string `json:"sandbox_mode"`
	ApprovalPolicy               string `json:"approval_policy"`
	WorkdirMode                  string `json:"workdir_mode"`
	DynamicToolsMode             string `json:"dynamic_tools_mode"`
	MCPMode                      string `json:"mcp_mode"`
	CommandPolicy                string `json:"command_policy"`
	FileReadPolicy               string `json:"file_read_policy"`
	IsolationRevision            string `json:"isolation_revision"`
}

SubscriptionPolicy is the immutable, non-secret execution boundary for one Primary Channel. It records what Fort selected; readiness remains a live projection and is deliberately not part of this snapshot.

func (SubscriptionPolicy) Validate added in v1.0.4

func (p SubscriptionPolicy) Validate(authority string) error

type Target

type Target struct {
	ID            string           `json:"id"`
	TurnID        string           `json:"turn_id"`
	ParticipantID string           `json:"participant_id"`
	RunID         string           `json:"run_id"`
	Attempt       int              `json:"attempt"`
	State         TargetState      `json:"state"`
	ErrorCode     string           `json:"error_code,omitempty"`
	Error         string           `json:"error,omitempty"`
	Authority     *TargetAuthority `json:"authority,omitempty"`
	Receipt       *TargetReceipt   `json:"receipt,omitempty"`
	CreatedAt     time.Time        `json:"created_at"`
	UpdatedAt     time.Time        `json:"updated_at"`
}

type TargetAuthority added in v1.0.4

type TargetAuthority struct {
	Authority      string             `json:"authority"`
	Policy         SubscriptionPolicy `json:"policy"`
	RequestedModel string             `json:"requested_model"`
}

TargetAuthority records the exact authority selected before one target is committed. Legacy targets have no TargetAuthority.

func (TargetAuthority) Validate added in v1.0.4

func (a TargetAuthority) Validate() error

type TargetReceipt added in v1.0.4

type TargetReceipt struct {
	ObservedAdapterID               string `json:"observed_adapter_id,omitempty"`
	ObservedAdapterRevision         string `json:"observed_adapter_revision,omitempty"`
	ObservedCodexVersion            string `json:"observed_codex_version,omitempty"`
	ObservedCodexExecutableRevision string `json:"observed_codex_executable_revision,omitempty"`
	ObservedCodexSchemaRevision     string `json:"observed_codex_schema_revision,omitempty"`
	ResolvedModel                   string `json:"resolved_model,omitempty"`
	ProviderThreadID                string `json:"provider_thread_id,omitempty"`
	ProviderTerminalStatus          string `json:"provider_terminal_status,omitempty"`
	UsageSource                     string `json:"usage_source,omitempty"`
	InputTokens                     int64  `json:"input_tokens,omitempty"`
	CachedInputTokens               int64  `json:"cached_input_tokens,omitempty"`
	OutputTokens                    int64  `json:"output_tokens,omitempty"`
	ReasoningTokens                 int64  `json:"reasoning_tokens,omitempty"`
}

TargetReceipt is provider-observed terminal metadata. It is separate from the immutable selected authority and may be absent for legacy targets.

func (TargetReceipt) ValidateFor added in v1.0.4

func (r TargetReceipt) ValidateFor(authority TargetAuthority) error

type TargetState

type TargetState string
const (
	TargetQueued   TargetState = "queued"
	TargetWorking  TargetState = "working"
	TargetAnswered TargetState = "answered"
	TargetFailed   TargetState = "failed"
	TargetCanceled TargetState = "canceled"
)

type Turn

type Turn struct {
	ID               string    `json:"id"`
	ConversationID   string    `json:"conversation_id"`
	ClientTurnID     string    `json:"client_turn_id"`
	PromptMessageID  int64     `json:"prompt_message_id"`
	ThroughMessageID int64     `json:"through_message_id"`
	CreatedAt        time.Time `json:"created_at"`
	Created          bool      `json:"-"`
}

type TurnResult

type TurnResult struct {
	Turn    Turn     `json:"turn"`
	Targets []Target `json:"targets"`
}

Jump to

Keyboard shortcuts

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