summaryrefslogtreecommitdiff
path: root/Omni/Agent.hs
diff options
context:
space:
mode:
authorOmni Worker <bot@omni.agent>2025-11-21 05:14:53 -0500
committerOmni Worker <bot@omni.agent>2025-11-21 05:21:19 -0500
commitc3ab8403df5e5ed99e6769dcdc152408d57026a7 (patch)
treecbbb86ff96bea7b16e9cb458cede274e6dc0c38a /Omni/Agent.hs
parentd0c03d25d5d81b83fc2a8e3928e85bdd4b5b1ee0 (diff)
feat: implement Omni.Agent.Worker loop logic
Amp-Thread-ID: https://ampcode.com/threads/T-4f2905ef-a042-4880-b146-f6809ce83751 Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'Omni/Agent.hs')
-rw-r--r--Omni/Agent.hs62
1 files changed, 62 insertions, 0 deletions
diff --git a/Omni/Agent.hs b/Omni/Agent.hs
new file mode 100644
index 0000000..7a31d40
--- /dev/null
+++ b/Omni/Agent.hs
@@ -0,0 +1,62 @@
+{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE QuasiQuotes #-}
+{-# LANGUAGE LambdaCase #-}
+{-# LANGUAGE NoImplicitPrelude #-}
+
+-- : out agent
+-- : dep temporary
+module Omni.Agent where
+
+import Alpha
+import qualified Data.Text as Text
+import qualified Omni.Cli as Cli
+import qualified Omni.Agent.Core as Core
+import qualified Omni.Agent.Worker as Worker
+import qualified Omni.Test as Test
+
+main :: IO ()
+main = Cli.main plan
+
+plan :: Cli.Plan ()
+plan =
+ Cli.Plan
+ { Cli.help = help
+ , Cli.move = move
+ , Cli.test = test
+ , Cli.tidy = \_ -> pure ()
+ }
+
+help :: Cli.Docopt
+help = [Cli.docopt|
+agent
+
+Usage:
+ agent start <name> [--path=<path>]
+ agent test
+ agent --help
+
+Options:
+ --path=<path> Path to the worker directory [default: .]
+ --help Show this help
+|]
+
+move :: Cli.Arguments -> IO ()
+move args
+ | args `Cli.has` Cli.command "start" = do
+ name <- Cli.getArg args (Cli.argument "name") |> \case
+ Just n -> pure (Text.pack n)
+ Nothing -> panic "Name required"
+ let path = Cli.getArgWithDefault args "." (Cli.longOption "path")
+
+ let worker = Core.Worker
+ { Core.workerName = name
+ , Core.workerPid = Nothing
+ , Core.workerStatus = Core.Idle
+ , Core.workerPath = path
+ }
+
+ Worker.start worker
+ | otherwise = putStrLn (Cli.usage help)
+
+test :: Test.Tree
+test = Test.group "Omni.Agent" []