harnas

package module
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 30 Imported by: 0

README

harnas-go

Go implementation of Harnas, a specification for LLM agent harnesses.

This repo is a conformance-first peer implementation. It started with the smallest buffered AgentLoop surface and now includes the live provider, CLI, tool, middleware, strategy, persistence, and conformance surfaces needed for real Go adoption.

Version 0.20.1 (2026-06-27). Tracks Harnas spec 0.20.1.

Status

  • Agent conformance: 75/75 fixtures passing
  • Buffered and streaming AgentLoop paths
  • Public Agent Manifest loader for v0.1 manifests
  • Agent façade and bin/harnas chat / bin/harnas run
  • Buffered HTTP providers for Anthropic, OpenAI, Gemini, and local Ollama
  • Streaming HTTP providers for Anthropic, OpenAI, Gemini, and local Ollama
  • Built-in tools: read_file, write_file, edit_file, list_dir, glob, grep, run_shell, fetch_url, load_skill, bash_session, with manifest-ready descriptors
  • Tool middleware: Timed, Logged, Retried, RateLimiter, StaleReadGuard
  • Anthropic, OpenAI, and Gemini fixture ingestors
  • Session-scoped hooks and observation bus, MarkerTail, TokenMarkerTail, SummaryTail, and ToolOutputCap compaction, AlwaysAllow, DenyByName, HumanApproval, sandbox/write, sandbox/network, credential/proxy, repetition, health, timeout, and cost-budget guards
  • Scripted provider errors and provider_error Log events
  • Observation-only streaming transport events plus DeltaLogger sidecar persistence for debugging
  • Adopter helper APIs: NewRuntime, TranscriptProject, ToolDescriptors, ManifestSnapshotMetadata, and delegation projections (DelegationTree, DescendantTimeline, OpenChildren, DescendantUsage)
  • MCP adapter package: HTTP and stdio transports, content flattening, Harnas tool descriptor translation, and degraded startup handling
  • Subagent delegation events, cross-session projection helpers, and optional spawn_agent receipt built-in
  • v0.20 durability APIs: harnas-jcs-v1 canonicalization, Event row content_hash, memory/file/SQL-backed StorageAdapter implementations, and expected_next_seq OCC fences

Run

go test ./...
bin/conformance
bin/conformance-roundtrip --help
bin/harnas run manifest.json --input "hello"
bin/harnas chat manifest.json
bin/harnas inspect session.jsonl
bin/smoke-anthropic "say hello in one word"
bin/smoke-ollama "say hello in one word"

Library use:

go get github.com/Tedo-ai/harnas-go

CLI use from source:

go install github.com/Tedo-ai/harnas-go/cmd/harnas@latest

bin/conformance resolves fixtures from a sibling checkout of Tedo-ai/harnas, or from HARNAS_SPEC when set.

Operator CLI

The Go port ships the persisted-Session operator commands shared with the Ruby and Python CLIs:

bin/harnas run manifest.json --input "hello"
bin/harnas chat manifest.json
bin/harnas inspect session.jsonl [--json]
bin/harnas fork session.jsonl --at-seq N --out forked.jsonl
bin/harnas diff a.jsonl b.jsonl
bin/harnas project session.jsonl --manifest manifest.json [--from-seq N] [--to-seq M] [--provider KIND] [--model MODEL]

project renders the provider request body from a saved Log slice without making a provider call. It supports the conformance-facing Anthropic, OpenAI-compatible, and Gemini projections.

MCP

The Go port includes github.com/Tedo-ai/harnas-go/mcp for consuming Model Context Protocol servers as Harnas tools. Connect to an MCP server, ask it for translated tool descriptors, and pass its dynamic handlers to the runtime:

import "github.com/Tedo-ai/harnas-go/mcp"

mcpClient, err := mcp.Connect(mcp.ConnectOptions{
    URL:        "http://localhost:3001",
    ServerName: "editorial-ai",
    Headers:    map[string]string{"Authorization": "Bearer " + token},
})
if err != nil {
    return err
}
defer mcpClient.Close()

tools, err := mcpClient.Tools(ctx)
if err != nil {
    return err
}
handlers := mcpClient.ToolHandlers()

