jev

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HeuristicRoute

func HeuristicRoute(prompt string, allTools []llm.ToolDefinition) ([]llm.ToolDefinition, string)

HeuristicRoute is "mini JEV": an offline keyword router used when the remote JEV classifier is unavailable (no API key, endpoint errors, or backing off). It scores keyword hits per category — English and Indonesian — then filters through filterToolsByCategory, so universal tools (coordination + computer-use) and explicitly cited tools behave exactly like the remote path. Returns the routed tools and the category.

func UniversalToolNames

func UniversalToolNames() []string

UniversalToolNames returns the tools that stay available in every routing outcome — coordination/workflow tools plus the native desktop control set (every input action is approval-gated in the agent, so always offering them is safe). Routing must never leave the model with no capabilities at all: a "general chat" classification that strips every tool makes the model hallucinate a toolset from training data.

Types

type RoleDecision

type RoleDecision struct {
	Role       string  `json:"role"`
	Reason     string  `json:"reason"`
	Confidence float64 `json:"confidence"`
	Source     string  `json:"source"`
}

RoleDecision captures Jev's sub-agent role recommendation and rationale.

func HeuristicRoleDecision

func HeuristicRoleDecision(task string, availableRoles []string) *RoleDecision

HeuristicRoleDecision determines the optimal sub-agent role using fast keyword and intent heuristics.

type RouteDecision

type RouteDecision struct {
	Category   string  `json:"category"`
	Confidence float64 `json:"confidence"`
	NeedsTools float64 `json:"needs_tools"`
	Model      string  `json:"model"`
}

RouteDecision captures Jev's classification and confidence metrics for an agent turn.

type Router

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

Router uses TypeSafe AI's Jev model as a high-speed System One classifier to select the exact tools an LLM needs for a task, preventing token bloat, tool hallucinations, and inappropriate script execution.

func NewRouter

func NewRouter(apiKey string, dataDir ...string) *Router

NewRouter creates a new Jev tool router. If apiKey is empty, it attempts to load from environment or .env files. Optional dataDir specifies where to persist jev_stats.json.

func (*Router) DecideAgentRole

func (r *Router) DecideAgentRole(ctx context.Context, task string, availableRoles []string) *RoleDecision

DecideAgentRole queries Jev to classify a task into the optimal sub-agent role ('research', 'planning', 'coding', or a custom role). If Jev is not configured, times out, or fails, it falls back to fast heuristic role decision.

func (*Router) DecideSubagent

func (r *Router) DecideSubagent(ctx context.Context, task string, candidates []SubagentCandidate) *SubagentDecision

DecideSubagent selects the best-suited sub-agent candidate for a task to be delegated. It matches task semantics against candidates' names, roles, and descriptions.

func (*Router) GetAPIKey

func (r *Router) GetAPIKey() string

GetAPIKey returns the currently configured API key (masked or plain).

func (*Router) GetStats

func (r *Router) GetStats() map[string]interface{}

GetStats returns usage and performance metrics for the Jev tool router.

func (*Router) IsEnabled

func (r *Router) IsEnabled() bool

IsEnabled returns true if a valid TypeSafe API key is configured and not in cooldown.

func (*Router) Route

func (r *Router) Route(ctx context.Context, prompt string, allTools []llm.ToolDefinition) ([]llm.ToolDefinition, *RouteDecision)

Route asks Jev to classify the goal/prompt and filters the given tool definitions to only the relevant tools. If Jev is not enabled, times out, or fails, it gracefully returns the original tools with no error so the agent continues normally.

func (*Router) SetAPIKey

func (r *Router) SetAPIKey(key string)

SetAPIKey dynamically updates the router's API key.

type RouterStats

type RouterStats struct {
	TotalRequests    int            `json:"total_requests"`
	TotalRoutes      int            `json:"total_routes"`
	CategoryCounts   map[string]int `json:"category_counts"`
	RoleCounts       map[string]int `json:"role_counts,omitempty"`
	PromptTokens     int64          `json:"prompt_tokens"`
	CompletionTokens int64          `json:"completion_tokens"`
	TotalTokens      int64          `json:"total_tokens"`
	TokensSaved      int64          `json:"tokens_saved"`
	TotalLatencyMs   int64          `json:"total_latency_ms"`
}

RouterStats tracks cumulative usage metrics for Jev routing decisions.

type SubagentCandidate

type SubagentCandidate struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Role        string `json:"role"`
	Description string `json:"description"`
}

SubagentCandidate represents a sub-agent definition available for Jev delegation.

type SubagentDecision

type SubagentDecision struct {
	SelectedID string  `json:"selected_id"`
	Name       string  `json:"name"`
	Role       string  `json:"role"`
	Reason     string  `json:"reason"`
	Confidence float64 `json:"confidence"`
	Source     string  `json:"source"`
}

SubagentDecision captures Jev's sub-agent recommendation.

func HeuristicSubagentDecision

func HeuristicSubagentDecision(task string, candidates []SubagentCandidate) *SubagentDecision

HeuristicSubagentDecision matches the task against candidate sub-agents using intent and keyword scoring.

Jump to

Keyboard shortcuts

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