From 3e3ca74a67b690713b0f99e63c73b315e89b43d9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 May 2026 01:27:19 +0200 Subject: [PATCH] Debug AI assistant and MCP server --- dev/translation/dynamic_translation_keys.lst | 1 + htdocs/ai/admin/assistant.php | 417 +++++++++++++++++++ htdocs/ai/admin/server_mcp.php | 7 +- htdocs/ai/admin/setup.php | 10 - htdocs/ai/assistant/parse_intent.php | 5 +- htdocs/ai/lib/ai.lib.php | 7 + htdocs/ai/tools/crud_objects.class.php | 6 +- htdocs/ai/tools/thirdparty.class.php | 25 +- htdocs/core/modules/modQuickMemo.class.php | 2 +- htdocs/langs/en_US/admin.lang | 6 +- htdocs/main.inc.php | 2 +- 11 files changed, 457 insertions(+), 31 deletions(-) create mode 100644 htdocs/ai/admin/assistant.php diff --git a/dev/translation/dynamic_translation_keys.lst b/dev/translation/dynamic_translation_keys.lst index 526f9913597..bc5bc59f711 100644 --- a/dev/translation/dynamic_translation_keys.lst +++ b/dev/translation/dynamic_translation_keys.lst @@ -10,6 +10,7 @@ AiDescription AiDescriptionLong AiSetup +AIError # datapolicy DATAPOLICY_ADHERENT diff --git a/htdocs/ai/admin/assistant.php b/htdocs/ai/admin/assistant.php new file mode 100644 index 00000000000..908d2222f91 --- /dev/null +++ b/htdocs/ai/admin/assistant.php @@ -0,0 +1,417 @@ + + * Copyright (C) 2022 Alice Adminson + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France + * Coryright (C) 2024 Alexandre Spangaro + * Copyright (C) 2026 Nick Fragoulis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/ai/admin/server_mcp.php + * \ingroup ai + * \brief MCP Server & Assistant Configuration Page + */ + +require '../../main.inc.php'; +/** + * @var Conf $conf + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + * @var Form $form + */ +require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT . "/core/class/html.form.class.php"; +require_once DOL_DOCUMENT_ROOT . "/core/class/doleditor.class.php"; +require_once DOL_DOCUMENT_ROOT . "/ai/lib/ai.lib.php"; +require_once DOL_DOCUMENT_ROOT . "/core/lib/functions2.lib.php"; +require_once DOL_DOCUMENT_ROOT . "/core/lib/security.lib.php"; + + +$langs->loadLangs(array("admin", "website", "other")); + +// Access control +if (!$user->admin) { + accessforbidden(); +} +if (!isModEnabled('ai')) { + accessforbidden('Module AI not activated.'); +} + +// Parameters +$action = GETPOST('action', 'aZ09'); +$backtopage = GETPOST('backtopage', 'alpha'); + + +/** + * ACTIONS + */ + +// Main Settings +if ($action == 'update') { + $error = 0; + + if (GETPOSTISSET('AI_ASK_FOR_CONFIRMATION')) { + $res = dolibarr_set_const($db, "AI_ASK_FOR_CONFIRMATION", GETPOSTINT("AI_ASK_FOR_CONFIRMATION"), 'int', 0, '', $conf->entity); + if ($res <= 0) $error++; + } + + if (GETPOSTISSET('AI_LOG_RETENTION')) { + $res = dolibarr_set_const($db, "AI_LOG_RETENTION", GETPOST("AI_LOG_RETENTION"), 'int', 0, '', $conf->entity); + if ($res <= 0) { + $error++; + } + } + + if (GETPOSTISSET('AI_DEFAULT_INPUT_MODE')) { + $res = dolibarr_set_const($db, "AI_DEFAULT_INPUT_MODE", GETPOST("AI_DEFAULT_INPUT_MODE"), 'chaine', 0, '', $conf->entity); + if ($res <= 0) { + $error++; + } + } + + if (GETPOSTISSET('AI_INTENT_PROMPT')) { + $res = dolibarr_set_const($db, "AI_INTENT_PROMPT", GETPOST("AI_INTENT_PROMPT"), 'chaine', 0, '', $conf->entity); + if ($res <= 0) { + $error++; + } + } + + if ($error) { + setEventMessages($langs->trans("ErrorSavingSettings"), null, 'errors'); + } else { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home"); + exit; +} + +// Test connection +if ($action == 'test_provider') { + $service = GETPOST('service_key', 'aZ09'); + if ($service) { + $credential = getDolGlobalString('AI_API_' . strtoupper($service) . '_KEY'); + $url = getDolGlobalString('AI_API_' . strtoupper($service) . '_URL'); + + // Decrypt if needed + if (preg_match('/^crypted:/', $credential)) { + $credential = dol_decode(substr($credential, 8)); + } elseif (preg_match('/^dolcrypt:/', $credential)) { + $credential = dolDecrypt($credential, ''); + } + + // Only proceed if the key is valid (decrypted or not encrypted) + if ($credential !== null) { + $res = testAIConnection($service, $credential, $url); + + if ($res['success']) { + setEventMessages($langs->trans("ConnectionSuccessful") . $res['message'], null, 'mesgs'); + } else { + setEventMessages($langs->trans("ConnectionFailed") . $res['message'], null, 'errors'); + } + } + } +} + +// External Access Settings +if ($action == 'update_external') { + $error = 0; + + $user_id = GETPOSTINT("AI_MCP_USER_ID"); + if (GETPOSTISSET('AI_MCP_USER_ID')) { + $res = dolibarr_set_const($db, "AI_MCP_USER_ID", $user_id, 'int', 0, '', $conf->entity); + if ($res <= 0) { + $error++; + } + } + + if ($error) { + setEventMessages($langs->trans("ErrorSavingSettings"), null, 'errors'); + } else { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + + header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home"); + exit; +} + +// Generate New API Key +if ($action == 'generate_key') { + $newKey = dolGetRandomBytes(64); + + if (empty($newKey)) { + setEventMessages($langs->trans("KeyGenerationFailed"), null, 'errors'); + } else { + if (dolibarr_set_const($db, 'AI_MCP_API_KEY', $newKey, 'chaine', 0, '', $conf->entity) > 0) { + setEventMessages($langs->trans("KeyGenerationSuccessfull"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("KeySaveFailed"), null, 'errors'); + } + } +} + + +/* + * VIEW + */ + +$help_url = ''; +$title = "AiSetup"; + +llxHeader('', $langs->trans($title), $help_url, '', 0, 0, '', '', '', 'mod-ai page-admin'); + +$linkback = ''.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').''.$langs->trans("BackToModuleList").''; + +print load_fiche_titre($langs->trans($title), $linkback, 'title_setup'); + + +$head = aiAdminPrepareHead(); +print dol_get_fiche_head($head, 'assistant', "MCP Server", -1, "ai"); + +print '' . $langs->trans("ConfigAssistantHelp") . '

