contract

package
v1.10.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 57 Imported by: 0

Documentation

Overview

Package contract exposes Cortex through the Forge dashboard dispatcher.

Index

Constants

View Source
const ContributorName = "cortex"

Variables

This section is empty.

Functions

func NexusCatalogs

func NexusCatalogs(gw *nexus.Gateway, access CatalogAccess) map[string]CatalogQuery

NexusCatalogs retains provider failures instead of silently omitting models. Catalog metadata is distinct from the ability to make a remote completion.

func Register

func Register(d *dispatcher.Dispatcher, reg dc.Registry, wreg dc.WardenRegistry, deps Deps) error

func ShieldCatalogs

func ShieldCatalogs(eng *shieldengine.Engine, access CatalogAccess) map[string]CatalogQuery

ShieldCatalogs uses exact app/tenant filters and scans the complete scoped result before optional run filtering. Every storage error reaches the caller.

func WeaveCatalogs

func WeaveCatalogs(eng *weaveengine.Engine, access CatalogAccess) map[string]CatalogQuery

WeaveCatalogs runs every engine call under the scope's tenant and checks the row's app and tenant again before reading its statistics. Listing walks all pages and exposes only exact matches.

Types

type AgentPatch

type AgentPatch struct {
	Description     *string           `json:"description,omitempty"`
	SystemPrompt    *string           `json:"system_prompt,omitempty"`
	Model           *string           `json:"model,omitempty"`
	Tools           *[]string         `json:"tools,omitempty"`
	MaxSteps        *int              `json:"max_steps,omitempty"`
	MaxTokens       *int              `json:"max_tokens,omitempty"`
	Temperature     *float64          `json:"temperature,omitempty"`
	ReasoningLoop   *string           `json:"reasoning_loop,omitempty"`
	Guardrails      *map[string]any   `json:"guardrails,omitempty"`
	Metadata        *map[string]any   `json:"metadata,omitempty"`
	Enabled         *bool             `json:"enabled,omitempty"`
	PersonaRef      *string           `json:"persona_ref,omitempty"`
	InlineSkills    *[]string         `json:"inline_skills,omitempty"`
	InlineTraits    *[]string         `json:"inline_traits,omitempty"`
	InlineBehaviors *[]string         `json:"inline_behaviors,omitempty"`
	Sections        *[]prompt.Section `json:"sections,omitempty"`
}

type AuditEvent

type AuditEvent struct {
	At         time.Time    `json:"at"`
	Subject    string       `json:"subject"`
	Scope      cortex.Scope `json:"scope"`
	Action     string       `json:"action"`
	ResourceID string       `json:"resource_id,omitempty"`
	Outcome    string       `json:"outcome"`
}

type BehaviorPatch

type BehaviorPatch struct {
	Description   *string             `json:"description,omitempty"`
	Triggers      *[]behavior.Trigger `json:"triggers,omitempty"`
	Actions       *[]behavior.Action  `json:"actions,omitempty"`
	Priority      *int                `json:"priority,omitempty"`
	RequiresSkill *string             `json:"requires_skill,omitempty"`
	RequiresTrait *string             `json:"requires_trait,omitempty"`
	Metadata      *map[string]any     `json:"metadata,omitempty"`
}

type CatalogAccess

type CatalogAccess func(context.Context, string) (CatalogScope, error)

type CatalogInput

type CatalogInput struct {
	ListInput
	ID       string `json:"id"`
	Provider string `json:"provider"`
	RunID    string `json:"run_id"`
}

type CatalogQuery

type CatalogQuery func(context.Context, map[string]any) (any, error)

CatalogQuery must enforce its own external system's authorized scope. The context already carries the resolved Cortex scope and authenticated principal. Returning unavailable is distinct from an installed provider with zero rows.

type CatalogScope

type CatalogScope struct {
	AppID    string
	TenantID string
}

CatalogScope is resolved by the host from the Cortex principal and scope. External identifiers need not equal Cortex hierarchy values. Empty identifiers are refused, because those services interpret empty filters as every tenant.

type CloneInput

type CloneInput struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type CreateInput

type CreateInput[T any] struct {
	Data T `json:"data"`
}