manifest.Tools = append(manifest.Tools, tools...)
loaded, err := harnas.BuildManifest(manifest, harnas.ManifestOptions{
    ConfiguredHandlers: handlers,
})
if err != nil {
    return err
}
runtime := &harnas.Runtime{Loaded: loaded}

Tools(ctx) performs lazy MCP initialize + tools/list, caches the translated descriptors, and degrades to an empty tool list if the MCP server is unavailable. ToolHandlers() returns the mcp_passthrough.<server> handler required by those descriptors.

Live providers

Set ANTHROPIC_API_KEY, OPENAI_API_KEY, or GEMINI_API_KEY to run the remote live smoke scripts. Ollama uses OLLAMA_BASE_URL when set and otherwise defaults to http://localhost:11434/v1; its smoke skips cleanly when Ollama is not running. Each smoke script exercises both the buffered and streaming provider for that backend:

bin/smoke-anthropic "say hello in one word"
bin/smoke-openai "say hello in one word"
bin/smoke-gemini "say hello in one word"
bin/smoke-ollama "say hello in one word"

bash_session

The Go port includes the conformable harnas.builtin.bash_session handler. It runs a long-lived shell per named session, preserving cd and export across tool calls, and returns a JSON object encoded as the string tool_result.output. The result includes both cumulative stdout / stderr and command-local command_stdout / command_stderr.

Prefer this tool for sandboxed coding agents that can safely expose a shell. The narrower list_dir, glob, grep, and run_shell tools remain available and are still the safer fit for restricted agents.

A minimal live-provider manifest is available at examples/bash-session/manifest.json:

export OPENAI_API_KEY=...
bin/harnas chat examples/bash-session/manifest.json

Documentation

Index

Constants

View Source
const (
	DefaultShellTimeoutSeconds = 30
	GrepMaxMatches             = 200
	MaxFetchBytes              = 256 * 1024
)
View Source
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"
)
View Source
const DefaultBashSessionMaxOutputBytes = 64 * 1024
View Source
const StorageConflictReason = "storage_conflict"
View Source
const SupportedManifestVersion = "0.1"

Variables

View Source
var DefaultAttachmentHTTPTimeout = 60 * time.Second
View Source
var DefaultFetchURLTimeout = 60 * time.Second
View Source
var DefaultProviderHTTPTimeout = 60 * time.Second
View Source
var ErrInvalidUnicode = errors.New("invalid_unicode")

Functions

func BuildSkillsIndex added in v0.10.0

func BuildSkillsIndex(skillsDir string) (string, error)

func BuiltinBashSession added in v0.11.0

func BuiltinBashSession(args map[string]any, config map[string]any) (string, error)

func BuiltinConfiguredHandlers added in v0.10.0

func BuiltinConfiguredHandlers() map[string]ConfiguredToolHandler

func BuiltinEditFile added in v0.5.0

func BuiltinEditFile(args map[string]any) (string, error)

func BuiltinFetchURL added in v0.5.0

func BuiltinFetchURL(args map[string]any) (string, error)

func BuiltinGlob added in v0.5.0

func BuiltinGlob(args map[string]any) (string, error)

func BuiltinGrep added in v0.5.0

func BuiltinGrep(args map[string]any) (string, error)

func BuiltinHandlers added in v0.5.0

func BuiltinHandlers() map[string]ToolHandler

func BuiltinListDir added in v0.5.0

func BuiltinListDir(args map[string]any) (string, error)

func BuiltinLoadSkill added in v0.10.0

func BuiltinLoadSkill(args map[string]any, config map[string]any) (string, error)

func BuiltinReadFile added in v0.5.0

func BuiltinReadFile(args map[string]any) (string, error)

func BuiltinRunShell added in v0.5.0

func BuiltinRunShell(args map[string]any) (string, error)

func BuiltinWriteFile added in v0.5.0

func BuiltinWriteFile(args map[string]any) (string, error)

func CanonicalizeJCSV1JSON added in v0.20.1

func CanonicalizeJCSV1JSON(data []byte, excludeKeys ...string) ([]byte, error)

func CapabilityManifestRef added in v0.18.0

func CapabilityManifestRef(manifest any) (string, error)

func ContentBlockForFile added in v0.17.0

func ContentBlockForFile(path string) (map[string]any, error)

func ContentBlocksForInput added in v0.17.0

func ContentBlocksForInput(text string, paths []string) ([]map[string]any, error)

