2025-05-23 16:02:16 +02:00
|
|
|
import base64
|
2025-05-22 20:03:22 +02:00
|
|
|
import ./types
|
|
|
|
|
import ./commands/commands
|
|
|
|
|
|
|
|
|
|
proc handleTask*(task: Task): Task =
|
|
|
|
|
|
|
|
|
|
# Handle task command
|
|
|
|
|
case task.command:
|
|
|
|
|
of ExecuteShell:
|
|
|
|
|
|
2025-05-23 16:02:16 +02:00
|
|
|
let (output, status) = taskShell(task.args)
|
|
|
|
|
echo output
|
2025-05-22 20:03:22 +02:00
|
|
|
|
|
|
|
|
return Task(
|
|
|
|
|
id: task.id,
|
|
|
|
|
agent: task.agent,
|
|
|
|
|
command: task.command,
|
|
|
|
|
args: task.args,
|
2025-05-23 16:02:16 +02:00
|
|
|
result: encode(output), # Base64 encode result
|
|
|
|
|
status: status
|
2025-05-22 20:03:22 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
echo "Not implemented"
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
|
|
return task
|