Add Prodigy event and export documentation views, enhance tests
- Created new Blade views for displaying Prodigy events and exports, including detailed references. - Implemented tests for Prodigy client and server event/export reference tools to ensure correct functionality. - Updated Pest test configuration for improved test case handling.
This commit is contained in:
78 files changed
+4223
-809
No files matched your search
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Tools\Prodigy\Client;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Tool;
|
||||
|
||||
#[Description('prp-bridge event reference for client-side events fired by the Prodigy Studios bridge resource. Includes notifications, sound, callbacks, allowlist, and medical events.')]
|
||||
class GetProdigyClientEventReference extends Tool
|
||||
{
|
||||
/**
|
||||
* Handle the tool request.
|
||||
*/
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$eventName = $request->get('event_name', '');
|
||||
|
||||
$events = $this->getClientEvents();
|
||||
|
||||
if ($eventName) {
|
||||
$event = collect($events)->firstWhere('name', $eventName);
|
||||
if ($event) {
|
||||
return Response::text($this->formatEvent($event));
|
||||
}
|
||||
|
||||
return Response::text("prp-bridge client-side event '$eventName' not found. See https://docs.prodigyrp.net/prp-bridge/events.html for the full reference.");
|
||||
}
|
||||
|
||||
return Response::text($this->formatEventList($events));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all prp-bridge client-side events.
|
||||
*/
|
||||
protected function getClientEvents(): array
|
||||
{
|
||||
return [
|
||||
// Core — Notifications & Sound
|
||||
[
|
||||
'name' => 'prp-bridge:notify',
|
||||
'side' => 'client',
|
||||
'category' => 'Core — Notifications & Sound',
|
||||
'description' => 'Sends a notification to the player. Trigger from server via bridge.fw.notify. Type: success, error, inform.',
|
||||
'parameters' => [
|
||||
'type' => 'Notification type: "success", "error", or "inform"',
|
||||
'message' => 'The notification body text',
|
||||
'title' => 'Optional title text',
|
||||
'duration' => 'Duration in milliseconds (optional)',
|
||||
],
|
||||
'lua_example' => "-- Trigger from client\nTriggerEvent('prp-bridge:notify', 'success', 'You sold the item!', 'Shop', 5000)\n\n-- Trigger from server\nTriggerClientEvent('prp-bridge:notify', source, 'success', 'You sold the item!', 'Shop', 5000)",
|
||||
'js_example' => "// Trigger from client\nemit('prp-bridge:notify', 'success', 'You sold the item!', 'Shop', 5000);\n\n// Trigger from server\nemitNet('prp-bridge:notify', source, 'success', 'You sold the item!', 'Shop', 5000);",
|
||||
],
|
||||
[
|
||||
'name' => 'prp-bridge:sound:play',
|
||||
'side' => 'client',
|
||||
'category' => 'Core — Notifications & Sound',
|
||||
'description' => 'Plays a sound on the client.',
|
||||
'parameters' => [
|
||||
'fileName' => 'Sound file name',
|
||||
'volume' => 'Volume level (0.0 – 1.0)',
|
||||
'noAutoPath' => 'Set true to use a fully qualified path instead of the automatic one',
|
||||
'resourceName' => 'Resource that owns the sound file',
|
||||
],
|
||||
'lua_example' => "TriggerEvent('prp-bridge:sound:play', 'cash_register', 0.5, false, 'my-resource')",
|
||||
'js_example' => "emit('prp-bridge:sound:play', 'cash_register', 0.5, false, 'my-resource');",
|
||||
],
|
||||
[
|
||||
'name' => 'prp-bridge:sound:playSpatial',
|
||||
'side' => 'client',
|
||||
'category' => 'Core — Notifications & Sound',
|
||||
'description' => 'Plays a 3D spatial sound at world coordinates.',
|
||||
'parameters' => [
|
||||
'fileName' => 'Sound file name',
|
||||
'volume' => 'Volume level (0.0 – 1.0)',
|
||||
'coords' => 'vector3 world position',
|
||||
'distance' => 'Max audible distance',
|
||||
'shouldMuffle' => 'Whether to apply interior muffling',
|
||||
'noAutoPath' => 'Set true to use a fully qualified path',
|
||||
'resourceName' => 'Resource that owns the sound file',
|
||||
],
|
||||
'lua_example' => "TriggerEvent('prp-bridge:sound:playSpatial', 'explosion', 1.0, vector3(100.0, 200.0, 30.0), 50.0, false, false, 'my-resource')",
|
||||
'js_example' => "emit('prp-bridge:sound:playSpatial', 'explosion', 1.0, [100.0, 200.0, 30.0], 50.0, false, false, 'my-resource');",
|
||||
],
|
||||
|
||||
// Core — Callbacks
|
||||
[
|
||||
'name' => 'prp-bridge:progress',
|
||||
'side' => 'client',
|
||||
'category' => 'Core — Callbacks',
|
||||
'description' => 'Progress bar callback. Invoked via lib.callback from the server.',
|
||||
'parameters' => [],
|
||||
'lua_example' => "-- Invoked internally via lib.callback from the server\n-- Use lib.callback.await on the server to trigger it\nlib.callback('prp-bridge:progress', source, function(result)\n print('Progress result:', result)\nend, { duration = 5000, label = 'Processing...' })",
|
||||
'js_example' => '// Invoked internally via lib.callback from the server',
|
||||
],
|
||||
[
|
||||
'name' => 'prp-bridge:minigame',
|
||||
'side' => 'client',
|
||||
'category' => 'Core — Callbacks',
|
||||
'description' => 'Minigame callback. Invoked via lib.callback from the server.',
|
||||
'parameters' => [],
|
||||
'lua_example' => "-- Invoked internally via lib.callback from the server\nlib.callback('prp-bridge:minigame', source, function(success)\n if success then\n print('Minigame passed!')\n end\nend, { type = 'circle', difficulty = 'easy' })",
|
||||
'js_example' => '// Invoked internally via lib.callback from the server',
|
||||
],
|
||||
[
|
||||
'name' => 'prp-bridge:confirmDialog',
|
||||
'side' => 'client',
|
||||
'category' => 'Core — Callbacks',
|
||||
'description' => 'Confirm dialog callback. Invoked via lib.callback from the server.',
|
||||
'parameters' => [],
|
||||
'lua_example' => "-- Invoked internally via lib.callback from the server\nlib.callback('prp-bridge:confirmDialog', source, function(confirmed)\n if confirmed then\n print('Player confirmed!')\n end\nend, { title = 'Are you sure?', content = 'This cannot be undone.' })",
|
||||
'js_example' => '// Invoked internally via lib.callback from the server',
|
||||
],
|
||||
[
|
||||
'name' => 'prp-bridge:inputDialog',
|
||||
'side' => 'client',
|
||||
'category' => 'Core — Callbacks',
|
||||
'description' => 'Input dialog callback. Invoked via lib.callback from the server.',
|
||||
'parameters' => [],
|
||||
'lua_example' => "-- Invoked internally via lib.callback from the server\nlib.callback('prp-bridge:inputDialog', source, function(input)\n print('Player entered:', input)\nend, { title = 'Enter value', inputs = { { type = 'input', label = 'Name' } } })",
|
||||
'js_example' => '// Invoked internally via lib.callback from the server',
|
||||
],
|
||||
[
|
||||
'name' => 'prp-bridge:placeProp',
|
||||
'side' => 'client',
|
||||
'category' => 'Core — Callbacks',
|
||||
'description' => 'Prop placer callback. Opens the prop placement UI. Invoked via lib.callback from the server.',
|
||||
'parameters' => [],
|
||||
'lua_example' => "-- Invoked internally via lib.callback from the server\nlib.callback('prp-bridge:placeProp', source, function(coords)\n if coords then\n print('Prop placed at:', coords)\n end\nend, { model = 'prop_barrier_work05a' })",
|
||||
'js_example' => '// Invoked internally via lib.callback from the server',
|
||||
],
|
||||
|
||||
// Allowlist
|
||||
[
|
||||
'name' => 'prp-bridge:client:updateAllowlist',
|
||||
'side' => 'client',
|
||||
'category' => 'Allowlist',
|
||||
'description' => 'Fired when the player\'s allowlists are updated or loaded.',
|
||||
'parameters' => [
|
||||
'allowlists' => 'table<string, boolean> — map of allowlist name to whether the player has it',
|
||||
],
|
||||
'lua_example' => "AddEventHandler('prp-bridge:client:updateAllowlist', function(allowlists)\n if allowlists['my_allowlist'] then\n print('Player has my_allowlist!')\n end\nend)",
|
||||
'js_example' => "on('prp-bridge:client:updateAllowlist', (allowlists) => {\n if (allowlists['my_allowlist']) {\n console.log('Player has my_allowlist!');\n }\n});",
|
||||
],
|
||||
|
||||
// Medical
|
||||
[
|
||||
'name' => 'prp-bridge:client:revived',
|
||||
'side' => 'client',
|
||||
'category' => 'Medical',
|
||||
'description' => 'Fired when the local player is revived.',
|
||||
'parameters' => [],
|
||||
'lua_example' => "AddEventHandler('prp-bridge:client:revived', function()\n print('Player was revived!')\nend)",
|
||||
'js_example' => "on('prp-bridge:client:revived', () => {\n console.log('Player was revived!');\n});",
|
||||
],
|
||||
[
|
||||
'name' => 'prp-bridge:client:died',
|
||||
'side' => 'client',
|
||||
'category' => 'Medical',
|
||||
'description' => 'Fired when the local player dies.',
|
||||
'parameters' => [],
|
||||
'lua_example' => "AddEventHandler('prp-bridge:client:died', function()\n print('Player died!')\nend)",
|
||||
'js_example' => "on('prp-bridge:client:died', () => {\n console.log('Player died!');\n});",
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a single event for output.
|
||||
*/
|
||||
protected function formatEvent(array $event): string
|
||||
{
|
||||
return view('mcp.prodigy.prodigy-event-reference', [
|
||||
'event' => $event,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format full event listing grouped by category.
|
||||
*/
|
||||
protected function formatEventList(array $events): string
|
||||
{
|
||||
$byCategory = collect($events)->groupBy('category')->toArray();
|
||||
|
||||
return view('mcp.prodigy.prodigy-event-list', [
|
||||
'eventsByCategory' => $byCategory,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tool's input schema.
|
||||
*
|
||||
* @return array<string, JsonSchema>
|
||||
*/
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'event_name' => $schema
|
||||
->string()
|
||||
->description('The prp-bridge client event name to look up (e.g. "prp-bridge:notify"). Omit to list all client events.')
|
||||
->default(''),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mcp\Tools\Prodigy\Client;
|
||||
|
||||
use Illuminate\Contracts\JsonSchema\JsonSchema;
|
||||
use Laravel\Mcp\Request;
|
||||
use Laravel\Mcp\Response;
|
||||
use Laravel\Mcp\Server\Attributes\Description;
|
||||
use Laravel\Mcp\Server\Tool;
|
||||
|
||||
#[Description('prp-bridge client-side exports reference. Covers the IsAllowlisted allowlist check, the PropPlacer UI, and the Ped Interactions system (AddPedInteraction, RemovePedInteraction).')]
|
||||
class GetProdigyClientExport extends Tool
|
||||
{
|
||||
/**
|
||||
* Handle the tool request.
|
||||
*/
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
$exportName = $request->get('export_name', '');
|
||||
|
||||
$exports = $this->getClientExports();
|
||||
|
||||
if ($exportName) {
|
||||
$export = collect($exports)->firstWhere('name', $exportName);
|
||||
if ($export) {
|
||||
return Response::text($this->formatExport($export));
|
||||
}
|
||||
|
||||
return Response::text("prp-bridge client export '$exportName' not found. See https://docs.prodigyrp.net/prp-bridge/exports.html for the full reference.");
|
||||
}
|
||||
|
||||
return Response::text($this->formatExportList($exports));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all prp-bridge client-side exports.
|
||||
*/
|
||||
protected function getClientExports(): array
|
||||
{
|
||||
return [
|
||||
// Allowlist
|
||||
[
|
||||
'name' => 'IsAllowlisted',
|
||||
'category' => 'Allowlist',
|
||||
'side' => 'client',
|
||||
'description' => 'Returns whether the current player character has a specific allowlist.',
|
||||
'parameters' => [
|
||||
['name' => 'allowlist', 'type' => 'string', 'description' => 'The allowlist key to check (e.g. "police_allowlist")'],
|
||||
],
|
||||
'returns' => ['type' => 'boolean', 'description' => 'true if the character has the allowlist, false otherwise'],
|
||||
'lua_example' => "local isAllowed = exports['prp-bridge']:IsAllowlisted('police_allowlist')\nif isAllowed then\n print('Player has police_allowlist')\nend",
|
||||
],
|
||||
|
||||
// Prop Placer
|
||||
[
|
||||
'name' => 'PropPlacer',
|
||||
'category' => 'Prop Placer',
|
||||
'side' => 'client',
|
||||
'description' => 'Opens the interactive prop placement UI. Returns the final position and heading, or nil if the player cancelled.',
|
||||
'parameters' => [
|
||||
['name' => 'model', 'type' => 'number', 'description' => 'Model hash of the prop to place'],
|
||||
['name' => 'forceGround', 'type' => 'boolean?', 'description' => 'Force the prop to snap to the ground (optional)'],
|
||||
['name' => 'allowedMaterials', 'type' => 'table?', 'description' => 'Table of allowed surface material types (optional)'],
|
||||
['name' => 'maxDistance', 'type' => 'number?', 'description' => 'Maximum placement distance from the player (optional)'],
|
||||
],
|
||||
'returns' => ['type' => 'vector4 | nil', 'description' => 'vector4(x, y, z, heading) of the placed prop, or nil if cancelled'],
|
||||
'lua_example' => "local result = exports['prp-bridge']:PropPlacer(\n GetHashKey('prop_barrier_work05a'),\n true,\n nil,\n 10.0\n)\nif result then\n print('Placed at:', result.x, result.y, result.z, 'heading:', result.w)\nelse\n print('Placement cancelled')\nend",
|
||||
],
|
||||
|
||||
// Ped Interactions
|
||||
[
|
||||
'name' => 'AddPedInteraction',
|
||||
'category' => 'Ped Interactions',
|
||||
'side' => 'client',
|
||||
'description' => 'Registers a ped interaction. The ped spawns when a player enters the radius and is removed when they leave. Returns true on success, or false with an error string.',
|
||||
'parameters' => [
|
||||
['name' => 'id', 'type' => 'string', 'description' => 'Unique identifier for this ped interaction'],
|
||||
['name' => 'payload', 'type' => 'table', 'description' => 'Configuration table (model, coords, heading, radius, options, scenario/anim, component, weapon)'],
|
||||
],
|
||||
'returns' => ['type' => 'boolean, string?', 'description' => 'true on success; false, "missing" if id/payload is nil; false, "exists" if id is already registered'],
|
||||
'lua_example' => "exports['prp-bridge']:AddPedInteraction('my_dealer', {\n model = 's_m_y_dealer_01',\n coords = vector3(100.0, 200.0, 30.0),\n heading = 180.0,\n radius = 50.0,\n scenario = 'WORLD_HUMAN_STAND_IMPATIENT',\n options = {\n {\n icon = 'fas fa-comments',\n label = 'Talk to Dealer',\n distance = 2.0,\n onSelect = function()\n openDealerMenu()\n end\n }\n }\n})",
|
||||
],
|
||||
[
|
||||
'name' => 'RemovePedInteraction',
|
||||
'category' => 'Ped Interactions',
|
||||
'side' => 'client',
|
||||
'description' => 'Removes a registered ped interaction and deletes the ped entity if it currently exists.',
|
||||
'parameters' => [
|
||||
['name' => 'id', 'type' => 'string', 'description' => 'The ID used when the ped was registered with AddPedInteraction'],
|
||||
],
|
||||
'returns' => ['type' => 'boolean', 'description' => 'true if the ped was removed; false if the ID was not found'],
|
||||
'lua_example' => "local removed = exports['prp-bridge']:RemovePedInteraction('my_dealer')\nif not removed then\n print('Ped not found')\nend\n\n-- Auto-cleanup on resource stop is handled automatically.\n-- Use manual removal only when you need to remove the ped while the resource is still running.",
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a single export for output.
|
||||
*/
|
||||
protected function formatExport(array $export): string
|
||||
{
|
||||
return view('mcp.prodigy.prodigy-export-reference', [
|
||||
'export' => $export,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format full export listing grouped by category.
|
||||
*/
|
||||
protected function formatExportList(array $exports): string
|
||||
{
|
||||
$byCategory = collect($exports)->groupBy('category')->toArray();
|
||||
|
||||
return view('mcp.prodigy.prodigy-export-list', [
|
||||
'exportsByCategory' => $byCategory,
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tool's input schema.
|
||||
*
|
||||
* @return array<string, JsonSchema>
|
||||
*/
|
||||
public function schema(JsonSchema $schema): array
|
||||
{
|
||||
return [
|
||||
'export_name' => $schema
|
||||
->string()
|
||||
->description('The prp-bridge client export name to look up (e.g. "IsAllowlisted", "AddPedInteraction"). Omit to list all client exports.')
|
||||
->default(''),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user