monarc / copilot
MONARC Copilot module for FrontOffice
Requires
- php: ^8.1
- ext-curl: *
- ext-json: *
- ext-pdo: *
- laminas/laminas-mvc: ^3.6
- laminas/laminas-mvc-middleware: ^2.2
- laminas/laminas-permissions-rbac: ^3.0
- monarc/frontoffice: ^2.13
Requires (Dev)
- laminas/laminas-test: ^4.11
- phpunit/phpunit: ^10.5
README
MONARC Copilot is a FrontOffice module that adds a copilot endpoint and supporting services for contextual guidance inside MONARC ANR workflows.
Features
- Provides a copilot API route under the FrontOffice ANR API.
- Builds contextual answers from ANR workflow state and selected objects or risks.
- Supports optional response refinement through an Ollama-compatible or OpenAI-style chat endpoint.
Requirements
- PHP 8.1+
- Composer
- MONARC FrontOffice 2.13+
Installation
composer require monarc/copilot
Enable the module in your MONARC FrontOffice application:
- Add the module name in
config/application.config.phpif it is not already present:'Monarc\Copilot', - Ensure the Laminas module symlink exists:
mkdir -p module/Monarc ln -sfn ./../../vendor/monarc/copilot module/Monarc/Copilot
- Add the FrontOffice feature flag in
config/autoload/local.php:'isCopilotEnabled' => true, - Create
config/autoload/copilot.local.phpfromconfig/autoload/copilot.local.php.distand configure the LLM connection. - Refresh linked assets:
./scripts/link_modules_resources.sh
For Docker-based FrontOffice deployments, the entrypoint can generate copilot.local.php and recreate the Copilot symlinks from environment variables on container startup.
Configuration
The module exposes a copilot config section in config/module.config.php.
Example options:
copilot.maxRecommendationscopilot.maxSourcescopilot.ollama.enabledcopilot.ollama.transportcopilot.ollama.baseUrlcopilot.ollama.endpointPathcopilot.ollama.modelcopilot.ollama.apiKeycopilot.ollama.jsonModecopilot.ollama.timeout
Example:
<?php return [ 'copilot' => [ 'ollama' => [ 'enabled' => true, 'transport' => 'openai-chat', 'baseUrl' => 'http://127.0.0.1:11434', 'endpointPath' => '/chat/completions', 'model' => 'llama-70b', 'apiKey' => '', 'jsonMode' => false, 'timeout' => 20, ], ], ];
Usage
When FrontOffice returns "isCopilotEnabled": true from api/config, the ANR layout shows a Show copilot button.
- The panel is hidden by default.
- The Copilot is read-only and does not modify ANR data.
- It can explain the current step, suggest next actions, provide context text, and suggest recommendations.
- It uses the current ANR page context such as selected object, selected instance, selected risk, and selected operational risk.
The API route is exposed under:
GET /api/client-anr/:anrId/copilot
POST /api/client-anr/:anrId/copilot
Common request parameters:
questionrouteNametabIndextabLabelselectedObjectUuidselectedInstanceIdselectedRiskIdselectedOpRiskId
Common troubleshooting checks:
Monarc\Copilotis present inconfig/application.config.phpmodule/Monarc/Copilotpoints tovendor/monarc/copilotconfig/autoload/copilot.local.phpexistsconfig/autoload/local.phpsets'isCopilotEnabled' => true- the configured
baseUrlis reachable from the PHP runtime
Development
Install dependencies:
composer install
Run tests:
vendor/bin/phpunit
License
This project is licensed under AGPL-3.0-or-later. See LICENSE.