'; + +$form = new Form($db); + +// Load Current Values +$apiKey = getDolGlobalString('AI_MCP_API_KEY'); + +// Default Prompt Logic +$defaultPromptText = " ROLE: Dolibarr ERP AI. +GOAL: Map user intent to specific JSON commands. + +CONSTRAINTS: +1. OUTPUT: Single valid JSON object ONLY. No Markdown. No text. + Format: {\"tool\": \"tool_name\", \"arguments\": {\"argument_name\": \"argument_value\", ...}} +2. TOOLS: Use ONLY provided tools. If no tool or thirdparty fits, you must first use 'respond_to_user' to inform user. +3. ARGS: strict adherence to schema. Do not invent parameters. +4. MISSING INFO: If a required argument (like an ID) is missing, use 'ask_for_clarification'. +5. SAFETY: For DELETE/UPDATE actions, you MUST use 'ask_for_confirmation'."; + +$currentPrompt = getDolGlobalString('AI_INTENT_PROMPT', $defaultPromptText); + +// Settings +print '
'; +//print ''; + +// Enable/Disable +//print ''; +//print ''; +//print ''; +//print ''; + +//print '
' +print $form->textwithpicto($langs->trans('EnableAssistant'), $langs->trans('DisableAssistant')); +//print ''; +print '   '; +print ajax_constantonoff('AI_ASSISTANT_ENABLED', array(), null, 0, 0, 1); +//print ' ' . $langs->trans('DisableMCPAI') . ''; +//print '
'; +print '
'; + +print '
'; +print '
'; + +if (getDolGlobalString('AI_ASSISTANT_ENABLED')) { + print load_fiche_titre($langs->trans("PrivateModeTitle"), '', 'fas fa-lock'); + + print '
'; + print ''; + print ''; + + print '
'; + print ''; + + // Input Mode + print ''; + print ''; + print ''; + print ''; + + // Enhanced Privacy control + print ''; + print ''; + print ''; + print ''; + + // Confirmation Level + print ''; + print ''; + print ''; + print ''; + + // Logging + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + // System Prompt + print ''; + print ''; + print ''; + + print '
'; + print $form->textwithpicto('Default Interface', $langs->trans("InputMethodHelp")); + print ''; + $input_modes = [ + 'text' => $langs->trans('OptionTextOnly'), + 'native' => $langs->trans('OptionCloudFast') . ' - ' . $langs->trans('OptionCloudFasthelp'), + 'whisper' => $langs->trans('OptionWhisperLocal') . ' - ' . $langs->trans('OptionWhisperLocalhelp') + ]; + print $form->selectarray('AI_DEFAULT_INPUT_MODE', $input_modes, getDolGlobalString('AI_DEFAULT_INPUT_MODE'), 0, 0, 0); + print '
' . $langs->trans('ObfuscatePIIData') . ''; + print ajax_constantonoff('AI_PRIVACY_REDACTION'); + print '   ' . $langs->trans("RedactionHelp") . ''; + print '
' . $form->textwithpicto($langs->trans("AskConfirmation"), $langs->trans("AskConfirmationHelp")).''; + $confirmation_options = [ + '0' => $langs->trans("ConfirmNever"), + '1' => $langs->trans("ConfirmWriteOnly"), + '2' => $langs->trans("ConfirmAlways") + ]; + print $form->selectarray('AI_ASK_FOR_CONFIRMATION', $confirmation_options, getDolGlobalInt('AI_ASK_FOR_CONFIRMATION', 1), 0, 0, 0); + print '
' . $langs->trans('EnableLogging') . ''; + print ajax_constantonoff('AI_LOG_REQUESTS'); + print '   '.$langs->trans("ViewLogs").''; + print '
' . $langs->trans("LogRetention") . ' (0 = Forever)
'; + print $form->textwithpicto($langs->trans("SystemPrompt"), $langs->trans("SystemPromptHelp")) . '

