praxo-core 0.5.0 → 0.6.0
raw patch · 10 files changed
+103/−39 lines, 10 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Praxo.Agent: [allowedTools] :: AgentOptions -> [String]
+ Praxo.Agent: [policy] :: AgentOptions -> Maybe (String -> Bool)
+ Praxo.Agent: [requirePolicy] :: AgentOptions -> Bool
+ Praxo.Agent: [requireToolScope] :: AgentOptions -> Bool
- Praxo.Agent: AgentOptions :: ([Message] -> IO (Either AgentError Response)) -> (ToolCall -> IO (Either AgentError Json)) -> (String -> IO (Either AgentError ())) -> Int -> Integer -> AgentOptions
+ Praxo.Agent: AgentOptions :: ([Message] -> IO (Either AgentError Response)) -> (ToolCall -> IO (Either AgentError Json)) -> (String -> IO (Either AgentError ())) -> Int -> Integer -> Maybe (String -> Bool) -> [String] -> Bool -> Bool -> AgentOptions
Files
- README.md +4/−2
- REGISTRY.md +12/−6
- api-snapshot.py +3/−1
- conformance/Main.hs +1/−1
- llms.md +10/−4
- llms.txt +10/−4
- praxo-core.cabal +1/−1
- src/Praxo/Agent.hs +39/−17
- src/Praxo/Wire.hs +1/−1
- tests/Main.hs +22/−2
README.md view
@@ -7,7 +7,7 @@ middleware, JSON Schema validation, plugin manifest parsing, and runtime helpers. - Implementation type: Core.-- Package version: `0.5.0`; supported `SPEC_VERSION`: `0.2.0`.+- Package version: `0.6.0`; supported `SPEC_VERSION`: `0.2.0`. - Local gate: all eleven shared vector groups, native regression tests, and source API/parity checks. - Linux and Windows CI run the full suite. Hackage publication uses@@ -18,8 +18,10 @@ - Registry introduction: [REGISTRY.md](https://github.com/axisvela/praxo-core/blob/main/language/haskell/REGISTRY.md) - Machine-readable entry: [llms.txt](https://github.com/axisvela/praxo-core/blob/main/language/haskell/llms.txt) and [llms.md](https://github.com/axisvela/praxo-core/blob/main/language/haskell/llms.md)+- [Examples](https://github.com/axisvela/praxo-core/tree/main/language/haskell/examples): runnable language-specific examples. - Coding-agent contract: [docs/getting-started/coding-agents.md](https://github.com/axisvela/praxo-core/blob/main/docs/getting-started/coding-agents.md)-- Registry: [Hackage](https://hackage.haskell.org/package/praxo-core-0.4.0)+- Registry: [Hackage](https://hackage.haskell.org/package/praxo-core-0.5.0)+- Community: [X](https://x.com/axisvela) · [Weibo](https://weibo.com/u/1936025761) ## Build and Test
REGISTRY.md view
@@ -1,7 +1,7 @@ # PRAXO-CORE Haskell Registry Introduction -**Status:** published. Source version `0.5.0`, source-tag `haskell/v0.5.0`. Published registry version: `0.4.0`. Registry+**Status:** published. Source version `0.6.0`, source+tag `haskell/v0.6.0`. Published registry version: `0.5.0`. Registry pages are release snapshots; verify the published version before relying on a feature. @@ -14,12 +14,12 @@ | Field | Value | | --- | --- | | Package | `praxo-core` |-| Registry | [Hackage](https://hackage.haskell.org/package/praxo-core-0.4.0) |-| Source version | `0.5.0` |-| Published registry version | `0.4.0` |+| Registry | [Hackage](https://hackage.haskell.org/package/praxo-core-0.5.0) |+| Source version | `0.6.0` |+| Published registry version | `0.5.0` | | Install (published) | `cabal install praxo-core` | | Install (source/release prepared) | `cabal install praxo-core` |-| Source tag | `haskell/v0.5.0` |+| Source tag | `haskell/v0.6.0` | | Tier | Core | | Contract | `SPEC_VERSION` `0.2.0` | | Documentation | https://axisvela.github.io/praxo-core/languages/haskell/ |@@ -39,10 +39,16 @@ ## Coding-agent entry +- [Examples](https://github.com/axisvela/praxo-core/tree/main/language/haskell/examples): runnable language-specific examples. - [llms.txt](llms.txt): compact machine-readable entry for this language. - [llms.md](llms.md): Markdown version of the same entry. - [Coding-agent contract](../../docs/getting-started/coding-agents.md): explicit scope, final-argument authorization, denial tests, and verification commands.++## Community++- X: <https://x.com/axisvela>+- Weibo: <https://weibo.com/u/1936025761> ## Boundaries
api-snapshot.py view
@@ -66,7 +66,9 @@ parser = argparse.ArgumentParser() parser.add_argument("--check", action="store_true") args = parser.parse_args()- target = ROOT / "api/0.1.0.txt"+ wire = (ROOT / "src/Praxo/Wire.hs").read_text(encoding="utf-8")+ version = re.search(r'^sdkVersion = "([^"]+)"$', wire, re.MULTILINE)[1]+ target = ROOT / "api" / f"{version}.txt" content = snapshot() if args.check: if not target.is_file() or target.read_text(encoding="utf-8") != content:
conformance/Main.hs view
@@ -61,7 +61,7 @@ then pure (Right (A.toolCallArguments call)) else pure (Left (A.AgentError "TOOL_NOT_FOUND" "tool not found")) sink event = modifyIORef' events (++ [JString event]) >> pure (Right ())- options = A.AgentOptions model tool sink (fromInteger (number (field "maxSteps" input))) (number (field "maxTokens" input))+ options = A.AgentOptions model tool sink (fromInteger (number (field "maxSteps" input))) (number (field "maxTokens" input)) Nothing [] False False result <- A.runAgent options [] (asString (field "prompt" input)) actualEvents <- readIORef events count <- readIORef invocations
llms.md view
@@ -7,12 +7,12 @@ ## Package - package: `praxo-core`-- registry: [Hackage](https://hackage.haskell.org/package/praxo-core-0.4.0)-- source_version: `0.5.0`-- published_version: `0.4.0`+- registry: [Hackage](https://hackage.haskell.org/package/praxo-core-0.5.0)+- source_version: `0.6.0`+- published_version: `0.5.0` - install_published: `cabal install praxo-core` - install_source: `cabal install praxo-core`-- source_tag: `haskell/v0.5.0`+- source_tag: `haskell/v0.6.0` - tier: Core - contract: `SPEC_VERSION` `0.2.0` - documentation: https://axisvela.github.io/praxo-core/languages/haskell/@@ -34,7 +34,13 @@ - Registry introduction: `REGISTRY.md` - Markdown entry: `llms.md` - Compact entry: `llms.txt`+- [Examples](https://github.com/axisvela/praxo-core/tree/main/language/haskell/examples): runnable language-specific examples. - Coding-agent contract: ../../docs/getting-started/coding-agents.md++## Community++- X: <https://x.com/axisvela>+- Weibo: <https://weibo.com/u/1936025761> ## Boundaries
llms.txt view
@@ -7,12 +7,12 @@ # Package - package: `praxo-core`-- registry: [Hackage](https://hackage.haskell.org/package/praxo-core-0.4.0)-- source_version: `0.5.0`-- published_version: `0.4.0`+- registry: [Hackage](https://hackage.haskell.org/package/praxo-core-0.5.0)+- source_version: `0.6.0`+- published_version: `0.5.0` - install_published: `cabal install praxo-core` - install_source: `cabal install praxo-core`-- source_tag: `haskell/v0.5.0`+- source_tag: `haskell/v0.6.0` - tier: Core - contract: `SPEC_VERSION` `0.2.0` - documentation: https://axisvela.github.io/praxo-core/languages/haskell/@@ -34,7 +34,13 @@ - Registry introduction: `REGISTRY.md` - Markdown entry: `llms.md` - Compact entry: `llms.txt`+- [Examples](https://github.com/axisvela/praxo-core/tree/main/language/haskell/examples): runnable language-specific examples. - Coding-agent contract: ../../docs/getting-started/coding-agents.md++# Community++- X: <https://x.com/axisvela>+- Weibo: <https://weibo.com/u/1936025761> # Boundaries
praxo-core.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: praxo-core-version: 0.5.0+version: 0.6.0 synopsis: Embeddable MIT-licensed agent framework for Haskell description: Native agent loop with tools, policy hooks, typed events, memory, checkpoints, context budgets, middleware, JSON Schema validation,
src/Praxo/Agent.hs view
@@ -1,37 +1,59 @@ module Praxo.Agent (AgentError(..), ToolCall(..), Message(..), Response(..), AgentOptions(..), RunResult(..), runAgent) where +import Data.Maybe (isNothing)+ import Praxo.Json (Json, encodeJson) data AgentError = AgentError { errorCode :: String, errorMessage :: String } deriving (Eq, Show) data ToolCall = ToolCall { toolCallId :: String, toolCallName :: String, toolCallArguments :: Json } deriving (Eq, Show) data Message = Message { messageRole :: String, messageContent :: String, messageToolCalls :: [ToolCall], messageToolCallId :: String } deriving (Eq, Show) data Response = Response { responseContent :: String, responseToolCalls :: [ToolCall], inputTokens :: Integer, outputTokens :: Integer } deriving (Eq, Show)-data AgentOptions = AgentOptions { generate :: [Message] -> IO (Either AgentError Response), invoke :: ToolCall -> IO (Either AgentError Json), emit :: String -> IO (Either AgentError ()), maxSteps :: Int, maxTokens :: Integer }+data AgentOptions = AgentOptions { generate :: [Message] -> IO (Either AgentError Response), invoke :: ToolCall -> IO (Either AgentError Json), emit :: String -> IO (Either AgentError ()), maxSteps :: Int, maxTokens :: Integer, policy :: Maybe (String -> Bool), allowedTools :: [String], requirePolicy :: Bool, requireToolScope :: Bool } data RunResult = RunResult { runOutput :: String, runSteps :: Int, runInputTokens :: Integer, runOutputTokens :: Integer, runMessages :: [Message] } deriving (Eq, Show) +ensureAllowed :: Either AgentError () -> IO (Either AgentError a) -> IO (Either AgentError a)+ensureAllowed (Left err) _ = pure (Left err)+ensureAllowed (Right ()) action = action+ runAgent :: AgentOptions -> [Message] -> String -> IO (Either AgentError RunResult)-runAgent options history prompt = do- started <- emit options "run.started"- case started of- Left err -> pure (Left err)- Right () -> do- result <- loop 1 0 0 (history ++ [Message "user" prompt [] ""])- case result of- Left err -> do- _ <- emit options "run.failed"- pure (Left err)- Right value -> do- completed <- emit options "run.completed"- case completed of+runAgent options history prompt =+ case validateOptions options of+ Just err -> pure (Left err)+ Nothing -> do+ started <- emit options "run.started"+ case started of+ Left err -> pure (Left err)+ Right () -> do+ result <- loop 1 0 0 (history ++ [Message "user" prompt [] ""])+ case result of Left err -> do _ <- emit options "run.failed" pure (Left err)- Right () -> pure (Right value)+ Right value -> do+ completed <- emit options "run.completed"+ case completed of+ Left err -> do+ _ <- emit options "run.failed"+ pure (Left err)+ Right () -> pure (Right value) where limit = if maxSteps options > 0 then maxSteps options else 8+ validateOptions opts+ | requirePolicy opts && isNothing (policy opts) =+ Just (AgentError "AGENT_INVALID_OPTIONS" "agent: require policy: policy is required")+ | requireToolScope opts && null (allowedTools opts) =+ Just (AgentError "AGENT_INVALID_OPTIONS" "agent: require tool scope: allowedTools must not be empty")+ | otherwise = Nothing+ authorize kind = case policy options of+ Nothing -> Right ()+ Just hook -> if hook kind then Right () else Left (AgentError "AGENT_POLICY_DENIED" ("agent: " ++ kind ++ " denied"))+ checkTool call+ | not (null (allowedTools options)) && toolCallName call `notElem` allowedTools options =+ Left (AgentError "AGENT_TOOL_NOT_ALLOWED" ("agent: tool " ++ toolCallName call ++ " is not allowed"))+ | otherwise = authorize "tool.invoke" loop step usedIn usedOut messages | step > limit = pure (Left (AgentError "AGENT_MAX_STEPS" "agent: maximum steps exceeded"))- | otherwise = do+ | otherwise = ensureAllowed (authorize "model.generate") $ do generated <- generate options messages case generated of Left err -> pure (Left err)@@ -51,7 +73,7 @@ Left err -> pure (Left err) Right updated -> loop (step + 1) totalIn totalOut updated tools messages [] = pure (Right messages)- tools messages (call:rest) = do+ tools messages (call:rest) = ensureAllowed (checkTool call) $ do event <- emit options "tool.call" case event of Left err -> pure (Left err)
src/Praxo/Wire.hs view
@@ -4,4 +4,4 @@ specVersion = "0.2.0" sdkVersion :: String-sdkVersion = "0.5.0"+sdkVersion = "0.6.0"
tests/Main.hs view
@@ -33,7 +33,7 @@ harmovelaTests mcpTests seamTests- assert "contract version" (specVersion == "0.2.0" && sdkVersion == "0.5.0")+ assert "contract version" (specVersion == "0.2.0" && sdkVersion == "0.6.0") forM_ ["", "01", "1.", "+1", "NaN", "1e", "[1,]", "{\"a\":1,}", "{}{}", "\"\\q\"", "\"\\ud800\"", "\"\\udc00\"", "\"\\ud800\\u0041\"", "\"line\nbreak\"", "true garbage"] $ \raw -> assert ("invalid JSON " ++ show raw) (isLeft (parseJson raw)) assert "unicode escape" (parseJson "\"\\u00e9\\ud83d\\ude00\"" == Right (JString "\x00e9\x1f600"))@@ -103,7 +103,7 @@ n <- readIORef calls pure (Right (if n == 0 then A.Response "" [call] 2 1 else A.Response "done" [] 1 1)) tool _ = modifyIORef' calls (+1) >> pure (Right JNull)- options = A.AgentOptions model tool sink 2 5+ options = A.AgentOptions model tool sink 2 5 Nothing [] False False result <- A.runAgent options [] "hello" assert "agent success and usage" (case result of Right r -> A.runSteps r == 2 && A.runInputTokens r == 3 && A.runOutputTokens r == 2; _ -> False) history <- readIORef requests@@ -153,6 +153,26 @@ limited <- A.runAgent (options { A.maxSteps = 0, A.generate = \_ -> pure (Right (A.Response "" [call] 0 0)) }) [] "x" count <- readIORef calls assert "default step budget" (count == 8 && case limited of Left err -> A.errorCode err == "AGENT_MAX_STEPS"; _ -> False)+ writeIORef events []+ missingPolicy <- A.runAgent (options { A.requirePolicy = True }) [] "x"+ assert "require policy rejects missing hook" (case missingPolicy of Left err -> A.errorCode err == "AGENT_INVALID_OPTIONS" && "require policy" `isInfixOf` A.errorMessage err; _ -> False)+ guardedEvents <- readIORef events+ assert "require policy fails before work starts" (null guardedEvents)+ writeIORef events []+ writeIORef calls 1+ allowedPolicy <- A.runAgent (options { A.requirePolicy = True, A.policy = Just (const True) }) [] "x"+ assert "require policy accepts configured hook" (case allowedPolicy of Right r -> A.runOutput r == "done"; _ -> False)+ writeIORef events []+ missingScope <- A.runAgent (options { A.requireToolScope = True }) [] "x"+ assert "require tool scope rejects empty scope" (case missingScope of Left err -> A.errorCode err == "AGENT_INVALID_OPTIONS" && "require tool scope" `isInfixOf` A.errorMessage err; _ -> False)+ writeIORef events []+ writeIORef calls 1+ scoped <- A.runAgent (options { A.requireToolScope = True, A.allowedTools = ["echo"] }) [] "x"+ assert "require tool scope accepts allowed tools" (case scoped of Right r -> A.runOutput r == "done"; _ -> False)+ writeIORef events []+ writeIORef calls 1+ defaults <- A.runAgent options [] "x"+ assert "safe defaults preserve behavior" (case defaults of Right r -> A.runOutput r == "done"; _ -> False) runtimeTests :: IO () runtimeTests = do