packages feed

A-gent 0.11.0.3 → 0.11.0.4

raw patch · 4 files changed

+36/−40 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

A-gent.cabal view
@@ -9,7 +9,7 @@ build-type: Simple                                                name: A-gent-version: 0.11.0.3+version: 0.11.0.4  synopsis: Polite & well educated LLM agent with excellent manners that always behaves well description: Polite and well educated LLM agent with excellent manners that always behaves well
CHANGELOG.md view
@@ -1,5 +1,16 @@ # Revision history for Λ-gent +## 0.11.0.4  -- 2026-03-08++* Fixed the `BUG` when trying to print emojii's ('🍎', '🍏', …):++  ```shell+  <stdout>: hPutChar: invalid argument (cannot encode character '\55357'+  ```+  +  by adding `setLocaleEncoding utf8` to `replWithMode`. Now instead of crashing,+  invalid `UTF-8` characters will just be shown as single or multiple `?`.+ ## 0.11.0.3  -- 2026-03-06  * Made `read` usable by providing support for:@@ -43,4 +54,4 @@  * Use of a fourth component [Version scheme][haskell-stack-ver]. -[haskell-stack-ver]: https://docs.haskellstack.org/en/v3.5.1/maintainers/version_scheme/#use-of-a-fourth-component+[haskell-stack-ver]: https://docs.haskellstack.org/en/stable/maintainers/version_scheme/#use-of-a-fourth-component
src/Agent/IO/Restricted.hs view
@@ -6,8 +6,6 @@ {-# LANGUAGE FlexibleContexts             #-} {-# LANGUAGE UndecidableInstances         #-} -{-# LANGUAGE LambdaCase                   #-}- {-# LANGUAGE MonoLocalBinds               #-}  --------------------------------------------------------------------------------@@ -228,12 +226,6 @@  instance StdOut RIO where   output x = RestrictedIO $-    {- BUG: Emojis can't be printed to console (UTF-16 "surrogate pairs")-       <stdout>: hPutChar: invalid argument (cannot encode character '\55357'-    hSetEncoding stdout utf8 >>-    hPutStr      stdout x >>-    hFlush       stdout-    -}     putStr x >> hFlush stdout  --------------------------------------------------------------------------------@@ -255,9 +247,9 @@       (exitcode, out, err) <- readProcessWithExitCode app fs []       case exitcode of         ExitSuccess ->-          return $ Right out+          pure $ Right out         ExitFailure _ ->-          return $ Left err+          pure $ Left err  -------------------------------------------------------------------------------- @@ -280,27 +272,19 @@       (Nothing, _ ) ->         RestrictedIO $ pure $ Left "No API address was provided"       (Just api, Nothing) ->-        ( \ case-              Right env -> Right env-              Left  err -> Left  err-        )-        <$> withExitCode "curl"-            [ "--silent"-            , "--show-error"-            , "--header" , "\"Content-Type: application/json; charset=utf-8\""-            , "--data"   , json-            , api ++ "/chat/completions"-            ]+        withExitCode "curl"+          [ "--silent"+          , "--show-error"+          , "--header" , "\"Content-Type: application/json; charset=utf-8\""+          , "--data"   , json+          , api ++ "/chat/completions"+          ]       (Just api, Just key) ->-        ( \ case-              Right env -> Right env-              Left  err -> Left  err-        )-        <$> withExitCode "curl" -- "echo" -- -            [ "--silent"-            , "--show-error"-            , "--header" , "\"Authorization: \"" ++ key ++ "\" "-            , "--header" , "\"Content-Type: application/json; charset=utf-8\""-            , "--data"   , json-            , api ++ "/chat/completions"-            ]+        withExitCode "curl"+          [ "--silent"+          , "--show-error"+          , "--header" , "\"Authorization: \"" ++ key ++ "\""+          , "--header" , "\"Content-Type: application/json; charset=utf-8\""+          , "--data"   , json+          , api ++ "/chat/completions"+          ]
src/Agent/LLM.hs view
@@ -41,10 +41,13 @@   ) import           System.IO   ( BufferMode(NoBuffering)-  , hFlush, hSetBuffering, hSetEcho, hSetEncoding+  , hFlush, hSetBuffering, hSetEcho   , stderr, stdin, stdout   , utf8   )+import           GHC.IO.Encoding+  ( setLocaleEncoding+  )  import           Agent.IO.Restricted import           Agent.JSON@@ -103,12 +106,10 @@   -> IO () replWithMode mod proc =   do+    setLocaleEncoding utf8     hSetBuffering stderr NoBuffering     hSetBuffering stdin  NoBuffering     hSetBuffering stdout NoBuffering-    hSetEncoding  stderr utf8-    hSetEncoding  stdin  utf8-    hSetEncoding  stdout utf8     hSetEcho      stdin  False -- NOTE: No default output when typing     putStrLn head >> hFlush stdout     run $ loop ctx proc@@ -179,6 +180,6 @@   "# Supported commands\n" ++   "* /help : This message\n" ++   "* /exit : Quit Λ-gent\n" ++-  "* /mode : Change mode to {" ++ ms ++ "}`. Ex: `/mode code`\n"+  "* /mode : Change mode to {" ++ ms ++ "}`. Ex:`/mode code`"   where     ms = foldl1 (\ x y -> x ++ "|" ++ y) $ map (map toLower . show) modes