type DecisionInput

type DecisionInput struct {
	ID       string `json:"id"`
	Approved bool   `json:"approved"`
	Reason   string `json:"reason"`
}

type Deps

type Deps struct {
	Engine         *engine.Engine
	AdaptiveReview *engine.AdaptiveReviewer
	Learning       *learning.Guard
	Planning       *coordination.PlanningOperator
	// ExecutionBudget supplies host-owned cumulative limits before preparation.
	// The callback receives a detached effective agent. Client limits can only
	// narrow its result; clients cannot supply their own deadline authority.
	ExecutionBudget func(context.Context, *agent.Config) (execution.Budget, error)
	// AgentMutationFence serializes dashboard agent writes with host policy reads.
	// The host must hold current authority until its synchronous callback returns.
	// Other agent writers must participate in the same host fence.
	AgentMutationFence func(context.Context, func(context.Context) error) error
	Optimization       *optimization.Optimizer
	DefaultScope       cortex.Scope
	ResolveScope       func(context.Context, dc.Principal) (cortex.Scope, error)
	Audit              func(context.Context, AuditEvent) error
	ExecutionLabel     string
	Catalogs           map[string]CatalogQuery
}

Deps lets the host supply its scope mapping and durable audit recorder. DefaultScope is only for an explicitly single-scope dashboard deployment. A present but invalid claim never falls back to it.

type ExecuteInput

type ExecuteInput struct {
	ID        string    `json:"id"`
	Input     string    `json:"input"`
	SessionID string    `json:"session_id"`
	Overrides Overrides `json:"overrides"`
}

type IDInput

type IDInput struct {
	ID string `json:"id"`
}

type ListInput

type ListInput struct {
	Search string `json:"search"`
	Limit  int    `json:"limit"`
	Offset int    `json:"offset"`
	Exact  bool   `json:"exact"`
}

type ListOutput

type ListOutput[T any] struct {
	Items  []*T  `json:"items"`
	Total  int64 `json:"total"`
	Limit  int   `json:"limit"`
	Offset int   `json:"offset"`
}

type MemoryInput

type MemoryInput struct {
	ID    string `json:"id"`
	Limit int    `json:"limit"`
}

type MemoryOutput

type MemoryOutput struct {
	Session  *session.Session `json:"session"`
	Messages []memory.Message `json:"messages"`
	Complete bool             `json:"complete"`
}

type OrchestrationPatch

type OrchestrationPatch struct {
	Description  *string                      `json:"description,omitempty"`
	Strategy     *string                      `json:"strategy,omitempty"`
	Participants *[]orchestration.Participant `json:"participants,omitempty"`
	Settings     *orchestration.Settings      `json:"settings,omitempty"`
	Metadata     *map[string]any              `json:"metadata,omitempty"`
}

type OverlayListInput

type OverlayListInput struct {
	ListInput
	AgentID string `json:"agent_id"`
}

type OverlaySaveInput

type OverlaySaveInput struct {
	ID           string         `json:"id"`
	AgentID      string         `json:"agent_id"`
	Patches      []prompt.Patch `json:"patches"`
	ToolsAdded   []string       `json:"tools_added"`
	ToolsRemoved []string       `json:"tools_removed"`
	Model        string         `json:"model"`
	Temperature  *float64       `json:"temperature"`
	MaxTokens    *int           `json:"max_tokens"`
}

type Overrides

type Overrides struct {
	Model        string   `json:"model"`
	Temperature  *float64 `json:"temperature"`
	MaxSteps     int      `json:"max_steps"`
	MaxTokens    int      `json:"max_tokens"`
	SystemPrompt string   `json:"system_prompt"`
	PersonaRef   string   `json:"persona_ref"`
	InlineSkills []string `json:"inline_skills"`
	InlineTraits []string `json:"inline_traits"`
	Tools        []string `json:"tools"`
}

type PersonaPatch

