### Install a Sanvex Driver Package Source: https://sanvex.narayan-dhakal.com.np/drivers After installing the core, add specific driver packages. Run the setup command to register the driver. ```bash php artisan sanvex:setup ``` -------------------------------- ### Install Specific Sanvex Drivers Source: https://sanvex.narayan-dhakal.com.np/concepts/packages Install only the Sanvex driver packages you intend to use. This example shows installing `sanvex/github` and `sanvex/slack`. ```bash composer require sanvex/github sanvex/slack ``` -------------------------------- ### Slack Driver Usage Example Source: https://sanvex.narayan-dhakal.com.np/drivers/slack Demonstrates basic usage of the Slack driver to list channels, post messages, and get user information. Requires the driver to be resolved from the manager. ```php $slack = $manager->resolveDriver('slack'); $slack->channels()->list(); $slack->messages()->post(['channel' => 'C123', 'text' => 'Hello']); $slack->users()->info(['user' => 'U123']); ``` -------------------------------- ### Gmail Driver Usage Examples Source: https://sanvex.narayan-dhakal.com.np/drivers/gmail Examples demonstrating how to resolve the Gmail driver and perform common actions like listing, getting, and sending messages, as well as listing threads. ```php $gmail = $manager->resolveDriver('gmail'); $gmail->messages()->list(['maxResults' => 10]); $gmail->messages()->get(['id' => 'message-id']); $gmail->messages()->send([...]); $gmail->threads()->list(); ``` -------------------------------- ### Install GitHub Driver Source: https://sanvex.narayan-dhakal.com.np/drivers/github Install the GitHub driver using Composer. Ensure sanvex/core and sanvex/cli are installed and migrations are run first. ```bash composer require sanvex/github ``` -------------------------------- ### Install Sanvex Packages and Migrate Source: https://sanvex.narayan-dhakal.com.np/getting-started/quickstart Install the necessary Sanvex packages using Composer, run database migrations, and list available commands. ```bash composer require sanvex/core sanvex/cli sanvex/github php artisan migrate php artisan sanvex:list ``` -------------------------------- ### API Key / Token Setup (CLI) Source: https://sanvex.narayan-dhakal.com.np/concepts/authentication Use the `sanvex:setup` command to store driver credentials. You can set them globally or for a specific tenant by providing owner type and ID. ```bash php artisan sanvex:setup github --api-key="ghp_..." ``` ```bash php artisan sanvex:setup slack --bot-token="xoxb-..." ``` ```bash php artisan sanvex:setup notion --api-key="secret_..." \ --owner-type=App\Models\Team --owner-id=1 ``` -------------------------------- ### Install Sanvex Core and CLI Source: https://sanvex.narayan-dhakal.com.np/getting-started/installation Install the core Sanvex package and the command-line interface using Composer. Run migrations to set up necessary database tables. ```bash composer require sanvex/core sanvex/cli php artisan migrate ``` -------------------------------- ### Install Notion Driver Source: https://sanvex.narayan-dhakal.com.np/drivers/notion Install the Notion driver using Composer. Ensure sanvex/core and sanvex/cli are installed and migrations are run first. ```bash composer require sanvex/notion ``` -------------------------------- ### Setup Linear Driver with API Key Source: https://sanvex.narayan-dhakal.com.np/drivers/linear Set up the Linear driver using an API key via the sanvex:setup artisan command. ```bash php artisan sanvex:setup linear --api-key="lin_api..." ``` -------------------------------- ### Typical Minimal Sanvex Install Source: https://sanvex.narayan-dhakal.com.np/concepts/packages Perform a minimal Sanvex installation including core, CLI, and a single driver. This also includes running database migrations and setting up the driver credentials. ```bash composer require sanvex/core sanvex/cli sanvex/github php artisan migrate php artisan sanvex:setup github --api-key="ghp_..." ``` -------------------------------- ### Install Slack Driver Source: https://sanvex.narayan-dhakal.com.np/drivers/slack Install the Slack driver package using Composer. Ensure sanvex/core and sanvex/cli are installed and migrations are run first. ```bash composer require sanvex/slack ``` -------------------------------- ### Install Linear Driver Source: https://sanvex.narayan-dhakal.com.np/drivers/linear Install the Linear driver using Composer. Ensure sanvex/core and sanvex/cli are installed and migrations are run first. ```bash composer require sanvex/linear ``` -------------------------------- ### Install Sanvex CLI Package Source: https://sanvex.narayan-dhakal.com.np/concepts/packages Install the `sanvex/cli` package to gain access to Artisan commands for Sanvex setup and scaffolding. This package is typically registered only in console environments. ```bash composer require sanvex/cli ``` -------------------------------- ### Global CLI Setup Source: https://sanvex.narayan-dhakal.com.np/concepts/tenancy Use this command to set up Sanvex credentials globally for the entire application. No owner-specific options are needed. ```bash php artisan sanvex:setup github --api-key="ghp_..." ``` -------------------------------- ### Install Gmail Driver Source: https://sanvex.narayan-dhakal.com.np/drivers/gmail Install the Gmail driver using Composer. Ensure sanvex/core and sanvex/cli are installed and migrations are run first. ```bash composer require sanvex/gmail ``` -------------------------------- ### General Sanvex Driver Setup Command Source: https://sanvex.narayan-dhakal.com.np/drivers The universal command for setting up any Sanvex driver. Specific parameters like API keys or tokens are driver-dependent. ```bash php artisan sanvex:setup {driver} [--api-key=] [--bot-token=] [--owner-type=] [--owner-id=] ``` -------------------------------- ### Install Sanvex Core Package Source: https://sanvex.narayan-dhakal.com.np/concepts/packages Install the foundational `sanvex/core` package using Composer. This package provides essential components for Sanvex functionality. ```bash composer require sanvex/core ``` -------------------------------- ### Start MCP Stdio Server Source: https://sanvex.narayan-dhakal.com.np/integrations/mcp Start the MCP server over stdin/stdout for clients like Claude Desktop or Cursor. ```bash php artisan sanvex:mcp-stdio ``` -------------------------------- ### Install Sanvex MCP Package Source: https://sanvex.narayan-dhakal.com.np/integrations/mcp Install the sanvex/mcp package using Composer. ```bash composer require sanvex/mcp ``` -------------------------------- ### Setup Notion Driver with API Key Source: https://sanvex.narayan-dhakal.com.np/drivers/notion Configure the Notion driver using an API key (integration token) via the Artisan command. ```bash php artisan sanvex:setup notion --api-key="secret_..." ``` -------------------------------- ### Install Agent Packages Source: https://sanvex.narayan-dhakal.com.np/getting-started/installation Install optional agent packages for Laravel AI and MCP using Composer. ```bash composer require sanvex/laravel-ai composer require sanvex/mcp ``` -------------------------------- ### Setup Slack Driver with Bot Token Source: https://sanvex.narayan-dhakal.com.np/drivers/slack Configure the Slack driver using a bot token. This is the recommended authentication method. ```bash php artisan sanvex:setup slack --bot-token="xoxb-..." ``` -------------------------------- ### List Installed Sanvex Drivers Source: https://sanvex.narayan-dhakal.com.np/drivers Verify that newly installed driver packages have been successfully registered with the Sanvex system. ```bash php artisan sanvex:list ``` -------------------------------- ### Setup GitHub Driver with Tenant-Scoped API Key Source: https://sanvex.narayan-dhakal.com.np/drivers/github Configure the GitHub driver with a personal access token for a specific tenant. This is useful for multi-tenant applications. ```bash php artisan sanvex:setup github --api-key="ghp_..." \ --owner-type=App\\Models\\User --owner-id=1 ``` -------------------------------- ### Run Database Migrations Source: https://sanvex.narayan-dhakal.com.np/concepts/database Execute the database migrations to create the necessary `sv_*` tables. This command is run after installing `sanvex/core`. ```bash php artisan migrate ``` -------------------------------- ### Sanvex Install with Agent Tooling Source: https://sanvex.narayan-dhakal.com.np/concepts/packages Install Sanvex core, CLI, a driver, and either the MCP or Laravel AI integration package for agent tooling. ```bash composer require sanvex/core sanvex/cli sanvex/github sanvex/mcp ``` ```bash composer require sanvex/core sanvex/cli sanvex/github sanvex/laravel-ai ``` -------------------------------- ### Setup Notion Driver with Owner Scope Source: https://sanvex.narayan-dhakal.com.np/getting-started/installation Configure the Notion driver with an API key, specifying the owner type and ID for per-team or per-user key management. ```bash php artisan sanvex:setup notion --api-key="secret_..." \ --owner-type=App\Models\Team --owner-id=1 ``` -------------------------------- ### Tenant-Scoped CLI Setup Source: https://sanvex.narayan-dhakal.com.np/concepts/tenancy Set up Sanvex credentials for a specific tenant (user or team) by providing owner type and ID. This ensures credentials are isolated per tenant. ```bash php artisan sanvex:setup slack --bot-token="xoxb-..." \ --owner-type=App\Models\Team --owner-id=42 ``` -------------------------------- ### Setup Slack Driver with User Token Source: https://sanvex.narayan-dhakal.com.np/drivers/slack Configure the Slack driver using a user token. The token resolution priority is bot_token → api_key → access_token. ```bash php artisan sanvex:setup slack --api-key="xoxp-..." ``` -------------------------------- ### Get Tools from a Single Sanvex Driver Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Retrieve all available tools for a specific Sanvex driver, such as 'github'. This is the default approach for most agents. ```php return app(SanvexAi::class)->driver('github')->tools(); ``` -------------------------------- ### Install Sanvex Laravel AI Package Source: https://sanvex.narayan-dhakal.com.np/concepts/packages Install the `sanvex/laravel-ai` package to integrate Sanvex with Laravel AI agents. This requires `laravel/ai` version ^0.6.0. ```bash composer require sanvex/laravel-ai ``` -------------------------------- ### GitHub Driver - Repositories Source: https://sanvex.narayan-dhakal.com.np/drivers/github Interact with GitHub repositories. This includes actions to get, list, create, and delete repositories. ```APIDOC ## GitHub Repositories API ### Description Provides methods to manage GitHub repositories. ### Resources - `repositories.get`: Get a repository - `repositories.list`: List repositories - `repositories.create`: Create a repository - `repositories.delete`: Delete a repository ### API Base `https://api.github.com` ### Usage Example ```php $github->repositories()->list(['per_page' => 10]); ``` ``` -------------------------------- ### Call an Operation via Generic Router Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Example of calling a specific operation (listing repositories) on a driver (github) using the generic router. ```json { "driver": "github", "resource": "repositories", "action": "list", "args": { "per_page": 10 } } ``` -------------------------------- ### Add Sanvex Drivers Source: https://sanvex.narayan-dhakal.com.np/getting-started/installation Install additional Sanvex drivers for various services like GitHub, Gmail, Linear, Notion, and Slack using Composer. ```bash composer require sanvex/github # composer require sanvex/gmail # composer require sanvex/linear # composer require sanvex/notion # composer require sanvex/slack ``` -------------------------------- ### Access Local DB for Email Messages Source: https://sanvex.narayan-dhakal.com.np/drivers/gmail Example of how to access and list email messages stored in the local database using the Gmail driver. ```php $gmail->db()->messages()->list(); ``` -------------------------------- ### Get Read-Only Tools from a Sanvex Driver Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Configure a driver to provide only read-only tools, which is a safe default for support or reporting bots. This prevents accidental modifications to data. ```php return app(SanvexAi::class)->driver('github')->readOnly()->tools(); ``` -------------------------------- ### Get Tools from Multiple Sanvex Drivers Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Combine tools from several Sanvex drivers by passing an array of driver names. This allows agents to access functionalities across different services. ```php return app(SanvexAi::class)->drivers(['github', 'slack', 'notion'])->tools(); ``` -------------------------------- ### Add Sanvex Tools to a Laravel AI Agent Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Implement the HasTools interface in your agent and return Sanvex tools from the tools() method. This example shows how to add GitHub repository tools to a custom agent. ```php use Laravel\Ai\Contracts\Agent; use Laravel\Ai\Contracts\HasTools; use Laravel\Ai\Promptable; use Sanvex\LaravelAi\Ai\SanvexAi; class MyAgent implements Agent, HasTools { use Promptable; public function instructions(): string { return 'You help the user with their GitHub repositories.'; } public function tools(): iterable { return app(SanvexAi::class)->driver('github')->tools(); } } ``` -------------------------------- ### Configure GitHub API Key Source: https://sanvex.narayan-dhakal.com.np/getting-started/quickstart Set up the GitHub integration by providing your personal access token via the Artisan command. ```bash php artisan sanvex:setup github --api-key="ghp_YOUR_TOKEN" ``` -------------------------------- ### Basic GitHub Driver Usage Source: https://sanvex.narayan-dhakal.com.np/drivers/github Instantiate the GitHub driver and perform common operations like listing repositories and creating issues. ```php $github = $manager->resolveDriver('github'); $github->repositories()->list(['per_page' => 10]); $github->issues()->create([ 'owner' => 'org', 'repo' => 'repo', 'title' => 'Bug report', ]); $github->pullRequests()->merge(['owner' => 'org', 'repo' => 'repo', 'pull_number' => 42]); ``` -------------------------------- ### Interact with GitHub Resources Source: https://sanvex.narayan-dhakal.com.np/getting-started/usage Demonstrates accessing different GitHub resources like repositories, issues, and pull requests after resolving the driver. ```php $github = $manager->resolveDriver('github'); $github->repositories()->get(['owner' => 'laravel', 'repo' => 'framework']); $github->issues()->list(['owner' => 'laravel', 'repo' => 'framework']); $github->pullRequests()->create([...]); ``` -------------------------------- ### List GitHub Repositories Source: https://sanvex.narayan-dhakal.com.np/getting-started/quickstart Call the GitHub API to list repositories using the SanvexManager. Ensure a valid token is used for successful API calls. ```php use Sanvex\Core\SanvexManager; public function repos(SanvexManager $manager) { return $manager->resolveDriver('github') ->repositories() ->list(['per_page' => 10]); } ``` -------------------------------- ### Configure Notion Driver with OAuth Source: https://sanvex.narayan-dhakal.com.np/drivers/notion Set up environment variables for Notion OAuth authentication, including client ID, secret, redirect URI, and auth type. ```env NOTION_CLIENT_ID=your-client-id NOTION_CLIENT_SECRET=your-client-secret NOTION_REDIRECT_URI=https://your-app.test/sanvex/notion/callback NOTION_AUTH_TYPE=oauth_2 NOTION_SUCCESS_REDIRECT=/ ``` -------------------------------- ### Mix Typed and Generic Tools Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Combine typed tools for specific drivers (like GitHub) with a generic router for other integrations. ```php return [ ...app(SanvexAi::class)->driver('github')->readOnly()->tools(), app(SanvexAi::class)->tool(['notion', 'linear']), ]; ``` -------------------------------- ### Verify GitHub Driver Configuration in PHP Source: https://sanvex.narayan-dhakal.com.np/getting-started/installation Check if the GitHub driver is configured by resolving it via SanvexManager and calling the isConfigured method. ```php use Sanvex\Core\SanvexManager; $driver = app(SanvexManager::class)->resolveDriver('github'); $driver->isConfigured(); // true after sanvex:setup ``` -------------------------------- ### Basic Notion Driver Usage Source: https://sanvex.narayan-dhakal.com.np/drivers/notion Resolve the Notion driver and perform common operations like listing pages, querying databases, and searching. ```php $notion = $manager->resolveDriver('notion'); $notion->pages()->list(['page_size' => 10]); $notion->databases()->query(['database_id' => '...']); $notion->search()->list(['query' => 'roadmap']); ``` -------------------------------- ### Check Driver Configuration Source: https://sanvex.narayan-dhakal.com.np/getting-started/usage Verifies if a driver is configured before attempting to use it. If not configured, it suggests the artisan command to set it up. ```php $driver = $manager->resolveDriver('github'); if (! $driver->isConfigured()) { // Run: php artisan sanvex:setup github --api-key=... } ``` -------------------------------- ### Discover Configured Drivers Only Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Use the system driver to discover only the drivers that are currently configured. ```json { "driver": "system", "resource": "drivers", "action": "list.configured", "args": {} } ``` -------------------------------- ### Slack Driver Usage Source: https://sanvex.narayan-dhakal.com.np/drivers/slack Demonstrates how to resolve the Slack driver and interact with its various methods for channels, messages, and users. ```APIDOC ## Slack Driver Usage ### Description This section shows how to instantiate the Slack driver and perform common operations like listing channels, posting messages, and retrieving user information. ### Method ```php $slack = $manager->resolveDriver('slack'); // Channels $slack->channels()->list(); $slack->channels()->info(parameters); $slack->channels()->join(parameters); // Messages $slack->messages()->post(['channel' => 'C123', 'text' => 'Hello']); $slack->messages()->list(parameters); $slack->messages()->delete(parameters); $slack->messages()->update(parameters); // Users $slack->users()->list(); $slack->users()->info(parameters); $slack->users()->lookupByEmail(parameters); ``` ### Resources #### `channels` | Action | Description | | ------ | ---------------- | | `list` | List channels | | `info` | Get channel info | | `join` | Join a channel | #### `messages` | Action | Description | | -------- | ------------------------------------ | | `post` | Post a message | | `list` | List messages (conversation history) | | `delete` | Delete a message | | `update` | Update a message | #### `users` | Action | Description | | --------------- | -------------------- | | `list` | List users | | `info` | Get user info | | `lookupByEmail` | Lookup user by email | ### API Base `https://slack.com/api` ``` -------------------------------- ### Filter Patterns for Multi-Driver Actions Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai When using multiple drivers, prefix resource names with the driver name (e.g., 'github.repositories.delete') to apply filters to specific drivers, especially when resource names overlap. ```php // Right: only Bitbucket ->except(['bitbucket.repositories.delete']) ``` -------------------------------- ### Local Database Interaction with Notion Driver Source: https://sanvex.narayan-dhakal.com.np/drivers/notion Interact with Notion pages through the local database abstraction provided by the driver. ```php $notion->db()->pages()->list(); ``` -------------------------------- ### Inspect Driver Metadata Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Retrieve metadata for all drivers to understand their capabilities, including configuration status and available resources/actions. ```php $meta = app(SanvexAi::class)->metadata(); ``` -------------------------------- ### Publish Sanvex Configuration Source: https://sanvex.narayan-dhakal.com.np/getting-started/installation Publish the Sanvex configuration files to customize drivers or encryption settings. ```bash php artisan vendor:publish --tag=sanvex-config ``` -------------------------------- ### Enable Run Script Tool Source: https://sanvex.narayan-dhakal.com.np/integrations/mcp Enable the RunScriptTool, which is disabled by default due to security risks, by setting SANVEX_MCP_ALLOW_RUN_SCRIPT to true. Only enable in trusted environments. ```env SANVEX_MCP_ALLOW_RUN_SCRIPT=true ``` -------------------------------- ### Combine Filters for Sanvex Tools Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Stack multiple filtering methods like 'readOnly()', 'except()', and 'only()' to create a precise set of tools for an agent. 'readOnly()' is applied last. ```php return app(SanvexAi::class) ->drivers(['github', 'gmail']) ->readOnly() ->except(['gmail.threads.list']) ->tools(); ``` -------------------------------- ### Discover All Registered Drivers Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Use the system driver to discover all registered drivers available in the application. ```json { "driver": "system", "resource": "drivers", "action": "list", "args": {} } ``` -------------------------------- ### Multi-tenancy with Sanvex Source: https://sanvex.narayan-dhakal.com.np/getting-started/usage Scopes driver instances and credentials to a specific authenticated user for multi-tenant applications. ```php $notion = $manager ->for(auth()->user()) ->resolveDriver('notion'); $pages = $notion->pages()->list(['page_size' => 10]); ``` -------------------------------- ### Local DB Usage Source: https://sanvex.narayan-dhakal.com.np/drivers/slack Illustrates how to access and list data from the local database for Slack messages and channels. ```APIDOC ## Local DB Usage ### Description This section demonstrates how to query local database tables for Slack messages and channels using the Slack driver. ### Method ```php // Access local DB for messages $slack->db()->messages()->list(); // Access local DB for channels $slack->db()->channels()->list(); ``` ``` -------------------------------- ### Register Custom Sanvex Drivers Source: https://sanvex.narayan-dhakal.com.np/concepts/packages Configure custom Sanvex drivers by listing their class names in the `drivers` array within `config/sanvex.php`. ```php 'drivers' => [ \App\Sanvex\AcmeDriver::class, ] ``` -------------------------------- ### Allow Only Specific Actions from Sanvex Drivers Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Use the 'only' method to specify a whitelist of allowed actions from multiple drivers. This provides granular control over agent capabilities. ```php return app(SanvexAi::class) ->drivers(['github', 'slack']) ->only([ 'github.repositories.list', 'github.issues.create', 'slack.messages.post', ]) ->tools(); ``` -------------------------------- ### Inspect Specific Driver Metadata Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Retrieve metadata for a subset of drivers by passing an array of driver names. ```php $meta = app(SanvexAi::class)->metadata(['github', 'slack']); ``` -------------------------------- ### Verify GitHub Driver Configuration in Tinker Source: https://sanvex.narayan-dhakal.com.np/getting-started/installation Use Artisan Tinker to programmatically check if the GitHub driver is configured. ```bash php artisan tinker --execute="dump(app(\\ ``` -------------------------------- ### Local DB Operations with Slack Driver Source: https://sanvex.narayan-dhakal.com.np/drivers/slack Interact with local database operations for messages and channels using the Slack driver. This allows for local data management. ```php $slack->db()->messages()->list(); $slack->db()->channels()->list(); ``` -------------------------------- ### Access Local GitHub Database Source: https://sanvex.narayan-dhakal.com.np/drivers/github Interact with the locally synced GitHub data using the driver's database access methods. This allows querying local data without hitting the GitHub API. ```php $github->db()->repositories()->list(); $github->db()->issues()->list(); ``` -------------------------------- ### Basic Linear Driver Usage Source: https://sanvex.narayan-dhakal.com.np/drivers/linear Resolve the Linear driver from the manager and perform common operations on issues and projects. ```php $linear = $manager->resolveDriver('linear'); $linear->issues()->list(); $linear->issues()->create([...]); $linear->projects()->get(['id' => 'project-id']); ``` -------------------------------- ### Generate Encryption Key Source: https://sanvex.narayan-dhakal.com.np/concepts/database Generate a dedicated Key Encryption Key (KEK) for encrypting Data Encryption Keys (DEKs) in the `sv_accounts` table. Add the output to your `.env` file. ```bash php artisan sanvex:keygen ``` -------------------------------- ### Enable HTTP Transport Source: https://sanvex.narayan-dhakal.com.np/integrations/mcp Enable HTTP transport for the MCP server by setting the SANVEX_MCP_ENABLE_SERVER environment variable to true. ```env SANVEX_MCP_ENABLE_SERVER=true ``` -------------------------------- ### Register Generic Router Tool Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Register the generic router tool to accept JSON payloads for driver, resource, action, and arguments. ```php return [ app(SanvexAi::class)->tool() ]; ``` -------------------------------- ### Access Local DB for Linear Issues Source: https://sanvex.narayan-dhakal.com.np/drivers/linear Access the local database to list issues managed by the Linear driver. ```php $linear->db()->issues()->list(); ``` -------------------------------- ### GitHub Driver - Local DB Access Source: https://sanvex.narayan-dhakal.com.np/drivers/github Access synced GitHub data stored in the local database. ```APIDOC ## GitHub Local DB Access ### Description Allows querying GitHub data that has been synced to the local database. ### Usage Example ```php $github->db()->repositories()->list(); $github->db()->issues()->list(); ``` ``` -------------------------------- ### Inject SanvexAi in Controller for Agent Tools Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Inject the SanvexAi service into a controller or action to provide tools to an agent. This allows for direct access to Sanvex drivers and their functionalities. ```php public function agent(SanvexAi $sanvex) { return MyAgent::make() ->tools($sanvex->driver('github')->tools()) ->prompt('List my open pull requests'); } ``` -------------------------------- ### Block Dangerous Actions from Sanvex Drivers Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Use the 'except' method to specify a blacklist of dangerous actions to be excluded from the available tools. This enhances security by preventing potentially harmful operations. ```php return app(SanvexAi::class) ->drivers(['github', 'gmail']) ->except(['github.repositories.delete', 'gmail.messages.delete']) ->tools(); ``` -------------------------------- ### Runtime Driver Resolution with Tenant Scope Source: https://sanvex.narayan-dhakal.com.np/concepts/tenancy Resolve a Sanvex driver within a specific owner's context using the `for($owner)` method before calling `resolveDriver`. This is essential for multi-tenant applications to use tenant-specific credentials. ```php use Sanvex\Core\SanvexManager; public function pages(SanvexManager $manager) { return $manager ->for(auth()->user()) ->resolveDriver('notion') ->pages() ->list(['page_size' => 10]); } ``` -------------------------------- ### Notion OAuth Environment Variables Source: https://sanvex.narayan-dhakal.com.np/concepts/authentication Configure Notion OAuth by setting client ID, secret, redirect URI, and auth type in your environment variables. ```env NOTION_CLIENT_ID=... NOTION_CLIENT_SECRET=... NOTION_REDIRECT_URI=https://your-app.test/sanvex/notion/callback NOTION_AUTH_TYPE=oauth_2 ``` -------------------------------- ### GitHub Driver - Issues Source: https://sanvex.narayan-dhakal.com.np/drivers/github Manage GitHub issues. Supports listing, retrieving, creating, and updating issues. ```APIDOC ## GitHub Issues API ### Description Provides methods to manage GitHub issues. ### Resources - `issues.list`: List issues - `issues.get`: Get an issue - `issues.create`: Create an issue - `issues.update`: Update an issue ### Usage Example ```php $github->issues()->create([ 'owner' => 'org', 'repo' => 'repo', 'title' => 'Bug report', ]); ``` ``` -------------------------------- ### Limit Drivers for Generic Router Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Restrict the drivers that the model can use with the generic router by passing an array of driver names. ```php return [ app(SanvexAi::class)->tool(['github', 'slack']) ]; ``` -------------------------------- ### GitHub Driver - Pull Requests Source: https://sanvex.narayan-dhakal.com.np/drivers/github Handle GitHub pull requests. Allows listing, retrieving, creating, and merging pull requests. ```APIDOC ## GitHub Pull Requests API ### Description Provides methods to manage GitHub pull requests. ### Resources - `pullRequests.list`: List pull requests - `pullRequests.get`: Get a pull request - `pullRequests.create`: Create a pull request - `pullRequests.merge`: Merge a pull request ### Usage Example ```php $github->pullRequests()->merge([ 'owner' => 'org', 'repo' => 'repo', 'pull_number' => 42 ]); ``` ``` -------------------------------- ### Access Local Database Cache Source: https://sanvex.narayan-dhakal.com.np/getting-started/usage Retrieves cached entities from the local database (`sv_entities`) for a specific driver and entity type. ```php $github = $manager->resolveDriver('github'); $repos = $github->db()->repositories()->list(); ``` -------------------------------- ### Exclude a Whole Resource from a Sanvex Driver Source: https://sanvex.narayan-dhakal.com.np/integrations/laravel-ai Exclude an entire resource type, such as 'repositories', from a specific driver. This simplifies the toolset by removing all operations related to that resource. ```php return app(SanvexAi::class)->driver('github')->except(['repositories'])->tools(); ``` -------------------------------- ### Default Global Scope Runtime Usage Source: https://sanvex.narayan-dhakal.com.np/concepts/tenancy When no owner is specified using `for($owner)`, Sanvex defaults to the global scope for driver resolution. This is equivalent to calling `for(null)`. ```php // Same as for(null)->resolveDriver('github') $manager->resolveDriver('github'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.