'; + $doleditor = new DolEditor('AI_INTENT_PROMPT', $currentPrompt, '', 250, 'dolibarr_notes', 'In', false, false, true, ROWS_8, '90%'); + $doleditor->Create(); + print '
'; + print '
'; + + print '
'; + print '
'; + + print '
'; + print '
'; + + + // AI Provider Config and Connection testing + $services = getListOfAIServices(); + $currentService = getDolGlobalString('AI_API_SERVICE'); + + print load_fiche_titre($langs->trans("AIProviderConfigTitle"), '', 'fa fa-plug'); + + if ((string) $currentService == '-1') { + print '
'.$langs->trans("NoAIProviderSelected").' '.$langs->trans("ConfigureHere").'
'; + } else { + print '
'; + print ''; + + print ''; + + $prefix = 'AI_API_'.strtoupper($currentService); + $modelVal = getDolGlobalString($prefix.'_MODEL_TEXT', $services[$currentService]['textgeneration']['default']); + + print ''; + print '
'.$langs->trans("AIProvider").''.$services[$currentService]['label'].'
'.$langs->trans("AI_API_MODEL").''.$modelVal.'
'; + + print '
'; + + if ($currentService && $currentService !== '-1') { + print ' Test Connection'; + } + + print '
'; + } + + print '