func ContentHashForEventRow added in v0.20.1

func ContentHashForEventRow(row EventRow) (string, error)

func ContentHashForEventRowJSON added in v0.20.1

func ContentHashForEventRowJSON(data []byte) (string, error)

func DefaultAttachmentRoot added in v0.17.0

func DefaultAttachmentRoot(sessionPath string) string

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 ListReferencedAttachments(log *Log) []string

func ManifestSnapshotMetadata added in v0.11.0

func ManifestSnapshotMetadata(registry *Registry, skills any, mcp any) map[string]any

ManifestSnapshotMetadata packages dynamic descriptors for Session metadata.

func NormalizeUsage added in v0.19.0

func NormalizeUsage(value any) map[string]any

func OpenChildren added in v0.18.0

func OpenChildren(sessionID string, resolver SessionResolver) ([]string, error)

func ParseSkillFile added in v0.10.0

func ParseSkillFile(path string) (map[string]any, string, error)

func ParseSkillFrontmatter added in v0.10.0

func ParseSkillFrontmatter(raw string) map[string]any

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 ValidSkillName(name string) bool

func ValidateManifest added in v0.5.0

func ValidateManifest(manifest Manifest) error

func VerifySessionPortable added in v0.20.1

func VerifySessionPortable(s *Session) error

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) Chat added in v0.5.0

func (a *Agent) Chat(text string) (Response, error)

func (*Agent) ChatPayload added in v0.17.0

func (a *Agent) ChatPayload(payload map[string]any) (Response, error)

func (*Agent) Stream added in v0.5.0

func (a *Agent) Stream(text string, onDelta func(Event)) (Response, error)

func (*Agent) StreamPayload added in v0.17.0

func (a *Agent) StreamPayload(payload map[string]any, onDelta func(Event)) (Response, error)

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)
}

func (AgentLoop) Run

func (l AgentLoop) Run() (reason string, err error)

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{}

func (AnthropicIngestor) Ingest

func (AnthropicIngestor) Ingest(response map[string]any) ([]EventArgs, error)

type AnthropicProjection

type AnthropicProjection struct {
	Model                      string
	MaxTokens                  int
	System                     string
	Registry                   *Registry
	Store                      AttachmentStore
	ProviderKind               string
	Capabilities               map[string]bool
	CapabilityMismatchBehavior string
}

func (AnthropicProjection) Project

func (p AnthropicProjection) Project(log *Log) (map[string]any, error)

type AnthropicProvider added in v0.5.0

type AnthropicProvider struct {
	APIKey     string
	APIVersion string
	Endpoint   string
	Client     HTTPDoer
}

func NewAnthropicProvider added in v0.5.0

func NewAnthropicProvider(apiKey string) AnthropicProvider

func (AnthropicProvider) Call added in v0.5.0

func (p AnthropicProvider) Call(request map[string]any) (map[string]any, error)

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

func (AnthropicStreamProvider) Call added in v0.5.0

func (p AnthropicStreamProvider) Call(request map[string]any, emit func(EventArgs)) error

type ApprovalHandler added in v0.5.0

type ApprovalHandler func(Event) bool

type AttachmentReference added in v0.17.0

type AttachmentReference struct {
	URI       string         `json:"uri,omitempty"`
	MediaType string         `json:"media_type"`
	ByteSize  int            `json:"byte_size"`
	SHA256    string         `json:"sha256"`
	Source    map[string]any `json:"source,omitempty"`
}

type AttachmentStore added in v0.17.0

type AttachmentStore interface {
	Put(data []byte, mediaType string) (AttachmentReference, error)
	Get(uri string) ([]byte, string, error)
	Delete(uri string) error
	Exists(uri string) bool
	ListReferenced(log *Log) []string
}

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()

func (*BashSessionRegistry) Handle added in v0.11.0

func (r *BashSessionRegistry) Handle(args map[string]any, config map[string]any) (string, error)

type CapabilityManifestStore added in v0.18.0

type CapabilityManifestStore interface {
	Put(manifest any) (string, error)
	Get(ref string) (any, bool)
}

type CapabilityMismatchError added in v0.17.0

type CapabilityMismatchError struct {
	BlockType string
	Message   string
}

func (CapabilityMismatchError) Error added in v0.17.0

func (e CapabilityMismatchError) Error() string

