/** Datei: plugins/agents/library/ARUNOX/Plugins/Agents/Calls/Model.php **/ Agents\Model::getValue( $agentId, "id" ), "chat_hashid" => $chatHashId, ])); } } /** Datei: plugins/agents/library/ARUNOX/Plugins/Agents/Calls/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Agents\Calls\API\v1; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; use ARUNOX\Plugins\REST; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ // Router::add([ Controller::class, "getAll" ]); // Router::add([ Controller::class, "get" ]); // Router::add([ Controller::class, "getTypeAsOptions" ]); // // Router::add([ Controller::class, "create" ]); // Router::add([ Controller::class, "save" ]); // Router::add([ Controller::class, "delete" ]); // Router::add([ Controller::class, "toggleStatus" ]); // // /* ### REST ROUTES ############################## # */ // Router::add([ Controller::class, "restConfigDetails" ]); // Router::add([ Controller::class, "restConfigCreate" ]); // Router::add([ Controller::class, "restConfigDelete" ]); // // Router::add([ Controller::class, "restResponseCreate" ]); // Router::add([ Controller::class, "restResponseSave" ]); // Router::add([ Controller::class, "restResponseDelete" ]); // Router::add([ Controller::class, "restResponseToggleStatus" ]); } } /** Datei: plugins/agents/library/ARUNOX/Plugins/Agents/Calls/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\Agents\Calls\API\v1; use ARUNOX\HTTP; use ARUNOX\Plugins\REST; use ARUNOX\Plugins\Agents; use ARUNOX\API\BaseController; class Controller extends BaseController { /* ### VARIABLES ################################################ # */ protected static array $NOTIFY = [ "notfound" => "Call nicht gefunden", "saved" => "Call wurde erfolgreich gespeichert", "deleted" => "Call wurde erfolgreich gelöscht", "created" => "Call wurde erfolgreich erstellt", "statuschanged.0" => "Call wurde erfolgreich deaktiviert", "statuschanged.1" => "Call wurde erfolgreich aktiviert", "notcreated" => "Call konnte nicht erstellt werden", "notsaved" => "Call konnte nicht gespeichert werden", ]; /* ### PUBLIC FUNCTIONS ######################################### # */ /** * @api * @method GET * * @route.path /agents/{id}/calls/{id} * @route.description Listet alle Calls eines Chats auf */ public static function getAllOwn( string $agentHashId, string $chatHashId, array $where = [] ) : array { return Agents\Calls\Model::getByAgent( $agentHashId, $chatHashId, $where ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /agents/{id}/tools/{id} * @route.description Aktualisiert die Eigenschaften eines Tools */ public static function save( string $agentHashId, string $chatHashId, array $data ) : HTTP\Response { if( $result = Calls\Tools\Model::get([ "id" => $id, "origin_id" => $origin ]) ) { if( $result->save( $data ) ) { return REST\Response::jsonResponse( 200, static::getNotify("saved") ); } return REST\Response::jsonResponse( 500, static::getNotify("notsaved") ); } return REST\Response::jsonResponse( 404, static::getNotify("notfound") ); } /** * @api * @method POST * * @route.path /agents/{id}/calls/{id} * @route.description Erstellt einen neuen Call für einen Chat */ public static function create( string $agentHashId, string $chatHashId, array $data ) : HTTP\Response { $data[ "origin_id" ] = Agents\Model::getValue( $agentHashId ); $data[ "chat_hashid" ] = $chatHashId; if( $hashid = Agents\Calls\Model::save( $data ) ) { $result = Agents\Calls\Model::get( $hashid ); return REST\Response::jsonResponse( 200, static::getNotify("created"), [ "data" => $result ] ); } return REST\Response::jsonResponse( 500, static::getNotify("notfound") ); } /** * @api * @method DELETE * * @route.path /agents/{id}/calls/{id} * @route.description Löscht ein Tool eines Agenten */ public static function delete( string $agentHashId, string $callHashId ) : HTTP\Response { $agent = Agents\Model::getValue( $agentHashId ); if( Agents\Calls\Model::delete([ "hashid" => $callHashId, "origin_id" => $agent ]) ) { return REST\Response::jsonResponse( 200, static::getNotify("deleted") ); } return REST\Response::jsonResponse( 500, static::getNotify("notfound") ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST FUNCTIONS #################################### # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /* ### PUBLIC REST TYPE FUNCTIONS ############################### # */ } /** Datei: plugins/agents/library/ARUNOX/Plugins/Agents/Calls/Source.php **/ [ "color" => REST\Generator\Config\Color::Info, "label" => "API", "icon" => "bi bi-code" ], self::Cron => [ "color" => REST\Generator\Config\Color::Info, "label" => "Cron", "icon" => "bi bi-clock" ], self::Phone => [ "color" => REST\Generator\Config\Color::Info, "label" => "Phone", "icon" => "bi bi-telephone" ], self::Admin => [ "color" => REST\Generator\Config\Color::Info, "label" => "Admin", "icon" => "bi bi-shield-lock" ], self::Webchat => [ "color" => REST\Generator\Config\Color::Info, "label" => "Webchat", "icon" => "bi bi-globe" ], self::Backend => [ "color" => REST\Generator\Config\Color::Info, "label" => "Backend", "icon" => "bi bi-cpu" ], ]; /* ### PUBLIC FUNCTIONS ######################################### # */ } /** Datei: plugins/agents/library/ARUNOX/Plugins/Agents/Calls/Type.php **/ [ "color" => REST\Generator\Config\Color::Info, "label" => "Text", "icon" => "bi bi-chat-dots" ], self::Image => [ "color" => REST\Generator\Config\Color::Info, "label" => "Image", "icon" => "bi bi-image" ], self::AudioIn => [ "color" => REST\Generator\Config\Color::Info, "label" => "Audio in", "icon" => "bi bi-mic" ], self::AudioOut => [ "color" => REST\Generator\Config\Color::Info, "label" => "Audio out", "icon" => "bi bi-volume-up" ], self::ToolCall => [ "color" => REST\Generator\Config\Color::Info, "label" => "Tool Call", "icon" => "bi bi-plug" ], self::ToolResult => [ "color" => REST\Generator\Config\Color::Info, "label" => "Tool Result", "icon" => "bi bi-check-circle" ], self::System => [ "color" => REST\Generator\Config\Color::Info, "label" => "System", "icon" => "bi bi-terminal" ], ]; /* ### PUBLIC FUNCTIONS ######################################### # */ } /** Datei: plugins/agents/library/ARUNOX/Plugins/Agents/Calls/Entity.php **/ Status::class, "type" => Type::class, "role" => Role::class, "source" => Source::class, "date_create" => Attribute\DateTime::class, "date_edit" => Attribute\DateTime::class, ]; /* ### PUBLIC FUNCTIONS ######################################### # */ public function toggleStatus( bool $save = FALSE ) { $this->status->toggle(); if( $save ) $this->save(); } } /** Datei: plugins/agents/library/ARUNOX/Plugins/Agents/Calls/Status.php **/ [ "color" => REST\Generator\Config\Color::Default, "label" => "Draft", "icon" => "bi bi-dash-circle" ], self::Waiting => [ "color" => REST\Generator\Config\Color::Info, "label" => "Waiting", "icon" => "bi bi-hourglass-split" ], self::InProgress => [ "color" => REST\Generator\Config\Color::Warning, "label" => "InProgress", "icon" => "bi bi-cpu" ], self::Completed => [ "color" => REST\Generator\Config\Color::Success, "label" => "Completed", "icon" => "bi bi-check-circle" ], self::Incomplete => [ "color" => REST\Generator\Config\Color::Danger, "label" => "Incomplete", "icon" => "bi bi-exclamation-triangle" ], self::Failed => [ "color" => REST\Generator\Config\Color::Danger, "label" => "Error", "icon" => "bi bi-exclamation-triangle" ], self::Skipped => [ "color" => REST\Generator\Config\Color::Info, "label" => "Skipped", "icon" => "bi bi-slash-circle" ], ]; /* ### PUBLIC FUNCTIONS ######################################### # */ /* ### MAGIC FUNCTIONS ########################################## # */ }