serviceimpl

package
v0.10.14 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DispatchExecuteRun

func DispatchExecuteRun(ctx context.Context, req ExecuteDispatchRequest, cb ExecuteDispatchCallbacks)

DispatchExecuteRun selects the concrete runner for an Execute request.

func ReplaySession

func ReplaySession(ctx context.Context, path string, w io.Writer) error

ReplaySession renders a human-readable transcript for one session log path.

func RunNative

func RunNative(ctx context.Context, req NativeRequest, cb NativeCallbacks)

RunNative drives the in-process agent loop without depending on root public service types.

func RunSubprocess

func RunSubprocess(ctx context.Context, req SubprocessRequest, runner harnesses.Harness, cb SubprocessCallbacks)

RunSubprocess executes a subprocess harness and forwards its event stream.

func SessionLogDir

func SessionLogDir(overrideDir, configDir string) string

SessionLogDir resolves the public service session-log directory from the per-service override and the loaded config value.

func SessionLogPath

func SessionLogPath(dir, sessionID string) (string, error)

SessionLogPath resolves the JSONL path for a public service session.

func SystemClock

func SystemClock() time.Time

SystemClock returns the current UTC wall-clock time.

func TailSessionLog

func TailSessionLog(ctx context.Context, sessionID string, subscribe SessionSubscriber) (<-chan harnesses.Event, error)

TailSessionLog proxies session-hub events to a caller-owned channel that closes on upstream completion or context cancellation.

func ToolNames

func ToolNames(tools []agentcore.Tool) []string

ToolNames returns names for non-nil tools.

func UsageReport

func UsageReport(ctx context.Context, logDir string, opts session.UsageOptions) (*session.UsageReport, error)

UsageReport aggregates session usage from the service-owned log directory.

func WriteSessionLog

func WriteSessionLog(ctx context.Context, path string, w io.Writer) error

WriteSessionLog writes the raw session events as indented JSON objects.

Types

type Clock

type Clock func() time.Time

Clock is the API-neutral time seam used by service implementation state. It deliberately has no dependency on root package contract types so the root facade can import this package without creating a cycle.

type ExecuteDispatchCallbacks

type ExecuteDispatchCallbacks struct {
	RunNative      func(context.Context)
	RunSubprocess  func(context.Context, harnesses.Harness)
	RunVirtual     func(context.Context)
	RunScript      func(context.Context)
	IsHTTPProvider func(harness string) bool
	Finalize       func(harnesses.FinalData)
}

ExecuteDispatchCallbacks connect the internal dispatcher to root-owned public event/session adapters.

type ExecuteDispatchRequest

type ExecuteDispatchRequest struct {
	Decision ExecuteRunnerDecision
	Started  time.Time
}

ExecuteDispatchRequest carries API-neutral data needed to choose the concrete execute runner.

type ExecuteRunnerDecision

type ExecuteRunnerDecision struct {
	Harness        string
	Provider       string
	ServerInstance string
	Model          string
}

ExecuteRunnerDecision is the API-neutral routing data needed by internal virtual/script runner implementations.

type ExecuteRunnerRequest

type ExecuteRunnerRequest struct {
	Prompt   string
	Metadata map[string]string
	Decision ExecuteRunnerDecision
	Started  time.Time
}

ExecuteRunnerRequest is the API-neutral request data needed by internal virtual/script runner implementations.

type ExecuteRunnerResult

type ExecuteRunnerResult struct {
	Final    harnesses.FinalData
	Text     string
	EmitText bool
}

ExecuteRunnerResult is the normalized result produced by an internal runner.

func RunScript

RunScript executes the service script harness mechanics without depending on root public service types.

func RunVirtual

RunVirtual executes the service virtual harness mechanics without depending on root public service types.

type NativeCallbacks

type NativeCallbacks struct {
	ResolveProvider            func(NativeProviderRequest) NativeProviderResolution
	ProviderNotConfiguredError func(NativeProviderRequest, NativeDecision) string
	Compactor                  func(model string) agentcore.Compactor
	ObserveAgentEvent          func(agentcore.Event)
	EmitEvent                  func(harnesses.EventType, any)
	BeforeFinal                func(harnesses.FinalData)
	Finalize                   func(harnesses.FinalData)
	ToolWiringHook             func(harness string, toolNames []string)
	PromptAssertionHook        func(systemPrompt, prompt string, contextFiles []string)
	CompactionAssertionHook    func(messagesBefore, messagesAfter, tokensFreed int)
	ObserveTokenUsage          func(provider string, tokens int, at time.Time)
}