'; + + // External Access Configuration + /* + print load_fiche_titre($langs->trans("AiMcpExternalAccess"), '', 'fas fa-lock-open'); + + print '
'; + print ''; + print ''; + + print '
'; + print ''; + + // Service User + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + + $endpoint = dol_buildpath('/ai/server/mcp_server.php', 3); + + print ''; + print ''; + print ''; + print ''; + + print '
Service User '; + print '
'; + print $form->select_dolusers(getDolGlobalInt('AI_MCP_USER_ID'), 'AI_MCP_USER_ID', 1); + print ' '; + print '
'; + print '' . $langs->trans("DedicatedUserRecommendation") . ''; + print '
API Key'; + if ($apiKey) { + print ''; + print ' Generate New Key'; + } else { + print '' . $langs->trans("NoKeyWarning") . ''; + print ' ' . $langs->trans("GenerateKey") . ''; + } + print '
Endpoint URL'; + print ''; + print '
'; + print '
'; + + print '
'; + + // Configuration Examples + print '
'; + print '
'; + print '' . $langs->trans("ClaudeDesktopConfig") . '
'; + print '
';
+	echo htmlspecialchars('
+	{
+	  "mcpServers": {
+		"dolibarr": {
+		  "command": "node",
+		  "args": ["/path/to/mcp-bridge.js"],
+		  "env": {
+			"DOLIBARR_URL": "'.$endpoint.'",
+			"DOLIBARR_API_KEY": "'.($apiKey ? $apiKey : "YOUR_KEY_HERE").'"
+		  }
+		}
+	  }
+	}');
+	print '
'; + print '
'; + */ +} + +print dol_get_fiche_end(); + +llxFooter(); +$db->close(); diff --git a/htdocs/ai/admin/server_mcp.php b/htdocs/ai/admin/server_mcp.php index fe74416ee2c..d41a6e37a6a 100644 --- a/htdocs/ai/admin/server_mcp.php +++ b/htdocs/ai/admin/server_mcp.php @@ -228,6 +228,7 @@ print '
'; print '
'; if (getDolGlobalString('AI_MCP_ENABLED')) { + /* print load_fiche_titre($langs->trans("PrivateModeTitle"), '', 'fas fa-lock'); print '
'; @@ -306,7 +307,7 @@ if (getDolGlobalString('AI_MCP_ENABLED')) { print '
'; print '
'; - + */ // AI Provider Config and Connection testing $services = getListOfAIServices(); @@ -323,7 +324,7 @@ if (getDolGlobalString('AI_MCP_ENABLED')) { print ''.$langs->trans("AIProvider").''.$services[$currentService]['label'].''; $prefix = 'AI_API_'.strtoupper($currentService); - $modelVal = getDolGlobalString($prefix.'_MODEL', $services[$currentService]['textgeneration']); + $modelVal = getDolGlobalString($prefix.'_MODEL_TEXT', $services[$currentService]['textgeneration']['default']); print ''.$langs->trans("AI_API_MODEL").''.$modelVal.''; print ''; @@ -331,7 +332,7 @@ if (getDolGlobalString('AI_MCP_ENABLED')) { print '
'; if ($currentService && $currentService !== '-1') { - print ' Test Connection'; + print ' Test Connection'; } print '
'; diff --git a/htdocs/ai/admin/setup.php b/htdocs/ai/admin/setup.php index 592180b24d9..4e3f52bec3c 100644 --- a/htdocs/ai/admin/setup.php +++ b/htdocs/ai/admin/setup.php @@ -106,16 +106,6 @@ foreach ($arrayofai as $ia => $iarecord) { if ($ia == 'custom') { $item->fieldAttr['placeholder'] = 'https://domainofapi.com/v1/'; } - - // Generic Model Field - /* - $item = $formSetup->newItem('AI_API_'.strtoupper($ia).'_MODEL'); - $item->nameText = $langs->trans("AI_API_MODEL").' ('.$ialabel.')'; - $item->defaultFieldValue = $iarecord['textgeneration']; - $item->fieldParams['trClass'] = 'iaservice '.$ia; - $item->cssClass = 'minwidth500 input'.$ia; - $item->helpText = $langs->trans("AI_API_MODEL_HELP"); - */ } $setupnotempty = + count($formSetup->items); diff --git a/htdocs/ai/assistant/parse_intent.php b/htdocs/ai/assistant/parse_intent.php index 07d9899de21..43d41506de4 100644 --- a/htdocs/ai/assistant/parse_intent.php +++ b/htdocs/ai/assistant/parse_intent.php @@ -48,7 +48,7 @@ require_once DOL_DOCUMENT_ROOT . '/ai/class/privacy_guard.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php'; // Security check -if (!isModEnabled('ai') || !getDolGlobalString('AI_MCP_ENABLED')) { +if (!isModEnabled('ai') || !getDolGlobalString('AI_ASSISTANT_ENABLED')) { http_response_code(403); accessforbidden('Module or feature not allowed'); } @@ -291,7 +291,7 @@ try { $systemRules .= "IMPORTANT: If the user asks for functionality that is NOT available in the list of Tools above, you MUST use the tool 'respond_to_user' to inform them that the specific feature is not available."; // If MCP is disabled, we disable all tools - if (!getDolGlobalString('AI_MCP_ENABLED')) { + if (getDolGlobalString('AI_ASSISTANT_DISABLE_TOOLS')) { $toolsForLLM = array(); } @@ -339,6 +339,7 @@ try { } $adapterType = $servicesList[$serviceKey]['adapter_type'] ?? 'openai'; + // The request. // var_dump($query); diff --git a/htdocs/ai/lib/ai.lib.php b/htdocs/ai/lib/ai.lib.php index 5c1bb457f7f..42a4c192640 100644 --- a/htdocs/ai/lib/ai.lib.php +++ b/htdocs/ai/lib/ai.lib.php @@ -422,6 +422,13 @@ function aiAdminPrepareHead() $head[$h][2] = 'custom'; $h++; + if (getDolGlobalString("MAIN_FEATURES_LEVEL") >= 2) { + $head[$h][0] = dol_buildpath("/ai/admin/assistant.php", 1); + $head[$h][1] = $langs->trans("Assistant"); + $head[$h][2] = 'assistant'; + $h++; + } + if (getDolGlobalString("MAIN_FEATURES_LEVEL") >= 2) { $head[$h][0] = dol_buildpath("/ai/admin/server_mcp.php", 1); $head[$h][1] = $langs->trans("MCPServer"); diff --git a/htdocs/ai/tools/crud_objects.class.php b/htdocs/ai/tools/crud_objects.class.php index 61933736148..37a9c9f20a7 100644 --- a/htdocs/ai/tools/crud_objects.class.php +++ b/htdocs/ai/tools/crud_objects.class.php @@ -141,10 +141,10 @@ class ToolCrudObjects extends McpTool // Order tool [ "name" => "create_sales_order", - "description" => "Create a CUSTOMER SALES ORDER. This is specifically for creating ORDERS that customers place with you. USE THIS TOOL whenever user mentions: 'order', 'sales order', 'customer order', 'new order'. This is NOT for invoices or supplier orders. Examples of when to use this tool: + "description" => "Create a CUSTOMER SALES ORDER. This is specifically for creating ORDERS that customers place with you. USE THIS TOOL whenever user mentions: 'create', 'new' or 'add' with 'order', 'customer order' or 'sales order'. This is NOT for invoices or supplier orders. Examples of when to use this tool: - 'create order for customer X' - 'new order for Y' -- 'order from customer Z' +- 'add order from customer Z' - 'add order for X with 5 items' If user says 'order' without any qualifier, they mean a SALES ORDER - use this tool.", "inputSchema" => [ @@ -184,7 +184,7 @@ If user says 'order' without any qualifier, they mean a SALES ORDER - use this t // Invoice tool [ "name" => "create_customer_invoice", - "description" => "Create a customer invoice (bill). Do NOT use this for orders - use create_sales_order instead. Do NOT use this for payments - use pay_invoice instead. Examples: 'create invoice for customer X', 'bill customer Y'", + "description" => "Create a customer invoice (bill). Do NOT use this for orders - use create_sales_order instead. Do NOT use this for payments - use pay_invoice instead. Examples: 'create invoice for customer X', 'new bill customer Y'", "inputSchema" => [ "type" => "object", "properties" => [ diff --git a/htdocs/ai/tools/thirdparty.class.php b/htdocs/ai/tools/thirdparty.class.php index 2fa9541c612..7ca43994d43 100644 --- a/htdocs/ai/tools/thirdparty.class.php +++ b/htdocs/ai/tools/thirdparty.class.php @@ -61,6 +61,7 @@ class ToolThirdParty extends McpTool "properties" => [ "query" => ["type" => ["string", "integer"], "description" => "The ID of the thirdparty, or a name/alias/code/email to search for."], "type" => ["type" => "string", "enum" => ["customer", "prospect", "supplier"], "description" => "Filter by type (optional)."], + "country_code" => ["type" => "string", "description" => "ISO 2-letter country code (e.g. US, FR, GR) (optional)."], "limit" => ["type" => "integer", "default" => 5] ], "required" => ["query"] @@ -192,10 +193,11 @@ class ToolThirdParty extends McpTool /** * Search for third parties based on provided criteria. * - * @param array{query:string|int, type?:string, limit?:int|string} $args Array of arguments: - * - query: Search string or ID - * - type: 'customer', 'prospect', 'supplier' - * - limit: Limit results (default 5) + * @param array{query:string|int, type?:string, country_code?:string, limit?:int|string} $args Array of arguments: + * - query: Search string or ID + * - country_code: ISO country code on 2 chars (FR, US, GR...) + * - type: 'customer', 'prospect', 'supplier' + * - limit: Limit results (default 5) * @return array{error:string}|list * */ @@ -207,6 +209,7 @@ class ToolThirdParty extends McpTool $query = $args['query']; $type = isset($args['type']) ? (string) $args['type'] : ''; + $country_code = isset($args['country_code']) ? (string) $args['country_code'] : ''; $limit = isset($args['limit']) ? (int) $args['limit'] : 5; // Safety fallback @@ -217,18 +220,20 @@ class ToolThirdParty extends McpTool // Dolibarr SQL construction $sql = "SELECT s.rowid, s.nom, s.name_alias, s.code_client, s.code_fournisseur, s.email, s.client, s.fournisseur"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; + if ($country_code) { + $sql.= " INNER JOIN ".MAIN_DB_PREFIX."c_country as c ON s.fk_pays = c.rowid AND c.code = '".$this->db->escape($country_code)."'"; + } $sql .= " WHERE s.entity IN (" . getEntity('societe') . ")"; if (is_numeric($query)) { $sql .= " AND s.rowid = " . (int) $query; $limit = 1; } else { - $q = $this->db->escape($query); - $sql .= " AND (s.nom LIKE '%" . $q . "%'"; - $sql .= " OR s.name_alias LIKE '%" . $q . "%'"; - $sql .= " OR s.code_client LIKE '%" . $q . "%'"; - $sql .= " OR s.code_fournisseur LIKE '%" . $q . "%'"; - $sql .= " OR s.email LIKE '%" . $q . "%')"; + $sql .= " AND (s.nom LIKE '%" . $this->db->escape($q) . "%'"; + $sql .= " OR s.name_alias LIKE '%" . $this->db->escape($q) . "%'"; + $sql .= " OR s.code_client LIKE '%" . $this->db->escape($q) . "%'"; + $sql .= " OR s.code_fournisseur LIKE '%" . $this->db->escape($q) . "%'"; + $sql .= " OR s.email LIKE '%" . $this->db->escape($q) . "%')"; } if ($type === 'customer') { diff --git a/htdocs/core/modules/modQuickMemo.class.php b/htdocs/core/modules/modQuickMemo.class.php index 54996a88b71..07e34bbc771 100644 --- a/htdocs/core/modules/modQuickMemo.class.php +++ b/htdocs/core/modules/modQuickMemo.class.php @@ -56,7 +56,7 @@ class modQuickMemo extends DolibarrModules // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' // It is used to group modules by family in module setup page - $this->family = "other"; + $this->family = "technic"; // Module position in the family on 2 digits ('01', '10', '20', ...) $this->module_position = '90'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5edb0131cbc..0aa5140a437 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2808,6 +2808,7 @@ MainErrorAddingSecurityPolicy=An error occurred when trying to add a Content Sec SecurityForConnection=Credentials for connection AddCredential=Add a credential API_ENABLE_COUNT_CALLS=Enable counting of API calls (slower). The value of API count is visible on the user page. +Assistant=Chat Assistant MCPServer=MCP Server AnalyzeUnalterableScopeOnly=Analyze only files and setup implicated into the feature of the module %s (otherwise all files are scanned) UnalterableFilesChecksum=Cheksum of unalterable files @@ -2827,6 +2828,8 @@ InitModuleIsSlow=Init of module is slow PreviousOptionGuaranteeThatDateIsAlwaysHigher=The previous option already guarantees that the date of invoice is always higher than the previous validated invoice ViewLogs=View Logs DisableMCPAI=Turn off to completely disable AI access to MCP server +EnableAssistant=Enable the chat AI assistant +DisableAssistant=Disable the chat AI assistant EnableMCPServer=Enable MCP Server EnableLogging=Enable Request Logging ObfuscatePIIData=Obfuscate Prompt Data @@ -2852,7 +2855,8 @@ NoLogsFound=No logs found MatchingSearchCriteria=matching your search criteria TryAskingAI=Try asking the AI ErrorSavingSettings=Error Saving Settings -ConfigHelp=Configure the Model Context Protocol (MCP) server. This controls how the AI interacts with your data and permissions. +ConfigAssistantHelp=Enable the private AI assistant. +ConfigHelp=Configure the Model Context Protocol (MCP) server. PrivateModeTitle=Private Mode (Recommended. AI LLM has no access to your database, it only sees information you allow) InputMethodHelp=Controls the default input method in the AI Assistant chat. AskConfirmation=Ask for Confirmation diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d058eb9b2d9..7097dfb30d7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2730,7 +2730,7 @@ function top_menu_ai() $html = ''; - if (isModEnabled('ai')) { + if (isModEnabled('ai') && getDolGlobalString('AI_ASSISTANT_ENABLED')) { // Open the AI Assistant in a popup overlay rather than navigating away, // so the user keeps their current page context while interacting with // the assistant. Uses the standard Dolibarr helper which builds an