type PersonaPatch struct {
	Description        *string                    `json:"description,omitempty"`
	Identity           *string                    `json:"identity,omitempty"`
	Skills             *[]persona.SkillAssignment `json:"skills,omitempty"`
	Traits             *[]persona.TraitAssignment `json:"traits,omitempty"`
	Behaviors          *[]string                  `json:"behaviors,omitempty"`
	CognitiveStyle     *cognitive.Style           `json:"cognitive_style,omitempty"`
	CommunicationStyle *communication.Style       `json:"communication_style,omitempty"`
	Perception         *perception.Model          `json:"perception,omitempty"`
	Metadata           *map[string]any            `json:"metadata,omitempty"`
}

type Reference

type Reference struct {
	ID    string       `json:"id"`
	Name  string       `json:"name"`
	Scope cortex.Scope `json:"scope"`
}

type ReferenceInput

type ReferenceInput struct {
	ListInput
	Kind      string `json:"kind"`
	OwnerKind string `json:"owner_kind"`
	OwnerID   string `json:"owner_id"`
}

type ReplayInput

type ReplayInput struct {
	ID    string `json:"id"`
	After string `json:"after"`
	Limit int    `json:"limit"`
}

ReplayInput uses durable run-bound cursors, independent of runs.events offsets.

type ResultContentInput

type ResultContentInput struct {
	ID       string `json:"id"`
	ResultID string `json:"result_id"`
}

ResultContentInput selects a committed result without carrying private evidence.

type ResumeInput

type ResumeInput struct {
	ID          string              `json:"id"`
	ToolResults []engine.ToolResult `json:"tool_results"`
}

type RunDetail

type RunDetail struct {
	Suspension *SuspensionView            `json:"suspension,omitempty"`
	Run        *run.Run                   `json:"run"`
	Steps      []*run.Step                `json:"steps"`
	ToolCalls  map[string][]*run.ToolCall `json:"tool_calls"`
}

type RunListInput

type RunListInput struct {
	ListInput
	AgentID string    `json:"agent_id"`
	State   run.State `json:"state"`
}

type SendInput

type SendInput struct {
	ReceiverID     string `json:"receiver_id"`
	ConversationID string `json:"conversation_id"`
	Content        string `json:"content"`
	InReplyTo      string `json:"in_reply_to"`
}

type SessionCreate

type SessionCreate struct {
	AgentID string `json:"agent_id"`
	Title   string `json:"title"`
}

type SessionListInput

type SessionListInput struct {
	ListInput
	AgentID string `json:"agent_id"`
}

type SessionUpdate

type SessionUpdate struct {
	ID       string          `json:"id"`
	Title    *string         `json:"title"`
	Metadata *map[string]any `json:"metadata"`
}

type SkillPatch

type SkillPatch struct {
	Description          *string               `json:"description,omitempty"`
	Tools                *[]skill.ToolBinding  `json:"tools,omitempty"`
	Knowledge            *[]skill.KnowledgeRef `json:"knowledge,omitempty"`
	SystemPromptFragment *string               `json:"system_prompt_fragment,omitempty"`
	Dependencies         *[]string             `json:"dependencies,omitempty"`
	DefaultProficiency   *skill.Proficiency    `json:"default_proficiency,omitempty"`
	Metadata             *map[string]any       `json:"metadata,omitempty"`
}

type StreamInput

type StreamInput struct {
	ID    string `json:"id"`
	After int    `json:"after"`
}

type StreamOutput

type StreamOutput struct {
	Events    []engine.StreamEvent `json:"events"`
	Next      int                  `json:"next"`
	Lost      bool                 `json:"lost"`
	Done      bool                 `json:"done"`
	Available bool                 `json:"available"`
}

type SuspensionView

type SuspensionView struct {
	Reason  suspension.SuspendReason `json:"reason"`
	Pending []suspension.PendingCall `json:"pending"`
}

type TraitPatch

type TraitPatch struct {
	Description *string            `json:"description,omitempty"`
	Dimensions  *[]trait.Dimension `json:"dimensions,omitempty"`
	Influences  *[]trait.Influence `json:"influences,omitempty"`
	Category    *trait.Category    `json:"category,omitempty"`
	Metadata    *map[string]any    `json:"metadata,omitempty"`
}

type UpdateInput

type UpdateInput[P any] struct {
	ID    string `json:"id"`
	Patch P      `json:"patch"`
}

Jump to

Keyboard shortcuts

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