type ConfiguredToolHandler added in v0.9.1

type ConfiguredToolHandler func(map[string]any, map[string]any) (string, error)

type ContextualToolHandler added in v0.19.5

type ContextualToolHandler func(map[string]any, ToolContext) (string, error)

type CostBudgetGuard added in v0.12.0

type CostBudgetGuard struct {
	MaxInputTokens  int
	MaxOutputTokens int
}

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

type CredentialProxyCredential struct {
	From  string
	Name  string
	Value string
}

func (CredentialProxyCredential) Resolve added in v0.16.0

func (c CredentialProxyCredential) Resolve() (string, bool)

type CredentialProxyInject added in v0.16.0

type CredentialProxyInject struct {
	Into  string
	Key   string
	Value string
}

type CredentialProxyMatch added in v0.16.0

type CredentialProxyMatch struct {
	URLHost     string
	URLHostGlob string
}

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

func (*DeltaLogger) Call added in v0.8.0

func (l *DeltaLogger) Call(eventName string, payload map[string]any)

type DenyByName

type DenyByName struct {
	Names        []string
	ReasonFormat string
}

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

func ApplyMutations(log *Log) []Event

type EventArgs

type EventArgs struct {
	Type    EventType
	Payload map[string]any
}

type EventDraft added in v0.20.1

type EventDraft struct {
	ID        string
	Timestamp string
	Type      EventType
	Payload   map[string]any
}

type EventRow added in v0.20.1

type EventRow struct {
	Seq         int
	ID          string
	Timestamp   string
	Type        EventType
	Payload     map[string]any
	ContentHash string
}

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
}

func (*GeminiIngestor) Ingest

func (g *GeminiIngestor) Ingest(response map[string]any) ([]EventArgs, error)

type GeminiProjection

type GeminiProjection struct {
	Model                      string
	System                     string
	Registry                   *Registry
	Store                      AttachmentStore
	ProviderKind               string
	Capabilities               map[string]bool
	CapabilityMismatchBehavior string
}

func (GeminiProjection) Project

func (p GeminiProjection) Project(log *Log) (map[string]any, error)

type GeminiProvider added in v0.5.0

type GeminiProvider struct {
	APIKey       string
	EndpointBase string
	Client       HTTPDoer
}

func NewGeminiProvider added in v0.5.0

func NewGeminiProvider(apiKey string) GeminiProvider

func (GeminiProvider) Call added in v0.5.0

func (p GeminiProvider) Call(request map[string]any) (map[string]any, error)

type GeminiStreamProvider added in v0.5.0

type GeminiStreamProvider struct {
	APIKey       string
	EndpointBase string
	Client       HTTPDoer
}

func NewGeminiStreamProvider added in v0.5.0

func NewGeminiStreamProvider(apiKey string) GeminiStreamProvider

func (GeminiStreamProvider) Call added in v0.5.0

func (p GeminiStreamProvider) Call(request map[string]any, emit func(EventArgs)) error

type HTTPDoer added in v0.5.0

type HTTPDoer interface {
	Do(*http.Request) (*http.Response, error)
}

type HTTPError added in v0.5.0

type HTTPError struct {
	Status int
	Body   any
}

func (HTTPError) Error added in v0.5.0

func (e HTTPError) Error() string

func (HTTPError) HTTPStatus added in v0.5.0

func (e HTTPError) HTTPStatus() int

type HealthGuard added in v0.13.0

type HealthGuard struct {
	Command        string
	TimeoutSeconds int
	OnFailure      string
}

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 HookHandler func(ctx map[string]any) any

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 HookSpec added in v0.9.0

type HookSpec struct {
	Point   string         `json:"point"`
	Handler string         `json:"handler"`
	Config  map[string]any `json:"config,omitempty"`
	OnError string         `json:"on_error,omitempty"`
}

type Hooks

type Hooks struct {
	// contains filtered or unexported fields
}

func NewHooks

func NewHooks() *Hooks

func (*Hooks) Handlers added in v0.9.0

func (h *Hooks) Handlers() map[string][]HookHandler

func (*Hooks) Invoke

func (h *Hooks) Invoke(point string, ctx map[string]any) []any

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

func (*Hooks) Reset added in v0.5.0

func (h *Hooks) Reset()

type HumanApproval added in v0.5.0

