enqueueToolAction builds a PendingAction, enqueues it, and binds to the task. Returns the command ID and true on success, or ("", false) on failure. Use this for modules that manage their own result channel (e.g. upload/download).
(ctx ModuleContext, sessionID string, taskID uint32, toolName string, args map[string]any)
| 142 | // Returns the command ID and true on success, or ("", false) on failure. |
| 143 | // Use this for modules that manage their own result channel (e.g. upload/download). |
| 144 | func enqueueToolAction(ctx ModuleContext, sessionID string, taskID uint32, toolName string, args map[string]any) (string, bool) { |
| 145 | cmdID := sessions.GenerateCommandID() |
| 146 | action := &sessions.PendingAction{ |
| 147 | ID: cmdID, |
| 148 | TaskID: taskID, |
| 149 | Type: sessions.ActionToolCall, |
| 150 | ToolName: toolName, |
| 151 | Arguments: args, |
| 152 | CreatedAt: time.Now(), |
| 153 | } |
| 154 | if !sessions.Global().EnqueueAction(sessionID, action) { |
| 155 | ctx.Tasks.Fail(sessionID, taskID, "enqueue failed") |
| 156 | return "", false |
| 157 | } |
| 158 | ctx.Tasks.BindCommand(sessionID, taskID, cmdID) |
| 159 | return cmdID, true |
| 160 | } |
| 161 | |
| 162 | // execSpite builds a simple ExecResponse Spite for error messages. |
| 163 | func execSpite(message string) *implantpb.Spite { |
no test coverage detected