NativeCallbacks are root-owned service seams used by the internal runner without importing root public contract types.

type NativeDecision

type NativeDecision struct {
	Harness        string
	Provider       string
	ServerInstance string
	Model          string
	Candidates     []NativeRouteCandidate
}

NativeDecision is the API-neutral routing data needed by the native runner.

type NativeProviderRequest

type NativeProviderRequest struct {
	Provider string
	Harness  string
	Model    string
}

NativeProviderRequest is the narrow provider-selection request that crosses from the internal runner back into root-owned provider configuration.

type NativeProviderResolution

type NativeProviderResolution struct {
	Provider agentcore.Provider
	Name     string
	Model    string
}

NativeProviderResolution is the API-neutral result of root-owned provider construction.

type NativeRequest

type NativeRequest struct {
	Prompt                    string
	SystemPrompt              string
	Model                     string
	Provider                  string
	Harness                   string
	WorkDir                   string
	Temperature               *float32
	TopP                      *float64
	TopK                      *int
	MinP                      *float64
	RepetitionPenalty         *float64
	Seed                      *int64
	SamplingSource            string
	Reasoning                 agentcore.Reasoning
	NoStream                  bool
	Permissions               string
	Tools                     []agentcore.Tool
	ToolPreset                string
	PlanningMode              bool
	MaxIterations             int
	MaxTokens                 int
	ReasoningByteLimit        int
	ProviderTimeout           time.Duration
	Timeout                   time.Duration
	CachePolicy               string
	StallMaxReadOnlyIteration *int
	Metadata                  map[string]string
	Decision                  NativeDecision
	Started                   time.Time
	SessionID                 string
}

NativeRequest is the API-neutral request data needed by the native runner.

type NativeRouteCandidate

type NativeRouteCandidate struct {
	Provider       string
	Endpoint       string
	ServerInstance string
	Model          string
	Eligible       bool
}

NativeRouteCandidate is the API-neutral subset of root RouteCandidate used by the native failover provider.

type Runtime

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

Runtime is implementation-local service state that can be constructed from the root facade without depending on root public contract types.

func NewRuntime

func NewRuntime(deps RuntimeDeps) Runtime

NewRuntime constructs implementation state with defaulted dependencies.

func (Runtime) Now

func (r Runtime) Now() time.Time

Now returns the runtime clock value normalized to UTC.

type RuntimeDeps

type RuntimeDeps struct {
	Now Clock
}

RuntimeDeps groups constructor dependencies that are safe to pass from the root facade into internal implementation packages.

func (RuntimeDeps) Clock

func (d RuntimeDeps) Clock() Clock

Clock returns the configured clock or the system clock when no test seam is supplied.

type SessionLogEntry

type SessionLogEntry struct {
	SessionID string
	ModTime   time.Time
	Size      int64
}

SessionLogEntry is an API-neutral projection of one service session log.

func ListSessionLogs

func ListSessionLogs(ctx context.Context, logDir string) ([]SessionLogEntry, error)

ListSessionLogs returns JSONL session logs sorted by session ID.

type SessionSubscriber

type SessionSubscriber func(sessionID string) (<-chan harnesses.Event, error)

SessionSubscriber is the narrow root-facade seam TailSessionLog needs from the in-memory session hub.

type SubprocessCallbacks

type SubprocessCallbacks struct {
	BeforeExecute func()
	BeforeFinal   func(harnesses.FinalData)
	ObserveEvent  func(harnesses.Event) harnesses.Event
	EmitEvent     func(harnesses.Event) bool
	Finalize      func(harnesses.FinalData)
	WriteEnd      func(map[string]string, harnesses.FinalData)
}

SubprocessCallbacks bridge service-owned event/progress/session-log behavior without importing root public service types.

type SubprocessRequest

type SubprocessRequest struct {
	Prompt         string
	SystemPrompt   string
	WorkDir        string
	Permissions    string
	Temperature    *float32
	Seed           *int64
	Reasoning      reasoning.Reasoning
	Timeout        time.Duration
	IdleTimeout    time.Duration
	SessionLogDir  string
	Metadata       map[string]string
	Decision       ExecuteRunnerDecision
	Started        time.Time
	SessionLogPath string
}

SubprocessRequest is the API-neutral request data needed by subprocess harness runner implementations.

Jump to

Keyboard shortcuts

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