type HumanApproval struct {
	Prompt       func(Event) bool
	DenialReason string
}

func (HumanApproval) Install added in v0.5.0

func (h HumanApproval) Install(session *Session)

type Ingestor

type Ingestor interface {
	Ingest(response map[string]any) ([]EventArgs, error)
}

func IngestorFor added in v0.5.0

func IngestorFor(kind string) Ingestor

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) Get added in v0.17.0

func (InlineStore) Get(_ string) ([]byte, string, error)

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 NewLog

func NewLog() *Log

func (*Log) Append

func (l *Log) Append(eventType EventType, payload map[string]any) Event

func (*Log) Events

func (l *Log) Events() []Event

func (*Log) LastAssistantMessage

func (l *Log) LastAssistantMessage() (Event, bool)

func (*Log) Restore

func (l *Log) Restore(event Event)

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 ManifestFromMap(source map[string]any) (Manifest, error)

func ReadManifest added in v0.5.0

func ReadManifest(path string) (Manifest, error)

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

type MarkerTail struct {
	MaxMessages int
	KeepRecent  int
}

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

func (*MemoryCapabilityManifestStore) Get added in v0.18.0

func (*MemoryCapabilityManifestStore) Put added in v0.18.0

func (s *MemoryCapabilityManifestStore) Put(manifest any) (string, error)

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
}

func (MockProvider) Call added in v0.5.0

func (p MockProvider) Call(_ map[string]any) (map[string]any, error)

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

type NetworkSandbox struct {
	Allow []string
	Deny  []string
}

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 ObservationSubscriber func(event string, payload map[string]any)

type ObservedEvent added in v0.5.0

type ObservedEvent struct {
	Event   string
	Payload map[string]any
}

type OllamaProvider added in v0.13.0

type OllamaProvider struct {
	BaseURL string
	Client  HTTPDoer
}

func NewOllamaProvider added in v0.13.0

func NewOllamaProvider(baseURL string) OllamaProvider

func (OllamaProvider) Call added in v0.13.0

func (p OllamaProvider) Call(request map[string]any) (map[string]any, error)

type OllamaStreamProvider added in v0.13.0

type OllamaStreamProvider struct {
	BaseURL string
	Client  HTTPDoer
}

func NewOllamaStreamProvider added in v0.13.0

func NewOllamaStreamProvider(baseURL string) OllamaStreamProvider

func (OllamaStreamProvider) Call added in v0.13.0

func (p OllamaStreamProvider) Call(request map[string]any, emit func(EventArgs)) error

type OpenAIIngestor

type OpenAIIngestor struct{}

func (OpenAIIngestor) Ingest

func (OpenAIIngestor) Ingest(response map[string]any) ([]EventArgs, error)

type OpenAIProjection

type OpenAIProjection struct {
	Model                      string
	System                     string
	Registry                   *Registry
	Store                      AttachmentStore
	ProviderKind               string
	Capabilities               map[string]bool
	CapabilityMismatchBehavior string
}

func (OpenAIProjection) Project

func (p OpenAIProjection) Project(log *Log) (map[string]any, error)

type OpenAIProvider added in v0.5.0

type OpenAIProvider struct {
	APIKey   string
	Endpoint string
	Client   HTTPDoer
	NoAuth   bool
}

func NewOpenAIProvider added in v0.5.0

func NewOpenAIProvider(apiKey string) OpenAIProvider

func (OpenAIProvider) Call added in v0.5.0

func (p OpenAIProvider) Call(request map[string]any) (map[string]any, error)

type OpenAIStreamProvider added in v0.5.0

type OpenAIStreamProvider struct {
	APIKey   string
	Endpoint string
	Client   HTTPDoer
	NoAuth   bool
}

func NewOpenAIStreamProvider added in v0.5.0

func NewOpenAIStreamProvider(apiKey string) OpenAIStreamProvider

func (OpenAIStreamProvider) Call added in v0.5.0

func (p OpenAIStreamProvider) Call(request map[string]any, emit func(EventArgs)) error

type Projection

type Projection interface {
	Project(log *Log) (map[string]any, error)
}

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 Provider

type Provider interface {
	Call(request map[string]any) (map[string]any, error)
}

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

func (*Registry) Find

func (r *Registry) Find(name string) (Tool, bool)

func (*Registry) Register

