Documentation
¶
Index ¶
- Constants
- Variables
- func BuildSkillsIndex(skillsDir string) (string, error)
- func BuiltinBashSession(args map[string]any, config map[string]any) (string, error)
- func BuiltinConfiguredHandlers() map[string]ConfiguredToolHandler
- func BuiltinEditFile(args map[string]any) (string, error)
- func BuiltinFetchURL(args map[string]any) (string, error)
- func BuiltinGlob(args map[string]any) (string, error)
- func BuiltinGrep(args map[string]any) (string, error)
- func BuiltinHandlers() map[string]ToolHandler
- func BuiltinListDir(args map[string]any) (string, error)
- func BuiltinLoadSkill(args map[string]any, config map[string]any) (string, error)
- func BuiltinReadFile(args map[string]any) (string, error)
- func BuiltinRunShell(args map[string]any) (string, error)
- func BuiltinWriteFile(args map[string]any) (string, error)
- func CanonicalizeJCSV1JSON(data []byte, excludeKeys ...string) ([]byte, error)
- func CapabilityManifestRef(manifest any) (string, error)
- func ContentBlockForFile(path string) (map[string]any, error)
- func ContentBlocksForInput(text string, paths []string) ([]map[string]any, error)
- func ContentHashForEventRow(row EventRow) (string, error)
- func ContentHashForEventRowJSON(data []byte) (string, error)
- func DefaultAttachmentRoot(sessionPath string) string
- func DelegationTree(sessionID string, resolver SessionResolver) (map[string]any, error)
- func DescendantTimeline(sessionID string, resolver SessionResolver) ([]map[string]any, error)
- func DescendantUsage(sessionID string, resolver SessionResolver) (map[string]any, error)
- func EnsureSQLStorageSchema(db *sql.DB, opts SQLStorageOptions) error
- func ListReferencedAttachments(log *Log) []string
- func ManifestSnapshotMetadata(registry *Registry, skills any, mcp any) map[string]any
- func NormalizeUsage(value any) map[string]any
- func OpenChildren(sessionID string, resolver SessionResolver) ([]string, error)
- func ParseSkillFile(path string) (map[string]any, string, error)
- func ParseSkillFrontmatter(raw string) map[string]any
- func TranscriptProject(log *Log, options TranscriptOptions) []map[string]any
- func ValidSkillName(name string) bool
- func ValidateManifest(manifest Manifest) error
- func VerifySessionPortable(s *Session) error
- type Agent
- type AgentLoop
- type AlwaysAllow
- type AnthropicIngestor
- type AnthropicProjection
- type AnthropicProvider
- type AnthropicStreamProvider
- type ApprovalHandler
- type AttachmentReference
- type AttachmentStore
- type BashSessionRegistry
- type CapabilityManifestStore
- type CapabilityMismatchError
- type ConfiguredToolHandler
- type ContextualToolHandler
- type CostBudgetGuard
- type CostTracker
- type CredentialProxy
- type CredentialProxyCredential
- type CredentialProxyInject
- type CredentialProxyMatch
- type CredentialProxyRoute
- type DeltaLogger
- type DenyByName
- type Event
- type EventArgs
- type EventDraft
- type EventRow
- type EventType
- type FileStorageAdapter
- func (a *FileStorageAdapter) AppendEvent(draft EventDraft, expectedNextSeq *int) (EventRow, error)
- func (a *FileStorageAdapter) EventsSince(cursor *int) ([]EventRow, error)
- func (a *FileStorageAdapter) LoadSession() (*SessionHeader, error)
- func (a *FileStorageAdapter) SaveHeader(header SessionHeader) error
- type FilesystemStore
- func (s *FilesystemStore) Delete(uri string) error
- func (s *FilesystemStore) Exists(uri string) bool
- func (s *FilesystemStore) Get(uri string) ([]byte, string, error)
- func (s *FilesystemStore) ListReferenced(log *Log) []string
- func (s *FilesystemStore) Put(data []byte, mediaType string) (AttachmentReference, error)
- type GeminiIngestor
- type GeminiProjection
- type GeminiProvider
- type GeminiStreamProvider
- type HTTPDoer
- type HTTPError
- type HealthGuard
- type HookErrorPolicy
- type HookHandler
- type HookInstallation
- type HookOptions
- type HookSpec
- type Hooks
- func (h *Hooks) Handlers() map[string][]HookHandler
- func (h *Hooks) Invoke(point string, ctx map[string]any) []any
- func (h *Hooks) Off(point string, handler HookHandler)
- func (h *Hooks) On(point string, handler HookHandler) HookHandler
- func (h *Hooks) OnWithOptions(point string, handler HookHandler, options HookOptions) HookHandler
- func (h *Hooks) Reset()
- type HumanApproval
- type Ingestor
- type InlineStore
- type LoadedManifest
- type Log
- type Manifest
- type ManifestError
- type ManifestOptions
- type MarkerTail
- type MemoryCapabilityManifestStore
- type MemoryStorageAdapter
- func (a *MemoryStorageAdapter) AppendEvent(draft EventDraft, expectedNextSeq *int) (EventRow, error)
- func (a *MemoryStorageAdapter) EventsSince(cursor *int) ([]EventRow, error)
- func (a *MemoryStorageAdapter) LoadSession() (*SessionHeader, error)
- func (a *MemoryStorageAdapter) SaveHeader(header SessionHeader) error
- type MemoryStore
- type MockProvider
- type NamedStrategyInstallation
- type NetworkSandbox
- type Observation
- type ObservationCollector
- type ObservationSubscriber
- type ObservedEvent
- type OllamaProvider
- type OllamaStreamProvider
- type OpenAIIngestor
- type OpenAIProjection
- type OpenAIProvider
- type OpenAIStreamProvider
- type Projection
- type Provider
- type ProviderError
- type ProviderSpec
- type RateLimiter
- type Registry
- func BuildRegistry(specs []ToolSpec, handlers map[string]ToolHandler) (*Registry, error)
- func BuildRegistryWithConfigured(specs []ToolSpec, handlers map[string]ToolHandler, ...) (*Registry, error)
- func BuildRegistryWithContextual(specs []ToolSpec, handlers map[string]ToolHandler, ...) (*Registry, error)
- func NewRegistry() *Registry
- type RepetitionGuard
- type Response
- type RetryDecision
- type RetryPolicy
- type Runner
- type Runtime
- type RuntimeConfig
- type SQLStorageAdapter
- func (a *SQLStorageAdapter) AppendEvent(draft EventDraft, expectedNextSeq *int) (EventRow, error)
- func (a *SQLStorageAdapter) EventsSince(cursor *int) ([]EventRow, error)
- func (a *SQLStorageAdapter) LoadSession() (*SessionHeader, error)
- func (a *SQLStorageAdapter) SaveHeader(header SessionHeader) error
- type SQLStorageDialect
- type SQLStorageOptions
- type Session
- type SessionHeader
- type SessionMap
- type SessionResolver
- type SkillEntry
- type StaleReadGuard
- type StorageAdapter
- type StorageConflictError
- type StrategyInstallation
- type StrategySpec
- type StreamProvider
- type SummaryTail
- type TimeoutGuard
- type TokenMarkerTail
- type Tool
- type ToolContext
- type ToolHandler
- type ToolHandlerV2
- type ToolOutputCap
- type ToolSpec
- type TranscriptOptions
- type TurnFailed
- type UnknownProviderError
- type UnknownStrategyError
- type UnresolvedHandlerError
- type UnsupportedVersionError
- type ValidationError
- type WriteSandbox
Constants ¶
const ( DefaultShellTimeoutSeconds = 30 GrepMaxMatches = 200 MaxFetchBytes = 256 * 1024 )
const ( AnthropicEndpoint = "https://api.anthropic.com/v1/messages" AnthropicAPIVersion = "2023-06-01" OpenAIEndpoint = "https://api.openai.com/v1/chat/completions" OllamaBaseURL = "http://localhost:11434/v1" GeminiEndpointBase = "https://generativelanguage.googleapis.com/v1beta/models" GeminiGenerateContent = "generateContent" )
const DefaultBashSessionMaxOutputBytes = 64 * 1024
const StorageConflictReason = "storage_conflict"
const SupportedManifestVersion = "0.1"
Variables ¶
var DefaultAttachmentHTTPTimeout = 60 * time.Second
var DefaultFetchURLTimeout = 60 * time.Second
var DefaultProviderHTTPTimeout = 60 * time.Second
var ErrInvalidUnicode = errors.New("invalid_unicode")
Functions ¶
func BuildSkillsIndex ¶ added in v0.10.0
func BuiltinBashSession ¶ added in v0.11.0
func BuiltinConfiguredHandlers ¶ added in v0.10.0
func BuiltinConfiguredHandlers() map[string]ConfiguredToolHandler
func BuiltinHandlers ¶ added in v0.5.0
func BuiltinHandlers() map[string]ToolHandler
func BuiltinLoadSkill ¶ added in v0.10.0
func CanonicalizeJCSV1JSON ¶ added in v0.20.1
func CapabilityManifestRef ¶ added in v0.18.0
func ContentBlockForFile ¶ added in v0.17.0
func ContentBlocksForInput ¶ added in v0.17.0
func ContentHashForEventRow ¶ added in v0.20.1
func ContentHashForEventRowJSON ¶ added in v0.20.1
func DefaultAttachmentRoot ¶ added in v0.17.0
func DelegationTree ¶ added in v0.18.0
func DelegationTree(sessionID string, resolver SessionResolver) (map[string]any, error)
func DescendantTimeline ¶ added in v0.18.0
func DescendantTimeline(sessionID string, resolver SessionResolver) ([]map[string]any, error)
func DescendantUsage ¶ added in v0.18.0
func DescendantUsage(sessionID string, resolver SessionResolver) (map[string]any, error)
func EnsureSQLStorageSchema ¶ added in v0.20.1
func EnsureSQLStorageSchema(db *sql.DB, opts SQLStorageOptions) error
func ListReferencedAttachments ¶ added in v0.17.0
func ManifestSnapshotMetadata ¶ added in v0.11.0
ManifestSnapshotMetadata packages dynamic descriptors for Session metadata.
func NormalizeUsage ¶ added in v0.19.0
func OpenChildren ¶ added in v0.18.0
func OpenChildren(sessionID string, resolver SessionResolver) ([]string, error)
func ParseSkillFile ¶ added in v0.10.0
func ParseSkillFrontmatter ¶ added in v0.10.0
func TranscriptProject ¶ added in v0.11.0
func TranscriptProject(log *Log, options TranscriptOptions) []map[string]any
TranscriptProject returns a UI-neutral semantic view of a Log.
func ValidSkillName ¶ added in v0.10.0
func ValidateManifest ¶ added in v0.5.0
func VerifySessionPortable ¶ added in v0.20.1
VerifySessionPortable checks that a Session satisfies the cross-implementation portability invariants the storage adapters maintain automatically:
- sequence numbers are dense and monotonic from 0,
- every event payload is canonical-JSON (harnas-jcs-v1) encodable, so a per-event content hash is computable, and
- the Session round-trips losslessly through canonical JSONL.
A Session that fails any check has been persisted or mutated in a way that breaks portability to other Harnas implementations. This is the symptom of hand-rolled persistence that bypasses the storage adapter — a footgun that no conformance fixture catches, because it is the *absence* of adapter use.
Run it in CI on a representative Session produced by your integration, as an acceptance gate before relying on cross-implementation portability.
Types ¶
type Agent ¶ added in v0.5.0
type Agent struct {
Name string
Session *Session
Loaded *LoadedManifest
}
func AgentFromManifest ¶ added in v0.5.0
func AgentFromManifest(path string, options ManifestOptions) (*Agent, error)
func AgentFromSession ¶ added in v0.5.0
func AgentFromSession(session *Session, path string, options ManifestOptions) (*Agent, error)
func (*Agent) ChatPayload ¶ added in v0.17.0
type AgentLoop ¶
type AgentLoop struct {
Session *Session
Projection Projection
Provider Provider
ProviderKind string
Ingestor Ingestor
StreamProvider StreamProvider
Runner *Runner
RetryPolicy *RetryPolicy
MaxTurns int
OnStreamEvent func(Event)
}
type AlwaysAllow ¶ added in v0.5.0
type AlwaysAllow struct{}
func (AlwaysAllow) Install ¶ added in v0.5.0
func (a AlwaysAllow) Install(session *Session)
type AnthropicIngestor ¶
type AnthropicIngestor struct{}
type AnthropicProjection ¶
type AnthropicProvider ¶ added in v0.5.0
func NewAnthropicProvider ¶ added in v0.5.0
func NewAnthropicProvider(apiKey string) AnthropicProvider
type AnthropicStreamProvider ¶ added in v0.5.0
type AnthropicStreamProvider struct {
APIKey string
APIVersion string
Endpoint string
Client HTTPDoer
}
func NewAnthropicStreamProvider ¶ added in v0.5.0
func NewAnthropicStreamProvider(apiKey string) AnthropicStreamProvider
type ApprovalHandler ¶ added in v0.5.0
type AttachmentReference ¶ added in v0.17.0
type AttachmentStore ¶ added in v0.17.0
type BashSessionRegistry ¶ added in v0.11.0
type BashSessionRegistry struct {
// contains filtered or unexported fields
}
func NewBashSessionRegistry ¶ added in v0.11.0
func NewBashSessionRegistry() *BashSessionRegistry
func (*BashSessionRegistry) Close ¶ added in v0.11.0
func (r *BashSessionRegistry) Close()
type CapabilityManifestStore ¶ added in v0.18.0
type CapabilityMismatchError ¶ added in v0.17.0
func (CapabilityMismatchError) Error ¶ added in v0.17.0
func (e CapabilityMismatchError) Error() string
type ConfiguredToolHandler ¶ added in v0.9.1
type ContextualToolHandler ¶ added in v0.19.5
type ContextualToolHandler func(map[string]any, ToolContext) (string, error)
type CostBudgetGuard ¶ added in v0.12.0
func (CostBudgetGuard) Install ¶ added in v0.12.0
func (c CostBudgetGuard) Install(session *Session)
type CostTracker ¶ added in v0.9.0
type CostTracker struct {
InputTokens int
OutputTokens int
Turns int
// contains filtered or unexported fields
}
func NewCostTracker ¶ added in v0.9.0
func NewCostTracker(observation *Observation, threshold int, onThreshold func(map[string]int)) *CostTracker
func (*CostTracker) Call ¶ added in v0.9.0
func (c *CostTracker) Call(eventName string, payload map[string]any)
func (*CostTracker) TotalTokens ¶ added in v0.9.0
func (c *CostTracker) TotalTokens() int
func (*CostTracker) Usage ¶ added in v0.9.0
func (c *CostTracker) Usage() map[string]int
type CredentialProxy ¶ added in v0.16.0
type CredentialProxy struct {
Credentials map[string]CredentialProxyCredential
Routes []CredentialProxyRoute
}
func NewCredentialProxy ¶ added in v0.16.0
func NewCredentialProxy(config map[string]any) (CredentialProxy, error)
func (CredentialProxy) Install ¶ added in v0.16.0
func (c CredentialProxy) Install(session *Session)
type CredentialProxyCredential ¶ added in v0.16.0
func (CredentialProxyCredential) Resolve ¶ added in v0.16.0
func (c CredentialProxyCredential) Resolve() (string, bool)
type CredentialProxyInject ¶ added in v0.16.0
type CredentialProxyMatch ¶ added in v0.16.0
type CredentialProxyRoute ¶ added in v0.16.0
type CredentialProxyRoute struct {
Tool string
Match CredentialProxyMatch
Inject CredentialProxyInject
Index int
}
type DeltaLogger ¶ added in v0.8.0
type DeltaLogger struct {
// contains filtered or unexported fields
}
func NewDeltaLogger ¶ added in v0.8.0
func NewDeltaLogger(path string, observation *Observation) *DeltaLogger
type DenyByName ¶
func (DenyByName) Install ¶
func (d DenyByName) Install(session *Session)
type Event ¶
type Event struct {
ID string `json:"-"`
Seq int `json:"seq"`
Timestamp string `json:"timestamp,omitempty"`
Type EventType `json:"type"`
Payload map[string]any `json:"payload"`
}
func ApplyMutations ¶
type EventDraft ¶ added in v0.20.1
type EventType ¶
type EventType string
const ( EventUserMessage EventType = "user_message" EventAssistantMessage EventType = "assistant_message" EventToolUse EventType = "tool_use" EventToolResult EventType = "tool_result" EventCompact EventType = "compact" EventRevert EventType = "revert" EventSummary EventType = "summary" EventAnnotation EventType = "annotation" EventProviderError EventType = "provider_error" EventRuntimeError EventType = "runtime_error" EventAgentSpawn EventType = "agent_spawn" EventAgentStatus EventType = "agent_status" EventAgentResult EventType = "agent_result" EventAssistantTurnStarted EventType = "assistant_turn_started" EventAssistantTextDelta EventType = "assistant_text_delta" EventToolUseBegin EventType = "tool_use_begin" EventToolUseArgumentDelta EventType = "tool_use_argument_delta" EventToolUseEnd EventType = "tool_use_end" EventAssistantTurnDone EventType = "assistant_turn_completed" EventAssistantTurnFailed EventType = "assistant_turn_failed" )
type FileStorageAdapter ¶ added in v0.20.1
type FileStorageAdapter struct {
// contains filtered or unexported fields
}
func NewFileStorageAdapter ¶ added in v0.20.1
func NewFileStorageAdapter(path string) *FileStorageAdapter
func (*FileStorageAdapter) AppendEvent ¶ added in v0.20.1
func (a *FileStorageAdapter) AppendEvent(draft EventDraft, expectedNextSeq *int) (EventRow, error)
func (*FileStorageAdapter) EventsSince ¶ added in v0.20.1
func (a *FileStorageAdapter) EventsSince(cursor *int) ([]EventRow, error)
func (*FileStorageAdapter) LoadSession ¶ added in v0.20.1
func (a *FileStorageAdapter) LoadSession() (*SessionHeader, error)
func (*FileStorageAdapter) SaveHeader ¶ added in v0.20.1
func (a *FileStorageAdapter) SaveHeader(header SessionHeader) error
type FilesystemStore ¶ added in v0.17.0
type FilesystemStore struct {
Root string
}
func NewFilesystemStore ¶ added in v0.17.0
func NewFilesystemStore(root string) *FilesystemStore
func (*FilesystemStore) Delete ¶ added in v0.17.0
func (s *FilesystemStore) Delete(uri string) error
func (*FilesystemStore) Exists ¶ added in v0.17.0
func (s *FilesystemStore) Exists(uri string) bool
func (*FilesystemStore) Get ¶ added in v0.17.0
func (s *FilesystemStore) Get(uri string) ([]byte, string, error)
func (*FilesystemStore) ListReferenced ¶ added in v0.17.0
func (s *FilesystemStore) ListReferenced(log *Log) []string
func (*FilesystemStore) Put ¶ added in v0.17.0
func (s *FilesystemStore) Put(data []byte, mediaType string) (AttachmentReference, error)
type GeminiIngestor ¶
type GeminiIngestor struct {
// contains filtered or unexported fields
}
type GeminiProjection ¶
type GeminiProvider ¶ added in v0.5.0
func NewGeminiProvider ¶ added in v0.5.0
func NewGeminiProvider(apiKey string) GeminiProvider
type GeminiStreamProvider ¶ added in v0.5.0
func NewGeminiStreamProvider ¶ added in v0.5.0
func NewGeminiStreamProvider(apiKey string) GeminiStreamProvider
type HTTPError ¶ added in v0.5.0
func (HTTPError) HTTPStatus ¶ added in v0.5.0
type HealthGuard ¶ added in v0.13.0
func (HealthGuard) Install ¶ added in v0.13.0
func (h HealthGuard) Install(session *Session)
type HookErrorPolicy ¶ added in v0.9.0
type HookErrorPolicy string
const ( HookErrorIsolate HookErrorPolicy = "isolate" HookErrorFailTurn HookErrorPolicy = "fail_turn" )
type HookHandler ¶
type HookInstallation ¶ added in v0.9.0
type HookInstallation struct {
Point string
Name string
Handler HookHandler
Config map[string]any
OnError string
}
func BuildHooks ¶ added in v0.9.0
func BuildHooks(specs []HookSpec, handlers map[string]HookHandler) ([]HookInstallation, error)
func (HookInstallation) Install ¶ added in v0.9.0
func (h HookInstallation) Install(session *Session)
type HookOptions ¶ added in v0.9.0
type HookOptions struct {
OnError HookErrorPolicy
Name string
Source string
}
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
func (*Hooks) Handlers ¶ added in v0.9.0
func (h *Hooks) Handlers() map[string][]HookHandler
func (*Hooks) Off ¶ added in v0.5.0
func (h *Hooks) Off(point string, handler HookHandler)
func (*Hooks) On ¶
func (h *Hooks) On(point string, handler HookHandler) HookHandler
func (*Hooks) OnWithOptions ¶ added in v0.9.0
func (h *Hooks) OnWithOptions(point string, handler HookHandler, options HookOptions) HookHandler
type HumanApproval ¶ added in v0.5.0
func (HumanApproval) Install ¶ added in v0.5.0
func (h HumanApproval) Install(session *Session)
type Ingestor ¶
func IngestorFor ¶ added in v0.5.0
type InlineStore ¶ added in v0.17.0
type InlineStore struct{}
func (InlineStore) Delete ¶ added in v0.17.0
func (InlineStore) Delete(_ string) error
func (InlineStore) Exists ¶ added in v0.17.0
func (InlineStore) Exists(_ string) bool
func (InlineStore) ListReferenced ¶ added in v0.17.0
func (InlineStore) ListReferenced(log *Log) []string
func (InlineStore) Put ¶ added in v0.17.0
func (InlineStore) Put(data []byte, mediaType string) (AttachmentReference, error)
type LoadedManifest ¶ added in v0.5.0
type LoadedManifest struct {
Name string
Session *Session
Projection Projection
Provider Provider
ProviderKind string
StreamProvider StreamProvider
Ingestor Ingestor
Registry *Registry
Strategies []StrategyInstallation
Hooks []HookInstallation
}
func BuildManifest ¶ added in v0.5.0
func BuildManifest(manifest Manifest, options ManifestOptions) (*LoadedManifest, error)
func LoadManifest ¶ added in v0.5.0
func LoadManifest(source string, options ManifestOptions) (*LoadedManifest, error)
func (*LoadedManifest) InstallStrategies ¶ added in v0.5.0
func (l *LoadedManifest) InstallStrategies()
func (*LoadedManifest) Loop ¶ added in v0.5.0
func (l *LoadedManifest) Loop() AgentLoop
func (*LoadedManifest) Runner ¶ added in v0.5.0
func (l *LoadedManifest) Runner() *Runner
type Log ¶
type Log struct {
Observation *Observation
// contains filtered or unexported fields
}
func (*Log) LastAssistantMessage ¶
type Manifest ¶ added in v0.5.0
type Manifest struct {
Version string `json:"harnas_version"`
FixtureVersionAdded string `json:"fixture_version_added,omitempty"`
Name string `json:"name"`
System string `json:"system,omitempty"`
Provider ProviderSpec `json:"provider"`
Tools []ToolSpec `json:"tools"`
Strategies []StrategySpec `json:"strategies"`
Hooks []HookSpec `json:"hooks,omitempty"`
}
func ManifestFromMap ¶ added in v0.18.1
func ReadManifest ¶ added in v0.5.0
type ManifestError ¶ added in v0.5.0
type ManifestError struct {
Message string
}
func (ManifestError) Error ¶ added in v0.5.0
func (e ManifestError) Error() string
type ManifestOptions ¶ added in v0.5.0
type ManifestOptions struct {
ToolHandlers map[string]ToolHandler
ConfiguredHandlers map[string]ConfiguredToolHandler
ContextualHandlers map[string]ContextualToolHandler
StrategyHandlers map[string]ApprovalHandler
HookHandlers map[string]HookHandler
Providers map[string]Provider
StreamProviders map[string]StreamProvider
APIKeys map[string]string
AttachmentStore AttachmentStore
}
type MarkerTail ¶
func (MarkerTail) Install ¶
func (m MarkerTail) Install(session *Session)
func (MarkerTail) OnPreProjection ¶
func (m MarkerTail) OnPreProjection(session *Session)
type MemoryCapabilityManifestStore ¶ added in v0.18.0
type MemoryCapabilityManifestStore struct {
// contains filtered or unexported fields
}
func NewMemoryCapabilityManifestStore ¶ added in v0.18.0
func NewMemoryCapabilityManifestStore() *MemoryCapabilityManifestStore
type MemoryStorageAdapter ¶ added in v0.20.1
type MemoryStorageAdapter struct {
// contains filtered or unexported fields
}
func NewMemoryStorageAdapter ¶ added in v0.20.1
func NewMemoryStorageAdapter() *MemoryStorageAdapter
func (*MemoryStorageAdapter) AppendEvent ¶ added in v0.20.1
func (a *MemoryStorageAdapter) AppendEvent(draft EventDraft, expectedNextSeq *int) (EventRow, error)
func (*MemoryStorageAdapter) EventsSince ¶ added in v0.20.1
func (a *MemoryStorageAdapter) EventsSince(cursor *int) ([]EventRow, error)
func (*MemoryStorageAdapter) LoadSession ¶ added in v0.20.1
func (a *MemoryStorageAdapter) LoadSession() (*SessionHeader, error)
func (*MemoryStorageAdapter) SaveHeader ¶ added in v0.20.1
func (a *MemoryStorageAdapter) SaveHeader(header SessionHeader) error
type MemoryStore ¶ added in v0.17.0
type MemoryStore struct {
// contains filtered or unexported fields
}
func NewMemoryStore ¶ added in v0.17.0
func NewMemoryStore() *MemoryStore
func (*MemoryStore) Delete ¶ added in v0.17.0
func (s *MemoryStore) Delete(uri string) error
func (*MemoryStore) Exists ¶ added in v0.17.0
func (s *MemoryStore) Exists(uri string) bool
func (*MemoryStore) Get ¶ added in v0.17.0
func (s *MemoryStore) Get(uri string) ([]byte, string, error)
func (*MemoryStore) ListReferenced ¶ added in v0.17.0
func (s *MemoryStore) ListReferenced(log *Log) []string
func (*MemoryStore) Put ¶ added in v0.17.0
func (s *MemoryStore) Put(data []byte, mediaType string) (AttachmentReference, error)
type MockProvider ¶ added in v0.5.0
type MockProvider struct {
Text string
}
type NamedStrategyInstallation ¶ added in v0.9.0
type NamedStrategyInstallation struct {
Name string
OnError string
Inner StrategyInstallation
}
func (NamedStrategyInstallation) Install ¶ added in v0.9.0
func (n NamedStrategyInstallation) Install(session *Session)
type NetworkSandbox ¶ added in v0.14.0
func (NetworkSandbox) Install ¶ added in v0.14.0
func (n NetworkSandbox) Install(session *Session)
type Observation ¶ added in v0.5.0
type Observation struct {
// contains filtered or unexported fields
}
func NewObservation ¶ added in v0.5.0
func NewObservation() *Observation
func (*Observation) Emit ¶ added in v0.5.0
func (o *Observation) Emit(event string, payload map[string]any)
func (*Observation) Reset ¶ added in v0.5.0
func (o *Observation) Reset()
func (*Observation) Subscribe ¶ added in v0.5.0
func (o *Observation) Subscribe(subscriber ObservationSubscriber) ObservationSubscriber
func (*Observation) Unsubscribe ¶ added in v0.5.0
func (o *Observation) Unsubscribe(subscriber ObservationSubscriber)
type ObservationCollector ¶ added in v0.5.0
type ObservationCollector struct {
Events []ObservedEvent
}
func NewObservationCollector ¶ added in v0.5.0
func NewObservationCollector() *ObservationCollector
func (*ObservationCollector) Call ¶ added in v0.5.0
func (c *ObservationCollector) Call(event string, payload map[string]any)
func (*ObservationCollector) Count ¶ added in v0.5.0
func (c *ObservationCollector) Count(event string) int
func (*ObservationCollector) Of ¶ added in v0.5.0
func (c *ObservationCollector) Of(event string) []ObservedEvent
func (*ObservationCollector) Reset ¶ added in v0.5.0
func (c *ObservationCollector) Reset()
type ObservationSubscriber ¶ added in v0.5.0
type ObservedEvent ¶ added in v0.5.0
type OllamaProvider ¶ added in v0.13.0
func NewOllamaProvider ¶ added in v0.13.0
func NewOllamaProvider(baseURL string) OllamaProvider
type OllamaStreamProvider ¶ added in v0.13.0
func NewOllamaStreamProvider ¶ added in v0.13.0
func NewOllamaStreamProvider(baseURL string) OllamaStreamProvider
type OpenAIIngestor ¶
type OpenAIIngestor struct{}
type OpenAIProjection ¶
type OpenAIProvider ¶ added in v0.5.0
func NewOpenAIProvider ¶ added in v0.5.0
func NewOpenAIProvider(apiKey string) OpenAIProvider
type OpenAIStreamProvider ¶ added in v0.5.0
func NewOpenAIStreamProvider ¶ added in v0.5.0
func NewOpenAIStreamProvider(apiKey string) OpenAIStreamProvider
type Projection ¶
func ProjectionFor ¶ added in v0.5.0
func ProjectionFor(provider ProviderSpec, system string) Projection
func ProjectionForWithRegistry ¶ added in v0.5.0
func ProjectionForWithRegistry(provider ProviderSpec, system string, registry *Registry) Projection
func ProjectionForWithRegistryAndStore ¶ added in v0.17.0
func ProjectionForWithRegistryAndStore(provider ProviderSpec, system string, registry *Registry, store AttachmentStore) Projection
type ProviderError ¶ added in v0.5.0
type ProviderError struct {
Message string
}
func (ProviderError) Error ¶ added in v0.5.0
func (e ProviderError) Error() string
type ProviderSpec ¶ added in v0.5.0
type ProviderSpec struct {
Kind string `json:"kind"`
Model string `json:"model,omitempty"`
MaxTokens int `json:"max_tokens"`
BaseURL string `json:"base_url,omitempty"`
Capabilities map[string]bool `json:"capabilities,omitempty"`
CapabilityMismatchBehavior string `json:"capability_mismatch_behavior,omitempty"`
}
type RateLimiter ¶ added in v0.5.0
type RateLimiter struct {
PerMinute int
// contains filtered or unexported fields
}
func (*RateLimiter) Wrap ¶ added in v0.5.0
func (r *RateLimiter) Wrap(handler ToolHandler) ToolHandler
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func BuildRegistry ¶ added in v0.5.0
func BuildRegistry(specs []ToolSpec, handlers map[string]ToolHandler) (*Registry, error)
func BuildRegistryWithConfigured ¶ added in v0.9.1
func BuildRegistryWithConfigured(specs []ToolSpec, handlers map[string]ToolHandler, configured map[string]ConfiguredToolHandler) (*Registry, error)
func BuildRegistryWithContextual ¶ added in v0.19.5
func BuildRegistryWithContextual( specs []ToolSpec, handlers map[string]ToolHandler, configured map[string]ConfiguredToolHandler, contextual map[string]ContextualToolHandler, ) (*Registry, error)
func NewRegistry ¶
func NewRegistry() *Registry
type RepetitionGuard ¶ added in v0.12.0
type RepetitionGuard struct {
MaxConsecutiveFailures int
MaxIdenticalCalls int
MaxConsecutiveRejections int
}
func (RepetitionGuard) Install ¶ added in v0.12.0
func (r RepetitionGuard) Install(session *Session)
type RetryDecision ¶ added in v0.5.0
type RetryPolicy ¶ added in v0.5.0
type RetryPolicy struct {
MaxAttempts int
RetryableHTTP map[int]bool
Backoff func(attempt int) time.Duration
}
func DefaultRetryPolicy ¶ added in v0.5.0
func DefaultRetryPolicy() RetryPolicy
func (RetryPolicy) Decide ¶ added in v0.5.0
func (p RetryPolicy) Decide(err error, attempt int) RetryDecision
type Runner ¶
type Runtime ¶ added in v0.11.0
type Runtime struct {
Loaded *LoadedManifest
}
Runtime is a convenience wrapper around manifest loading plus optional Session resume/save.
func NewRuntime ¶ added in v0.11.0
func NewRuntime(config RuntimeConfig) (*Runtime, error)
type RuntimeConfig ¶ added in v0.11.0
type SQLStorageAdapter ¶ added in v0.20.1
type SQLStorageAdapter struct {
// contains filtered or unexported fields
}
func NewSQLStorageAdapter ¶ added in v0.20.1
func NewSQLStorageAdapter(db *sql.DB, sessionID string, opts SQLStorageOptions) *SQLStorageAdapter
func (*SQLStorageAdapter) AppendEvent ¶ added in v0.20.1
func (a *SQLStorageAdapter) AppendEvent(draft EventDraft, expectedNextSeq *int) (EventRow, error)
func (*SQLStorageAdapter) EventsSince ¶ added in v0.20.1
func (a *SQLStorageAdapter) EventsSince(cursor *int) ([]EventRow, error)
func (*SQLStorageAdapter) LoadSession ¶ added in v0.20.1
func (a *SQLStorageAdapter) LoadSession() (*SessionHeader, error)
func (*SQLStorageAdapter) SaveHeader ¶ added in v0.20.1
func (a *SQLStorageAdapter) SaveHeader(header SessionHeader) error
type SQLStorageDialect ¶ added in v0.20.1
type SQLStorageDialect string
const ( SQLStorageDialectSQLite SQLStorageDialect = "sqlite" SQLStorageDialectPostgres SQLStorageDialect = "postgres" )
type SQLStorageOptions ¶ added in v0.20.1
type SQLStorageOptions struct {
Dialect SQLStorageDialect
TablePrefix string
// WorkspaceID scopes every row to a tenant. It is the storage partition
// key: rows are keyed (workspace_id, session_id[, seq]) and queries filter
// by it, so the same session_id in two workspaces never collide. Leave it
// empty for single-tenant use — the schema degenerates to the session-only
// key and behaves exactly as before. Set explicitly (not parsed from the
// header) so partitioning is independent of session content.
WorkspaceID string
// ConflictDetector, when set, decides whether an append error is a
// unique-constraint violation on (workspace_id, session_id, seq) — i.e.
// a lost optimistic-concurrency race that must surface as a
// StorageConflictError.
//
// It exists so consumers can detect conflicts by their driver's native
// error (e.g. lib/pq: errors.As(err, &pqErr) && pqErr.Code == "23505")
// without harnas-go importing any database driver. When nil, a
// driver-agnostic message match ("unique"/"duplicate") is used, which
// covers the standard lib/pq and pgx messages but is less robust.
//
// Note: a conflict only surfaces when AppendEvent is called with a
// non-nil expectedNextSeq. Concurrent writers MUST pass expectedNextSeq,
// or a losing racer receives the raw driver error rather than a
// StorageConflictError.
ConflictDetector func(error) bool
}
type Session ¶
type Session struct {
ID string
Log *Log
Metadata map[string]any
ParentSessionID string
RootSessionID string
SpawnID string
SpawnedByEventID string
DelegationChain []map[string]any
Hooks *Hooks
Observation *Observation
}
func CreateSession ¶
func LoadSession ¶
type SessionHeader ¶ added in v0.20.1
type SessionMap ¶ added in v0.18.0
func (SessionMap) LoadSession ¶ added in v0.18.0
func (m SessionMap) LoadSession(id string) (*Session, error)
type SessionResolver ¶ added in v0.18.0
type SkillEntry ¶ added in v0.10.0
func SkillEntries ¶ added in v0.10.0
func SkillEntries(skillsDir string) ([]SkillEntry, error)
type StaleReadGuard ¶ added in v0.5.0
func (StaleReadGuard) WrapEdit ¶ added in v0.5.0
func (g StaleReadGuard) WrapEdit(handler ToolHandler) ToolHandler
func (StaleReadGuard) WrapRead ¶ added in v0.5.0
func (g StaleReadGuard) WrapRead(handler ToolHandler) ToolHandler
func (StaleReadGuard) WrapWrite ¶ added in v0.9.0
func (g StaleReadGuard) WrapWrite(handler ToolHandler) ToolHandler
type StorageAdapter ¶ added in v0.20.1
type StorageAdapter interface {
LoadSession() (*SessionHeader, error)
SaveHeader(SessionHeader) error
AppendEvent(EventDraft, *int) (EventRow, error)
EventsSince(*int) ([]EventRow, error)
}
type StorageConflictError ¶ added in v0.20.1
func (*StorageConflictError) Error ¶ added in v0.20.1
func (e *StorageConflictError) Error() string
type StrategyInstallation ¶ added in v0.5.0
type StrategyInstallation interface {
Install(session *Session)
}
func BuildStrategies ¶ added in v0.5.0
func BuildStrategies(specs []StrategySpec, handlers map[string]ApprovalHandler) ([]StrategyInstallation, error)
func BuildStrategiesWithRuntime ¶ added in v0.5.0
func BuildStrategiesWithRuntime( specs []StrategySpec, handlers map[string]ApprovalHandler, projection Projection, provider Provider, ingestor Ingestor, ) ([]StrategyInstallation, error)
type StrategySpec ¶ added in v0.5.0
type StreamProvider ¶
type SummaryTail ¶ added in v0.5.0
type SummaryTail struct {
Projection Projection
Provider Provider
Ingestor Ingestor
MaxMessages int
KeepRecent int
Prompt string
}
func (SummaryTail) Install ¶ added in v0.5.0
func (s SummaryTail) Install(session *Session)
func (SummaryTail) OnPreProjection ¶ added in v0.5.0
func (s SummaryTail) OnPreProjection(session *Session)
type TimeoutGuard ¶ added in v0.12.0
type TimeoutGuard struct {
TimeoutSeconds int
}
func (TimeoutGuard) Install ¶ added in v0.12.0
func (t TimeoutGuard) Install(session *Session)
type TokenMarkerTail ¶ added in v0.5.0
func (TokenMarkerTail) Install ¶ added in v0.5.0
func (t TokenMarkerTail) Install(session *Session)
func (TokenMarkerTail) OnPreProjection ¶ added in v0.5.0
func (t TokenMarkerTail) OnPreProjection(session *Session)
type ToolContext ¶ added in v0.19.5
type ToolHandler ¶ added in v0.5.0
func Logged ¶ added in v0.5.0
func Logged(handler ToolHandler, writer io.Writer) ToolHandler
func Retried ¶ added in v0.5.0
func Retried(handler ToolHandler, attempts int, retryable func(error) bool) ToolHandler
func Timed ¶ added in v0.5.0
func Timed(handler ToolHandler) ToolHandler
type ToolHandlerV2 ¶ added in v0.15.0
type ToolHandlerV2 = ConfiguredToolHandler
func WrapV1Handler ¶ added in v0.15.0
func WrapV1Handler(handler ToolHandler) ToolHandlerV2
type ToolOutputCap ¶
func (ToolOutputCap) Install ¶
func (t ToolOutputCap) Install(session *Session)
func (ToolOutputCap) OnPreProjection ¶
func (t ToolOutputCap) OnPreProjection(session *Session)
type ToolSpec ¶ added in v0.5.0
type ToolSpec struct {
Name string `json:"name"`
Handler string `json:"handler"`
Description string `json:"description"`
InputSchema map[string]any `json:"input_schema"`
Config map[string]any `json:"config,omitempty"`
}
func BuiltinDescriptors ¶ added in v0.5.0
func BuiltinDescriptors() []ToolSpec
func ToolDescriptors ¶ added in v0.11.0
ToolDescriptors snapshots the public descriptors of a registry.
type TranscriptOptions ¶ added in v0.11.0
type TranscriptOptions struct {
IncludeTools bool
IncludeErrors bool
IncludeAnnotations bool
ContentPlaceholder func(map[string]any) string
}
func DefaultTranscriptOptions ¶ added in v0.11.0
func DefaultTranscriptOptions() TranscriptOptions
type TurnFailed ¶ added in v0.9.0
type TurnFailed struct {
Message string
}
func (TurnFailed) Error ¶ added in v0.9.0
func (t TurnFailed) Error() string
type UnknownProviderError ¶ added in v0.5.0
type UnknownProviderError struct{ ManifestError }
type UnknownStrategyError ¶ added in v0.5.0
type UnknownStrategyError struct{ ManifestError }
type UnresolvedHandlerError ¶ added in v0.5.0
type UnresolvedHandlerError struct{ ManifestError }
type UnsupportedVersionError ¶ added in v0.5.0
type UnsupportedVersionError struct{ ManifestError }
type ValidationError ¶ added in v0.5.0
type ValidationError struct{ ManifestError }
type WriteSandbox ¶ added in v0.12.0
func (WriteSandbox) Install ¶ added in v0.12.0
func (w WriteSandbox) Install(session *Session)
Source Files
¶
- agent.go
- agent_loop.go
- attachments.go
- bash_session.go
- bash_session_unix.go
- builtin_tools.go
- capabilities.go
- capability_manifest.go
- content_blocks.go
- delegation_projection.go
- event.go
- hooks.go
- ingestor_anthropic.go
- ingestor_gemini.go
- ingestor_openai.go
- input_file.go
- jcs.go
- log.go
- manifest.go
- mutations.go
- observation.go
- portability.go
- projection_anthropic.go
- provider.go
- provider_carriers.go
- provider_http.go
- provider_stream.go
- retry_policy.go
- runtime.go
- session.go
- skills.go
- snapshot.go
- storage.go
- storage_sql.go
- strategies.go
- tool_middleware.go
- tools.go
- transcript.go
- usage.go
- values.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
conformance
command
|
|
|
conformance-roundtrip
command
|
|
|
harnas
command
|
|
|
smoke
command
|
|
|
examples
|
|
|
multitenant
Package multitenant is a reference for embedding harnas-go in a concurrent, multi-tenant Go server (the shape Tedo/Ovin uses): one Session per conversation, persisted to a SQL StorageAdapter, tools routed through the host's registry behind an enforce-by-default pre_tool_use gate, and the Observation bus bridged to distributed tracing.
|
Package multitenant is a reference for embedding harnas-go in a concurrent, multi-tenant Go server (the shape Tedo/Ovin uses): one Session per conversation, persisted to a SQL StorageAdapter, tools routed through the host's registry behind an enforce-by-default pre_tool_use gate, and the Observation bus bridged to distributed tracing. |