File size: 9,436 Bytes
12c2cae 205cdf1 8f2700b ecad107 563a647 12c2cae 1aeb859 12c2cae 563a647 205cdf1 12c2cae 8f2700b ec4fcc6 12c2cae 8f2700b 563a647 ecad107 563a647 ecad107 205cdf1 ecad107 25d834f 205cdf1 8f2700b 205cdf1 8f2700b 205cdf1 8f2700b 205cdf1 8f2700b 205cdf1 8f2700b 205cdf1 8f2700b ecad107 8f2700b 12c2cae 205cdf1 c110410 205cdf1 358e009 c9a68de 358e009 25d834f 2404239 12c2cae 8f2700b ec4fcc6 8f2700b 563a647 ecad107 563a647 205cdf1 ecad107 205cdf1 ecad107 25d834f 205cdf1 ecad107 8f2700b 25d834f 8f2700b c110410 25d834f 358e009 c9a68de 2404239 12c2cae | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | """
purpose_agent β A local-first self-improvement kernel for agents.
v3.0 features: event runtime, durable execution, memory homeostasis,
protocol interop, intelligent routing, skill evolution, agentic optimization,
first-principles engineering (O(1) critic, falsification scoring, PEP 578 sandbox),
AND SRE hardening (5 critical patches auto-applied).
"""
__version__ = "3.0.0"
# ββ SRE Patches (auto-apply on import) βββββββββββββββββββββββββββββββββββ
import purpose_agent.sre_patches # noqa: F401 β patches Actor, MemoryStore, ExperienceReplay, Trajectory
# ββ Core ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.types import (
State, Action, Trajectory, TrajectoryStep,
Heuristic, PurposeScore, MemoryRecord, MemoryTier,
)
from purpose_agent.llm_backend import (
LLMBackend, MockLLMBackend, HFInferenceBackend,
OpenAICompatibleBackend, ChatMessage, resolve_backend,
)
from purpose_agent.actor import Actor
from purpose_agent.purpose_function import PurposeFunction
from purpose_agent.experience_replay import ExperienceReplay
from purpose_agent.optimizer import HeuristicOptimizer
from purpose_agent.orchestrator import Orchestrator, Environment, SimpleEnvironment, TaskResult
# ββ First-Principles βββββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.state_delta import compute_state_delta, StateDelta, format_critic_input
from purpose_agent.falsification_critic import FalsificationCritic, FalsificationResult
from purpose_agent.sandbox_hooks import install_sandbox, SandboxPolicy, SandboxViolation, is_sandbox_installed
from purpose_agent.hardening import (
safe_params, safe_string, safe_float, safe_dict_get,
with_timeout, llm_call_with_timeout, graceful,
validate_purpose, ValidationError,
)
# ββ V2 Kernel βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.v2_types import RunMode, MemoryScope, PurposeScoreV2
from purpose_agent.trace import Trace, TraceEvent
from purpose_agent.memory import MemoryStore, MemoryCard, MemoryKind, MemoryStatus
from purpose_agent.compiler import PromptCompiler, CompiledPrompt
from purpose_agent.immune import scan_memory, ScanResult
from purpose_agent.memory_ci import MemoryCI
from purpose_agent.evalport import EvalCase, EvalPort, DictEvalPort, ScoreBundle
from purpose_agent.benchmark_v2 import BenchmarkRunnerV2, V2BenchmarkResult
# ββ V3 Runtime ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.runtime.events import PAEvent, EventKind, Visibility, create_event
from purpose_agent.runtime.event_bus import EventBus, parallel_merge
# ββ Research Implementations ββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.meta_rewarding import MetaRewardingLoop
from purpose_agent.self_taught import SelfTaughtEvaluator
from purpose_agent.prompt_optimizer import PromptOptimizer, Signature, Demonstration
from purpose_agent.llm_compiler import LLMCompiler, ExecutionPlan, TaskNode
from purpose_agent.retroformer import Retroformer
# ββ SLM-Native Backends ββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.slm_backends import (
OllamaBackend, LlamaCppBackend, SLMPromptCompressor,
create_slm_backend, SLM_REGISTRY,
)
# ββ Streaming & Async ββββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.streaming import StreamingMixin, StreamEvent, AsyncOrchestrator
# ββ Tools ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.tools import (
Tool, FunctionTool, ToolResult, ToolRegistry,
CalculatorTool, PythonExecTool, ReadFileTool, WriteFileTool,
)
# ββ Observability ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.observability import (
CostTracker, TokenUsage, CallbackManager,
AgentEvent, EventType, LoggingCallback, MetricsCollector,
)
# ββ Multi-Agent ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.multi_agent import AgentSpec, AgentTeam
# ββ Human-in-the-Loop βββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.hitl import (
HITLOrchestrator, Checkpoint, HumanInputHandler,
CLIInputHandler, AutoApproveHandler, InterruptType,
)
# ββ Evaluation βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.evaluation import BenchmarkTask, BenchmarkRunner, BenchmarkResult
# ββ Plugin Registry ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.registry import (
PluginRegistry, backend_registry, callback_registry, model_registry,
EmbeddingBackend, default_embedding,
)
# ββ Unified Capabilities ββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.unified import (
Agent, Graph, parallel, Conversation, KnowledgeStore,
START, END, Message,
Spark, Flow, swarm, Council, Vault, BEGIN, DONE_SIGNAL,
)
# ββ Easy API βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
from purpose_agent.easy import purpose, Team, quickstart, TEAM_TEMPLATES
__all__ = [
# Core
"State", "Action", "Trajectory", "TrajectoryStep", "Heuristic",
"PurposeScore", "MemoryRecord", "MemoryTier",
"LLMBackend", "MockLLMBackend", "HFInferenceBackend",
"OpenAICompatibleBackend", "ChatMessage", "resolve_backend",
"Actor", "PurposeFunction", "ExperienceReplay", "HeuristicOptimizer",
"Orchestrator", "Environment", "SimpleEnvironment", "TaskResult",
# First-Principles + Hardening
"compute_state_delta", "StateDelta", "format_critic_input",
"FalsificationCritic", "FalsificationResult",
"install_sandbox", "SandboxPolicy", "SandboxViolation", "is_sandbox_installed",
"safe_params", "safe_string", "safe_float", "safe_dict_get",
"with_timeout", "llm_call_with_timeout", "graceful",
"validate_purpose", "ValidationError",
# V2 Kernel
"RunMode", "MemoryScope", "PurposeScoreV2",
"Trace", "TraceEvent",
"MemoryStore", "MemoryCard", "MemoryKind", "MemoryStatus",
"PromptCompiler", "CompiledPrompt",
"scan_memory", "ScanResult", "MemoryCI",
"EvalCase", "EvalPort", "DictEvalPort", "ScoreBundle",
"BenchmarkRunnerV2", "V2BenchmarkResult",
# V3 Runtime
"PAEvent", "EventKind", "Visibility", "create_event",
"EventBus", "parallel_merge",
# Research
"MetaRewardingLoop", "SelfTaughtEvaluator",
"PromptOptimizer", "Signature", "Demonstration",
"LLMCompiler", "ExecutionPlan", "TaskNode", "Retroformer",
# SLM
"OllamaBackend", "LlamaCppBackend", "SLMPromptCompressor",
"create_slm_backend", "SLM_REGISTRY",
# Streaming
"StreamingMixin", "StreamEvent", "AsyncOrchestrator",
# Tools
"Tool", "FunctionTool", "ToolResult", "ToolRegistry",
"CalculatorTool", "PythonExecTool", "ReadFileTool", "WriteFileTool",
# Observability
"CostTracker", "TokenUsage", "CallbackManager",
"AgentEvent", "EventType", "LoggingCallback", "MetricsCollector",
# Multi-Agent
"AgentSpec", "AgentTeam",
# HITL
"HITLOrchestrator", "Checkpoint", "HumanInputHandler",
"CLIInputHandler", "AutoApproveHandler", "InterruptType",
# Evaluation
"BenchmarkTask", "BenchmarkRunner", "BenchmarkResult",
# Plugin Registry
"PluginRegistry", "backend_registry", "callback_registry", "model_registry",
"EmbeddingBackend", "default_embedding",
# Unified Capabilities
"Agent", "Graph", "parallel", "Conversation", "KnowledgeStore",
"START", "END", "Message",
"Spark", "Flow", "swarm", "Council", "Vault", "BEGIN", "DONE_SIGNAL",
# Easy API
"purpose", "Team", "quickstart", "TEAM_TEMPLATES",
]
|