func (r *Registry) Register(tool Tool) error

func (*Registry) Size

func (r *Registry) Size() int

func (*Registry) Tools added in v0.5.0

func (r *Registry) Tools() []Tool

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 Response added in v0.5.0

type Response struct {
	Text       string
	StopReason string
	Log        *Log
}

type RetryDecision added in v0.5.0

type RetryDecision struct {
	Retry bool
	Delay time.Duration
}

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 Runner struct {
	Registry      *Registry
	ParentSession *Session
	ChildSessions map[string]*Session
	Context       context.Context
	Extra         map[string]any
}

func (*Runner) Run

func (r *Runner) Run(toolUse Event, log *Log)

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)

func (*Runtime) Agent added in v0.11.0

func (r *Runtime) Agent() *Agent

func (*Runtime) Loop added in v0.11.0

func (r *Runtime) Loop() AgentLoop

func (*Runtime) Registry added in v0.11.0

func (r *Runtime) Registry() *Registry

func (*Runtime) Save added in v0.11.0

func (r *Runtime) Save(path string) error

func (*Runtime) Session added in v0.11.0

func (r *Runtime) Session() *Session

type RuntimeConfig added in v0.11.0

type RuntimeConfig struct {
	Manifest     map[string]any
	ManifestPath string
	Options      ManifestOptions
	SessionPath  string
	Resume       bool
	Metadata     map[string]any
}

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 CreateSession(metadata map[string]any) *Session

func LoadSession

func LoadSession(path string) (*Session, error)

func NewSession

func NewSession(id string, log *Log, metadata map[string]any) *Session

func (*Session) Fork

func (s *Session) Fork(atSeq int) *Session

func (*Session) Save

func (s *Session) Save(path string) error

type SessionHeader added in v0.20.1

type SessionHeader struct {
	ID               string
	Metadata         map[string]any
	ParentSessionID  string
	RootSessionID    string
	SpawnID          string
	SpawnedByEventID string
	DelegationChain  []map[string]any
}

type SessionMap added in v0.18.0

type SessionMap map[string]*Session

func (SessionMap) LoadSession added in v0.18.0

func (m SessionMap) LoadSession(id string) (*Session, error)

type SessionResolver added in v0.18.0

type SessionResolver interface {
	LoadSession(id string) (*Session, error)
}

type SkillEntry added in v0.10.0

type SkillEntry struct {
	Name        string
	Description string
	Category    string
	Triggers    []string
}

func SkillEntries added in v0.10.0

func SkillEntries(skillsDir string) ([]SkillEntry, error)

type StaleReadGuard added in v0.5.0

type StaleReadGuard struct {
	Log         *Log
	Strict      bool
	RequireRead bool
}

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

type StorageConflictError struct {
	Reason         string
	ExpectedSeq    int
	CurrentNextSeq int
}

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 StrategySpec struct {
	Name    string         `json:"name"`
	Config  map[string]any `json:"config,omitempty"`
	OnError string         `json:"on_error,omitempty"`
}

type StreamProvider

type StreamProvider interface {
	Call(request map[string]any, emit func(EventArgs)) error
}

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

type TokenMarkerTail struct {
	MaxTokens     int
	Threshold     float64
	KeepRecent    int
	SummaryFormat string
}

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 Tool

type Tool struct {
	Name        string
	Handler     string
	Description string
	InputSchema map[string]any
	Config      map[string]any
	Call        func(map[string]any) (string, error)
	CallConfig  func(map[string]any, map[string]any) (string, error)
	CallContext ContextualToolHandler
}

type ToolContext added in v0.19.5

type ToolContext struct {
	Context         context.Context
	SessionID       string
	ToolUseID       string
	SourceToolUseID string
	Config          map[string]any
	Extra           map[string]any
}

type ToolHandler added in v0.5.0

type ToolHandler func(map[string]any) (string, error)

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

type ToolOutputCap struct {
	MaxBytes      int
	PrefixBytes   int
	SummaryFormat string
}

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

func ToolDescriptors(registry *Registry) []ToolSpec

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

type WriteSandbox struct {
	Allow []string
	Deny  []string
}

func (WriteSandbox) Install added in v0.12.0

func (w WriteSandbox) Install(session *Session)

Directories

Path Synopsis
cmd
conformance 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.

Jump to

Keyboard shortcuts

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