# Anvil Documentation > Documentation for Anvil, the observability platform for Control4 drivers by Driverforge This file contains all documentation content in a single document following the llmstxt.org standard. ## Error Grouping When the same error occurs multiple times, Anvil groups them together so you can focus on fixing unique issues rather than drowning in duplicates. ### Occurrences Each time an error with the same fingerprint is thrown, Anvil records it as a new **occurrence** within the existing error group. When you open an error from the [Errors](/platform/errors) page, you see the most recent occurrence by default. To see all occurrences of a given error, click the **View More Occurrences** button on the error detail page. This shows a list of every time this error was thrown, with timestamps, driver versions, and error messages for each. Selecting a specific occurrence takes you to the detail page for that individual occurrence, useful for comparing context, arguments, or driver versions across different instances of the same error. You can also navigate between occurrences using the **Previous** / **Next** buttons on the detail page without returning to the list. ### How Grouping Works Anvil creates a **fingerprint** for each error based on its characteristics. Errors with the same fingerprint are grouped together into a single entry on the [Errors](/platform/errors) page, with a count of how many times it occurred. #### Fingerprinting Strategy Anvil uses **exception stacktrace grouping** which considers all frames in the call stack: | Component | Description | |-----------|-------------| | **Error type** | The category of error (e.g. `LuaError`, `RuntimeError`) | | **Error message** | The error text, normalised to remove variable data | | **Stack frames** | All frames in the call stack, including file names and line numbers | Two errors are grouped together when they have the same error type, originate from the same location in your code, and have the same call path leading to the error. #### Example These two errors would be grouped together (same type, same location, same call path): ``` ERROR: attempt to index nil value (local 'device') driver.lua:142: in function 'handleInput' driver.lua:89: in function ``` But this error would create a **separate group** because it originates from a different line: ``` ERROR: attempt to index nil value (local 'device') driver.lua:156: in function 'handleOutput' driver.lua:92: in function ``` ### Viewing Grouping Data On any error detail page, expand the **Grouping Info** section to see: - **Grouped by**: the strategy used (currently "exception stacktrace - all frames") - **Hash**: the unique SHA-256 fingerprint for this error group - **Raw grouping data**: toggle to see the exact data used to generate the fingerprint ### The Fingerprint Hash Each error group has a unique hash. This is useful for: - **Referencing specific issues** in bug reports or tickets - **Tracking recurrence**: if a previously fixed bug returns, it'll have the same fingerprint - **API integrations** that need to identify specific error types --- ## Captured Handlers The Driverforge SDK automatically captures handler calls from your driver: there's nothing to wire up per handler. Every captured call appears on the [Events](/platform/events) page in real time. ### What's Captured The SDK automatically captures 100+ handlers, including: - Lifecycle events (`OnDriverInit`, `OnDriverLateInit`, `OnDriverDestroyed`, etc.) - Property and binding events (`OnPropertyChanged`, `OnBindingChanged`, etc.) - Commands (`ExecuteCommand`, `ReceivedFromProxy`, etc.) - System events (`OnSystemEvent`, `OnTimerExpired`, etc.) See [Automatic Capture](/sdk/automatic-capture) for the full list. ### Implementation Coverage Anvil knows the full set of handlers Control4 can call, so it can show you not just the events your driver *handles* but also the ones it *doesn't*. An **unimplemented** handler is one Control4 may invoke that your driver doesn't define yet. On the [Events](/platform/events) page, the **Implementation Status** filter switches between all events, only implemented handlers, or only unimplemented ones; unimplemented events render at reduced opacity so they stand out. It's a quick way to see which Control4 events your driver still needs to handle. --- ## Start a driver from a template Starting a new driver? `driverforge new` creates the project from a template with the Driverforge SDK already set up, so the driver sends telemetry from its first deploy. To add Anvil to a driver you already have, follow the [Quick start](/platform/quick-start) instead. ### Prerequisites - **Control4 OS 3.3.1 or newer** on the controller you'll deploy to - The [Anvil Agent installed](/agent/installation) on that controller - The [`driverforge` CLI installed](/cli/installation) - An [Anvil](https://dev.driverforge.com) account ### 1. Sign in ```bash driverforge login ``` ### 2. Create the driver ```bash driverforge new my-driver ``` [`new`](/cli/new) creates `./my-driver` from the official template, then asks which Anvil project the driver reports to (an existing one, or a new one it creates), how to version it, and whether to add build configurations and forward logs. When it finishes it prints a link to the project in Anvil and offers to open it. That page shows the remaining steps below and moves on to your data as soon as the first telemetry arrives. ### 3. Deploy it ```bash cd my-driver driverforge device select driverforge deploy ``` [`device select`](/cli/device) picks the controller to target. [`deploy`](/cli/deploy) builds the driver, sends it to the agent on that controller, and loads it. ### 4. Watch the telemetry Telemetry starts when the driver loads on the controller. Follow it from the terminal: ```bash driverforge events --follow ``` or open the project in [Anvil](https://dev.driverforge.com) to see [events](/platform/events), [logs](/platform/logs) and [errors](/platform/errors) as they arrive. ### Next steps - Start from your own templates with [`--repo`](/cli/new#--repo), and [write them](/cli/templates) - Learn about [automatic event capture](/sdk/automatic-capture) - Let a [coding agent](/coding-agents/overview) read your telemetry and work on the driver with you --- ## Billing The **Settings → Payment** page, under **Billing** in the settings sidebar, is where you manage how your organization pays and review what you've been charged. > **Tip** > > Managing billing requires the **owner** or **admin** role. Billing is **per > organization**: each one has its own payment methods and invoice history. ### Payment methods The card marked as default is the one used for your subscription. 1. On the **Billing** page, click **Add Payment Method** (or **Change payment method** if one is already on file). 2. Enter your card details and save. Cards are handled securely through our payment processor; Anvil never stores your full card number. You can add more than one card, change which is the default, and remove cards you no longer use. ### Billing details When you add or update payment, you can also provide a **billing address** and **tax ID** so your invoices show the correct tax for your region. ### Invoices Your recent invoices are listed with their number, date, amount, and status (for example **Paid** or **Open**). The invoice number opens a hosted copy you can view or print, and **Download** saves the PDF. If you need an older invoice than the page lists, contact support. ### Further reading - [Subscription](/platform/subscription): view your plan and usage, upgrade, downgrade, or cancel - [Plans](/platform/plans): what each tier includes --- ## Events The Events page shows every handler call in your drivers in real time. See exactly what Control4 is sending, what arguments are passed, how long each handler takes, and whether it succeeded or threw an error. The page covers every project in your organization. Use the **project filter** at the top to narrow it to one driver, or leave it as-is to watch them all at once. See [Managing projects](/platform/projects) for how the filter works. ### Real-Time Event Stream Events stream in as they happen, each one a two-line row: - A **status glyph** showing whether the event succeeded, errored, warned, or something else. The glyph's shape carries the status as well as its colour, so it stays readable without relying on colour alone. - The **handler name** (for example `OnPropertyChanged`, `ExecuteCommand`) with its **duration** alongside. - Underneath, the **last log output** from that handler, or the error message if it threw. - Trailing the row, badges naming the **project** and **platform** the event came from, the **controller** it ran on, and the **time** it occurred (hover for the full timestamp). New events appear at the top of the list with a brief pulse animation, tinted by status, so you can see what just arrived. #### Pause and Resume Click the **pause button** next to the time filter to freeze the stream while you inspect something. While paused: - Events continue to buffer in the background - A badge shows how many events are waiting (red if any contain errors) - Click play to flush the buffer and resume live streaming #### Jump to Live If you scroll down through older events, a **Jump to live** button appears to snap you back to the latest events. ### Event Detail Click any event row to open the detail drawer. The drawer opens on the **Logs** tab, since what your code did during the handler is usually the reason you clicked. The tabs are: - **Logs**, every log message captured during this event's execution, as a numbered console you can search - **Arguments**, a full JSON view of the arguments Control4 passed - **Error** if the event threw (the error type, value, and full stack trace), or **Return Value** if it didn't - **Details**, the event's metadata (driver, controller, and the like) plus the raw event JSON Events are shareable: use the link button in the drawer header to copy a URL that opens the same event for whoever you send it to. ### Histogram Above the event list, a stacked bar chart shows event volume over time. Bars are coloured by status so you can quickly spot error spikes. Hover over any bar for a breakdown by status with counts. The histogram automatically adjusts its bucket size based on the selected time range. ### Filtering #### Projects The project filter narrows the stream (and the histogram and facet counts along with it) to the projects you tick. Your selection is held in the URL, so a filtered view is a link you can share. #### Time Range Select a time range from the dropdown: 15 minutes, 1 hour, 4 hours, 1 day, 2 days, 7 days, 14 days, 30 days, 60 days, or 90 days. Available ranges are clamped to your plan's data retention period. #### Facets Filter by multiple dimensions simultaneously: - **Status**: Success, OK, Error, Fatal, Warning, Info, Debug, Trace - **Event Name**: multi-select dropdown showing all captured handlers with counts - **Controller**: filter by specific controller (shown as formatted MAC address) Each facet shows the count of matching events, so you can see the distribution at a glance. #### Implementation Status Toggle between showing all events, only implemented handlers, or only unimplemented handlers. Unimplemented events are shown at reduced opacity so they're visually distinct. See [Captured Handlers](/platform/captured-handlers) for what Anvil captures and how implementation coverage works. > **Note** > > Facet filtering (Status, Event Name, Controller) is available on paid plans. Implementation status filtering and basic event streaming are available on all plans. ### Keyboard Navigation Navigate the event list without leaving your keyboard: - `j` / `k` (or `↓` / `↑`) to move down and up through events - `Enter` to open the selected event's detail drawer, and `Esc` to close it With the drawer open, `j` and `k` move it straight to the next or previous event. Press `?` for the full shortcut list, including time-range and pause shortcuts. > **Note** > > If every project in the current filter is a Monitor-mode project, Events disappears from the sidebar: production monitoring is concerned with logs and errors rather than the handler-by-handler stream. Selecting a project that isn't in Monitor mode brings it back. --- ## Managing your organization An **organization** is your top-level workspace in Anvil, and it's the scope everything else sits inside. It owns your [projects](/platform/projects), [members](/platform/members), [devices](/platform/devices), and [billing](/platform/billing). You can belong to more than one organization (a personal one and a company one, for example) and switch between them at any time. Nothing is shared between organizations: each has its own projects, members, devices, and subscription. The dashboard, events, logs, and errors views all cover the organization you're currently in, filtered to whichever [projects](/platform/projects) you've selected. You get your first organization when you create your Anvil account. ### Switching organizations The organization you're in is shown at the **top of the sidebar**. Click it to open the switcher and pick another one. The whole app (dashboard, data views, settings) switches to that organization. ### Creating another organization 1. Click the organization at the **top of the sidebar** and choose **Add organization**. 2. Enter a **name** for the organization. 3. If you're prompted, choose a [plan](/platform/plans). Your first organization can run on the free Hobby plan; creating additional organizations may require a paid plan, in which case you'll set up payment before the organization is created. 4. Optionally create your first [project](/platform/projects) to finish setting up. ### Editing organization settings Go to **Settings → General** (owners and admins only): - **Organization Name**: how the organization appears throughout Anvil. - **Organization Slug**: the short identifier used in your Anvil URLs (lowercase letters, numbers, and hyphens). Click **Save Changes** to apply. ### Deleting an organization 1. Go to **Settings → General**. 2. Scroll to the **Danger Zone** and click **Delete this organization** (owners only). 3. In the confirmation dialog, type the organization's name exactly, then confirm. > **Warning** > > Deleting an organization is permanent. It removes the organization and **all of > its projects**, along with their telemetry and API keys. This can't be undone. ### Other organization settings The settings sidebar also holds: - **Members**, covered in [Members & roles](/platform/members). - **Projects** and **Devices**, the same pages the main sidebar links to. - **API Keys**, for organization-level secret keys that grant API access. These are still in development; the per-project [driver tokens](/platform/project-tokens) your drivers use live in each project's settings. - **Integrations**, for connecting Anvil to issue trackers, chat, and alerting tools. Also still in development, with a link to vote on what you'd like to see first. - **Subscription** and **Payment**, covered in [Subscription](/platform/subscription) and [Billing](/platform/billing). Which of these you see depends on your role. ### Further reading - [Members & roles](/platform/members), invite people and control what they can do - [Projects](/platform/projects), create and manage the projects in your organization - [Subscription](/platform/subscription) and [Billing](/platform/billing), your plan, usage, and payment --- ## Devices A **device** is a Control4 controller that's registered to your organization. A controller registers itself when the [Anvil Agent](/agent/overview) is installed on it, and from then on it's a target you can deploy drivers to with the [CLI](/cli/deploy). > **Tip** > > Managing devices requires the **owner** or **admin** role. ### The Devices page **Devices** is reachable from the **Manage** group in the sidebar, and also from **Settings → Devices**. It lists every controller registered to your organization, with its name, address, platform, and status (for example **Active** or **Revoked**). The [`driverforge device`](/cli/context) commands work against this same list: `driverforge device list` shows these controllers and `driverforge device select` chooses which one the CLI deploys to. Devices belong to the organization rather than to any one project, so the project filter doesn't apply here. ### Renaming a device Controllers register with a system-generated name; give yours something memorable. 1. On the **Devices** page, open the **⋯** menu for the device and choose **Rename**. 2. Enter a new name and save. ### Revoking a device Revoking cuts a controller off: it stops accepting that controller's telemetry and frees the device's slot in your plan quota. 1. Open the **⋯** menu for the device and choose **Revoke device**. 2. Confirm in the dialog. A revoked controller shows a **Revoked** status. If the controller sends data again it is re-registered automatically, provided a slot is available. ### Removing a device **Remove device** in the **⋯** menu deletes the controller from the list entirely. Use it to tidy up hardware you've retired, rather than as a way to block a controller; a removed controller that sends data again re-registers like any new one. ### Device limits Your [plan](/platform/plans) sets how many active controllers your organization can have. If you hit the limit, revoke a controller you no longer use or [upgrade](/platform/subscription). Anvil warns you in the app when new controllers are being turned away because the quota is full. ### Further reading - [Anvil Agent](/agent/overview): how a controller registers and what the agent does - [`driverforge device`](/cli/context): selecting the deploy target from the CLI - [`driverforge deploy`](/cli/deploy) / [`driverforge sync`](/cli/sync): pushing drivers to a controller --- ## Members & roles Invite people to your organization and control what they can do. Member management lives under **Settings → Members**, reached from **Settings** in the sidebar. > **Tip** > > Inviting, removing, and re-roling members requires the **owner** or **admin** > role. Members can see the organization's projects but can't manage other people. ### Roles Every member has one of three roles: | Role | Can do | |------|--------| | **Owner** | Everything, including managing billing and subscriptions, managing all members and roles, and deleting the organization. | | **Admin** | Invite and remove members, create and manage projects, and access all projects. | | **Member** | Access the organization's projects. | An organization can have several owners, but there must always be at least one. ### Inviting a member 1. Go to **Settings → Members** and click **Invite Member**. 2. Enter the person's **email address**. 3. Choose a **role** (Member, Admin, or Owner) from the dropdown. The default is Member. 4. Click **Send Invite**. The invitation is emailed to that address and appears under **Invited Members**. - Invitations expire after **7 days**. - The invitee doesn't need an Anvil account yet; they'll be prompted to create one when they accept. > **Note** > > If you've reached your [plan](/platform/plans)'s member limit, the invite form is > replaced by an upgrade prompt. See [Subscription](/platform/subscription) to add > seats or change plans. #### Managing pending invitations Under **Invited Members**, each pending invitation shows when it was sent and when it expires, and can be: - **Resend invitation**, to send a fresh email and reset the 7-day expiry. - **Revoke invitation**, to cancel it so the link no longer works. ### Changing a member's role 1. Go to **Settings → Members**. 2. Open the **⋯** menu next to the member and choose **Change Role**. 3. Pick the new role (you'll see what each role can do) and confirm. ### Removing a member 1. Open the **⋯** menu next to the member and choose **Remove**. 2. Confirm the removal. ### Rules that keep things safe - You can't manage members with **higher** privilege than your own role. An admin can't change or remove an owner, for instance, but one admin can manage another and one owner can manage another. - You can't remove or demote the **last owner**; promote someone else to owner first. ### Further reading - [Managing your organization](/platform/organizations): general settings and deletion - [Subscription](/platform/subscription): member limits and adding seats --- ## Plans Anvil comes in several tiers, from a free **Hobby** plan up to **Enterprise**. Your plan applies to a whole [organization](/platform/organizations) and sets both your limits and which features are available. Plans differ along a couple of dimensions: - **Limits**: how many members, projects, and devices an organization can have, and how long your events, logs, and errors are retained. - **Features**: capabilities like facet filtering and search across the data pages, work login (Google Workspace, Microsoft 365), and single sign-on. The core events, logs, and errors views and live streaming are available on every plan. The free Hobby plan is a good place to start; Enterprise is custom-priced and arranged with our sales team. > **Note** > > To compare tiers and see current limits and pricing, open **Settings → > Subscription → Change Plan** in Anvil. See [Subscription](/platform/subscription) > to upgrade, downgrade, or cancel, and [Billing](/platform/billing) to manage > payment. --- ## Troubleshooting Common issues and how to fix them. ### No Events Appearing #### Check the Controller's OS Version Anvil requires **Control4 OS 3.3.1 or newer**. Below that the SDK switches itself off at load, so a correctly-installed driver produces no telemetry at all, which looks identical to a broken setup. Check the controller's logs for this line when the driver loads: ``` Anvil: this controller is running Control4 OS older than 3.3.1 - the SDK has disabled itself and the driver will run uninstrumented. ``` Or ask the SDK directly: `Anvil:TelemetryStatus()` returns `unsupported-runtime` on a controller below the floor. If you see either, nothing else on this page will help: the controller needs upgrading. #### Check the Agent 1. Open Composer Pro 2. Select the Anvil Agent 3. Check the **Authentication status** property: it should show `Logged in as you@youremail.com` If not logged in: - Re-authenticate via **Actions** > **Get authentication link** - Check the controller has internet access - Verify outbound access to `ingest.driverforge.com:8883` is not blocked by a firewall #### Check Your Driver Make sure `Driverforge:Init()` is called: ```lua function OnDriverInit(strDIR) require('vendor.driverforge-sdk') Driverforge:Init(driverToken) -- ... end ``` #### Check Your Project Token The token passed to `Driverforge:Init()` must be the project token of the project you're expecting data in. In Anvil, open **Settings > Projects**, click the gear icon on your project, and copy the token directly from **Project Token** to avoid typos. A project token doesn't expire and can't be revoked, so there's no status to check: if it's the right value for the right project, it works. The usual causes are a typo, or a token copied from a different project than the one you're watching. Confirm the token in your driver matches the project whose Events page you have open. See [Project tokens](/platform/project-tokens) for how tokens work. #### Trigger an Event Try changing a property or executing a command in Composer. If basic events don't appear, something is wrong with the setup. ### SDK Not Loading If you set the driver up with [`driverforge init`](/cli/init), run [`driverforge doctor`](/cli/doctor) first. It checks each piece `init` put in place and offers to restore whatever is missing. #### Check the Path Your `require()` path must match your directory structure: ```lua -- If file is at src/vendor/driverforge-sdk.lua require('vendor.driverforge-sdk') ``` #### Check the Manifest The SDK file must be in your `manifest.c4zproj`: ```xml ``` #### Check Controller Logs Look for Lua errors when the driver loads. Common issues: - File not found - Syntax errors in the SDK - Missing dependencies ### Timer/URL Errors Not Showing The SDK can't automatically capture errors in `C4:SetTimer` or `C4:url()` callbacks because `C4` is a protected userdata object. These need to be instrumented manually. See [Manual Capture](/sdk/manual-capture) for how to handle timers and URL callbacks. ### Events Delayed or Missing #### Check Network Events stream over the network. High latency or packet loss can cause delays. #### Check Agent Debug Mode Enable debug mode on the agent to see what it's receiving: 1. Select Anvil Agent in Composer 2. Set **Debug Mode** to "On" 3. Check Lua Output ### Need Help? We're here to help. Reach out to our support team at [support@driverforge.com](mailto:support@driverforge.com) and we'll get you sorted. --- ## Subscription The **Settings → Subscription** page, under **Billing** in the settings sidebar, shows your organization's current [plan](/platform/plans), how much of it you're using, and the controls to change plans. > **Tip** > > Managing the subscription requires the **owner** or **admin** role. Billing is > per organization: each one has its own plan and payment. ### Your current plan The page shows your active plan, its status, your renewal date, and the full list of what the plan includes. A **Usage & Limits** panel tracks where you stand against your plan's allowances: **Members**, **Projects**, and **Devices** each show a count against your limit with a meter that turns amber as you approach it, plus your **data retention** window. When you reach a limit, Anvil stops you creating more of that resource and points you to upgrade. ### Changing your plan 1. On the **Subscription** page, click **Change Plan**. 2. Compare the tiers and choose one: - **Upgrade** to a higher tier. - **Downgrade** to a lower tier. - **Contact Sales** for Enterprise (it isn't self-serve). 3. Confirm the change. How a change takes effect depends on the direction: - **Upgrades** apply immediately. You'll see a cost preview (the prorated charge for the rest of the current billing period, plus any tax) and confirm with a [payment method](/platform/billing). You're billed at the new rate from then on. - **Downgrades** apply at the **end of your current billing period**, so you keep what you've paid for until then. Anvil tells you which features you'll lose before you confirm. A scheduled change (such as a pending downgrade) is shown on the page until it takes effect. ### Cancelling Cancelling stops future billing. Your subscription stays active until the end of the current period, then the organization moves to the free Hobby plan with its lower limits and shorter retention. ### If a payment fails If a payment can't be collected, the subscription becomes **past due** and the organization goes **read-only**: existing data stays visible, but new telemetry isn't ingested until the payment method is updated. The Subscription page shows an alert with a link to fix it; see [Billing](/platform/billing) to update your card. ### Further reading - [Plans](/platform/plans): what the tiers include - [Billing](/platform/billing): payment methods and invoices - [Members & roles](/platform/members): adding seats --- ## Logs The Logs page (titled **Log Explorer** in the app) shows all log output from your drivers in real time. Filter by level, search by message content, and pick up right where you left off: logs persist across driver reloads, so there's no need to keep Composer Pro's Lua tab open. To learn how to forward logs from your driver to Anvil, see [Log Forwarding](/sdk/log-forwarding) in the SDK section. The page covers every project in your organization. Use the **project filter** at the top to narrow it to one driver. See [Managing projects](/platform/projects) for how the filter works. ### Real-Time Log Stream Logs stream in as they happen. Each row shows: - **Level**, a coloured indicator (red for error, amber for warn, blue for info, green for debug, grey for trace) - **Time**, when the log was recorded (hover for the full timestamp) - **Project**, which project the log came from, so a merged stream still tells you which driver logged it - **Event**, the linked event name, if the log was captured during an event handler - **Message**, the full log message To find which *controller* a log came from, use the Controller facet or open the log's detail drawer. #### Pause and Resume Click the **pause button** to freeze the stream while you read through logs. Events continue buffering in the background, and a badge shows how many are waiting. Click play to flush the buffer and resume. ### Log Detail Click any log row to open the detail drawer. The detail drawer shows: - The **level** badge and the full timestamp - **Message**, the complete log message (selectable for copying, with a copy button in the header) - **Arguments**, the values the log call was given, as a JSON tree, when any of them wasn't a string. A note says so if the SDK's size limits cut them (see [Tables and Other Values](/sdk/log-forwarding#tables-and-other-values)) - **Context**: the project, platform, controller, and driver the log came from, plus the event that was executing - **Tags**, any key-value pairs attached to the log, as JSON - **View Related Event**, if the log was captured during an event handler, to jump to that event (see [Logs vs Events](/platform/logs-vs-events)) ### Histogram A bar chart above the log list shows log volume over time. Hover for a breakdown by level with counts. The histogram adjusts its bucket size based on the selected time range. ### Filtering #### Projects The project filter narrows the stream (and the histogram and facet counts along with it) to the projects you tick. Your selection is held in the URL, so a filtered view is a link you can share. #### Time Range Select from preset ranges: 15 minutes through to 90 days, clamped to your plan's retention period. #### Message Search Search for logs containing specific text. The search is a substring match with a short debounce, so results update as you type. Message search is available on all plans. #### Facets Filter by multiple dimensions, each showing a count so you can see the distribution at a glance: - **Level**, one of Error, Fatal, Warn, Warning, Info, Debug, or Trace - **Controller**, shown as a formatted MAC address > **Note** > > Facet filtering (Level and Controller) is available on paid plans. Message search and basic log streaming are available on all plans. ### Keyboard Navigation - `j` / `k` (or `↓` / `↑`) to move down and up through logs - `Enter` to open the selected log's detail drawer, and `Esc` to close it Press `?` for the full shortcut list. --- ## Logs vs Events Logs and events complement each other: - **Events** show you what Control4 sends to your driver: handler calls, arguments, timing - **Logs** show you what your code does with it: your own messages, state, flow Each log captured during an event handler is linked to that event. On the [Events](/platform/events) page, you can open an event's detail drawer and switch to the **Logs** tab to see exactly what your code logged during that handler's execution. It works the other way too: on the [Logs](/platform/logs) page, each log row shows its linked event name; click through to jump to the event that was executing when the log was recorded. --- ## Project tokens Every Anvil project has a **project token** that your driver uses to send telemetry (events, logs, and errors) to that project. It's the value you pass to `Driverforge:Init()` in your driver. The token is created with the project, so you can start sending data the moment the project exists. Anvil has two classes of credential, and they behave differently: | Class | Where it lives | What it's for | | ------------------------------ | ------------------------------------------------------- | ------------------------------------------------------------------------ | | **Static token** (publishable) | On the thing it identifies: a project, an installation | Naming which project telemetry belongs to. Safe to embed and distribute. | | **API key** (secret) | Organization settings | Server-side access to the Anvil API. A credential to protect. | The rest of this page is about your project token, which is what you need to send telemetry. Organization-level secret API keys are still in development; you'll find the placeholder under **Settings → API Keys**. ### Safe to commit **You can commit your project token directly in your driver source**, for example in your `OnDriverInit` function: ```lua Driverforge:Init("drv_3HipSk6nrxTCGGDvhDB8hXpmmEK") ``` This is intentional and safe, and it's worth knowing _why_ rather than taking it on trust. A project token **identifies**; it doesn't authenticate or authorise. It answers "which project is this telemetry for?", the same job an `{id}` segment does in a URL. Something else proves who is sending: the agent holds a signed token from Anvil's identity server, the broker verifies it on connect, and Anvil then checks that the sender has permission on the project's organisation. Your project token is not what gets you in. So a copy of your token doesn't let anyone in. It's designed to be embedded in the driver you distribute to customers, so it already travels inside every copy you ship. You **don't** need build-time secret injection, environment variables, or a secrets manager for it. > **Tip** > > Don't build a pipeline to keep your project token out of source control. It isn't a secret; commit it like any other configuration value. ### What a project token can do Project tokens are **write-only**. A token names exactly one project, and telemetry sent with it lands in that project. It **cannot**: - read any of your events, logs, or errors, - change project or organization settings, - access any other project, or - act on your account in any way. That narrow scope is what makes the token safe to embed and distribute. ### Recognising a token Project tokens begin with `drv_`, followed by 27 characters: ``` drv_3HipSk6nrxTCGGDvhDB8hXpmmEK ``` Other prefixes you may come across: - `inst_…` identifies an installation: a specific site where a dealer installed your driver. - `dfa_…` and `dfs_…` are secret organization API keys. Anything starting `df` is a secret, always. These are stored hashed and shown only once, so they behave nothing like a project token. ### Your project token doesn't expire A project has **one** project token, for its whole life. There's nothing to rotate, expire or revoke, and no list of old tokens to keep track of. Open **Settings → Projects**, click the **gear icon** on the project's row, and find the **Project Token** section in the drawer that opens. Copy it whenever you need it; the full value stays available, because it isn't a secret. This is deliberate. Your token ships inside compiled drivers installed on controllers in customers' homes, and those aren't updated in place. A token that could be revoked would mean an action in Anvil could stop every installed copy of your driver reporting, without stopping anyone who had already taken a copy of the value. Since the token grants nothing on its own, there's nothing worth that trade. If you need telemetry to stop arriving for a project entirely, delete the project. --- ## Managing projects A **project** is where a driver's telemetry lives. Each project has its own [project token](/platform/project-tokens) and its own settings. Most teams use one project per driver, often with separate projects for development and production. You can create as many projects as your [plan](/platform/plans) allows. Projects are not places you navigate into. The [events, logs, and errors](/) views are scoped to your whole organization, and the **project filter** above each one narrows what you're looking at. Selecting a single project is how you focus on one driver; leaving everything selected shows the organization as a whole. > **Tip** > > Creating and managing projects requires the **owner** or **admin** role in the > organization. See [Members & roles](/platform/members). ### Using the project filter The project filter sits next to the time range above the dashboard, Events, Logs, and Errors. Tick the projects you want and the view (including its histogram and facet counts) recalculates for that selection. Your selection is held in the page URL, so a filtered view is a link you can send to a colleague and they'll see the same thing. Clearing the selection returns to all projects and leaves the URL clean. Because the views merge several projects into one stream, each row carries a pair of small badges naming the project and its platform. That's how you tell which driver a log line or error came from without narrowing the filter. ### Creating a project You can start a new project from either of two places: - the **New project** row at the bottom of the project filter dropdown, or - the **New Project** button on the **Settings → Projects** page. Then: 1. Select the **platform** your driver targets. Control4 is supported today; selecting another platform shows a "coming soon" notice. 2. Type a **Project Name**. This is how the project appears throughout Anvil, and you can change it later. 3. Optionally add a **Description** to remind you and your team what the project is for. 4. Click **Create Project**. When the project is created, Anvil mints its **project token** so you can start sending telemetry immediately (see [Project tokens and API keys](/platform/project-tokens)), then takes you straight to the setup instructions with the filter narrowed to your new project. From there, follow the [Quick start](/platform/quick-start) to wire the SDK into your driver and send your first events. The setup view is a temporary state: once telemetry arrives, that same page becomes the normal dashboard. > **Note** > > Your [plan](/platform/plans) sets how many projects an organization can have. If > you've reached the limit, you'll be prompted to upgrade instead of creating > another. ### The Projects page **Settings → Projects** lists every project in the organization. Each row shows the project's name, platform, description, and a sparkline of the last 24 hours of activity, so you can see at a glance which drivers are busy. A project that hasn't received data yet shows a **Complete setup** button instead of a sparkline, which takes you to its setup instructions. ### Project settings Click the **gear icon** on a project's row to open its settings drawer. Everything about a single project lives there: - **Project Name**, to rename the project. - **Project Slug**, the short identifier used when a project appears in a URL (lowercase letters, numbers, and hyphens). - **Description**, the optional description. - **Project Token**, the value your driver sends telemetry with. It identifies the project and is created with it. See [Project tokens](/platform/project-tokens) for why it's safe to commit. - **Danger Zone**, to delete the project. Click **Save Changes** to apply your edits. ### Deleting a project 1. Open the project's settings drawer from **Settings → Projects**. 2. Scroll to the **Danger Zone** and click **Delete project**. 3. In the confirmation dialog, type the project's name exactly, then confirm. > **Warning** > > Deleting a project is permanent. Its events, logs, errors, and its project token > are removed and can't be recovered. Because the token goes with it, any > installed driver still sending with it stops resolving. Migrate or export > anything you still need first. ### Further reading - [Quick start](/platform/quick-start), wire the SDK into your driver and send your first events - [Project tokens](/platform/project-tokens), how a project's token works and why it's safe to commit - [Members & roles](/platform/members), who can create and manage projects - [Plans](/platform/plans), project limits by plan --- ## Errors The Errors page groups exceptions thrown by your drivers so you can focus on unique issues rather than wading through duplicates. Each error group shows how often it occurs, when it was last seen, and a trend sparkline. The page covers every project in your organization. Use the **project filter** at the top to narrow it to one driver. See [Managing projects](/platform/projects) for how the filter works. ### Error Groups Errors are automatically grouped by their fingerprint (see [Error Grouping](/platform/error-grouping) for details). Each row in the list shows: - The error **type** (for example `LuaError`) and its **value**, the error message - **Last seen** and **First seen**, both relative, with the full timestamp on hover - Badges naming the **project** and **platform** the error came from - A **trend** sparkline of occurrence frequency across the selected time range - A **count** of total occurrences This lets you quickly see which errors are frequent, which are new, and which are trending up or down. ### Error Detail Click an error group to open the detail page. This gives you everything you need to diagnose the issue: #### Stack Trace A formatted, syntax-highlighted view of the call stack showing file names, line numbers, and function names. If you've uploaded [source maps](/cli/source-maps), the stack trace maps back to your original source files rather than the bundled output. #### Occurrences A table of every individual occurrence of this error, showing: - **Error ID**: unique identifier (click to view that specific occurrence) - **Timestamp**: when it happened - **Message**: the error message for this occurrence - **Version**: the driver version that produced it Navigate between occurrences using the **Previous** / **Next** buttons, or jump to the first or last occurrence. #### Sidebar Alongside the stack trace, a sidebar summarises the group: when it was **last seen** and **first seen**, and which driver **versions** have produced it. It also has a shortcut to configure an issue tracker, so errors can become work items in Jira, Linear, GitHub, and similar tools. That integration is still in development; see [Managing your organization](/platform/organizations). #### Context Expandable sections below the stack trace: - **Tags**, key-value pairs attached to the error - **Contexts**, the full JSON payload from the error context - **Event Grouping Information**, the fingerprint strategy, hash, and raw grouping data used to identify this error group (collapsed by default) ### Histogram A bar chart above the error list shows error volume over time. Hover for counts at each time bucket. The histogram adjusts automatically based on the selected time range. ### Real-Time Streaming New errors stream in via WebSocket. When a new occurrence of an existing error arrives, the group's count, last seen, and sparkline update in place. New error groups appear at the top of the list. The same pause/resume controls from Events and Logs are available: pause the stream to inspect, and a badge shows how many errors are buffered. ### Automatic Capture Errors in event handlers are captured automatically. You don't need to add any error handling code; just add the Driverforge SDK and errors appear in Anvil. Note that errors in `C4:SetTimer` and `C4:url()` callbacks need manual instrumentation because `C4` is a protected userdata object. See [Manual Capture](/sdk/manual-capture) for details. ### Keyboard Navigation - `j` / `k` (or `↓` / `↑`) to move down and up through error groups - `Enter` to open the selected error's detail page Press `?` for the full shortcut list. --- ## Account settings Your **account** is personal to you and separate from any [organization](/platform/organizations). It's your single Anvil login, which can belong to several organizations at once. Organization settings (members, billing, projects) are managed per organization; the settings here are about *you*. ### Getting there Open the **user menu** at the bottom of the sidebar and choose **Settings**. Your account settings open in Anvil's dedicated account area. ### What you can manage - **Profile**: your name, email, and avatar. - **Password**: change your password. - **Passkeys**: add passkeys for passwordless sign-in. - **Connected accounts**: link or unlink social logins (such as Google) you use to sign in. - **Two-factor authentication**: add a second factor for extra security. - **Sessions**: review where you're signed in and sign out other sessions. ### Account vs organization Signing out, changing your password, or adding a passkey affects your login everywhere. Changing an organization's name, members, or plan only affects that organization. If you lead a team, see [Members & roles](/platform/members) for managing who can access your organization. --- ## Quick start Install the agent on your controller, let the `driverforge` CLI set up your driver, and deploy it. Events start streaming to Anvil as soon as the driver loads. Starting a new driver rather than adding Anvil to an existing one? See [Start a driver from a template](/platform/start-from-a-template). ### Prerequisites - **Control4 OS 3.3.1 or newer** on the controller running your driver - An existing driver project: a directory with `src/manifest.c4zproj` - An [Anvil](https://dev.driverforge.com) account > **Info: Older controllers** > > On anything below OS 3.3.1 the SDK disables itself at load and your driver runs exactly as it would with no SDK vendored at all. Nothing breaks; you just get no telemetry. See [SDK installation](/sdk/installation#control4-os-331-or-newer) for what that looks like. ### 1. Install the Anvil Agent The agent is a system driver on your controller that streams your driver's telemetry to Anvil. Install it and sign it in with the [agent installation guide](/agent/installation). ### 2. Install the CLI On macOS: ```bash brew tap driverforge/tap brew install driverforge ``` On Linux: ```bash sh -c "$(curl -fsSL https://go.driverforge.com/get)" ``` See [CLI installation](/cli/installation) for Windows and the details of each method. ### 3. Sign in ```bash driverforge login ``` ### 4. Set up your driver From your driver project's directory, run: ```bash driverforge init ``` [`init`](/cli/init) embeds the Driverforge SDK, wraps your `OnDriverInit` so Anvil initializes when the driver loads, and links your driver to an Anvil project, creating one if you need it. It shows you a diff of every change before it writes anything. ### 5. Deploy Choose the controller to deploy to, then deploy: ```bash driverforge device select driverforge deploy ``` [`deploy`](/cli/deploy) builds your driver, sends it to the agent on the controller, and reloads it. Events start streaming to Anvil immediately. ### 6. View your data in Anvil Open your project in [Anvil](https://dev.driverforge.com) to see data flowing in real time. The [Events](/platform/events) page shows every handler call as it happens, [Logs](/platform/logs) shows your driver's log output, and [Errors](/platform/errors) surfaces any exceptions with full stack traces. Interact with your driver in a navigator or Composer to see events appear instantly. You can read the same data from the terminal with [`driverforge events`](/cli/events), [`driverforge logs`](/cli/logs) and [`driverforge errors`](/cli/errors). ### Setting up without the CLI To add the SDK to your driver by hand instead, follow [SDK installation](/sdk/installation). ### Next steps - Learn about [automatic event capture](/sdk/automatic-capture) - See how to [capture timer and URL callback errors](/sdk/manual-capture) - Review the [API reference](/sdk/api-reference) - Let a [coding agent](/coding-agents/overview) read your telemetry and work on the driver with you --- ## Overview Anvil gives you a real-time view of what's happening inside your Control4 drivers. Events, logs, and errors stream in as they happen, so there's no guessing what your driver is doing and no digging through Composer's Lua output. ### Why Anvil Developing Control4 drivers can feel like working in the dark: - **Events are opaque** - Proxies call your driver's code, but it can be hard to know which commands are being received, what data they're sent with, and which events need to be handled in your driver. - **Errors vanish** - Uncaught errors are easy to miss, relying on text logging that easily gets lost between Composer refreshes and driver reloads. - **Debugging is painful** - Print statements and log diving only get you so far. Anvil captures every handler call, log line and unhandled error in your driver automatically, and keeps them, so you can see exactly what Control4 sent your driver and what your driver did with it. ### How it works ![Anvil architecture: Your driver → Anvil Agent → Anvil](/img/anvil-architecture.svg) 1. **Install the Agent** - A system driver on your dev controller that streams data to Anvil 2. **Add the Driverforge SDK** - A small Lua library that instruments your driver automatically 3. **Watch the stream** - Events appear in real-time as your driver runs The [Quick start](/platform/quick-start) takes you through all three. ### Requirements Anvil needs **Control4 OS 3.3.1 or newer** on the controller running your driver. On older controllers the SDK disables itself at load, so a driver that ships with it is safe to install anywhere; it simply produces no telemetry where it cannot be delivered. See [SDK installation](/sdk/installation#control4-os-331-or-newer). ### How Anvil is organised Your [organization](/platform/organizations) is the scope you work in. Everything you open (the dashboard, events, logs, errors) covers the whole organization by default, and a [project](/platform/projects) is a **filter** you apply on top rather than a place you navigate into. If you've used Sentry, this will feel familiar. That means one stream per view instead of one per driver: you can watch every driver in the organization at once, then narrow to a single project when you want to focus. Each row carries a small badge naming the project and platform it came from, so a merged stream still tells you where each item originated. #### The sidebar The left sidebar is the same on every page: - At the **top**, the organization you're currently in. Click it to switch organizations or add a new one. - **Dashboard**, your organization's activity at a glance. - **Build**, the three data views: [Events](/platform/events), [Logs](/platform/logs), and [Errors](/platform/errors). - **Manage**, shortcuts to [Projects](/platform/projects) and [Devices](/platform/devices), plus **Settings** for everything else. - At the **bottom**, your user menu: your own account settings, the light/dark theme, keyboard shortcuts, and links to the docs, community, and changelog. Opening **Settings** swaps the sidebar for the settings sections (Organization, Manage, Third Party Access, and Billing), with a **Back to _your organization_** link at the top to return. You're either in the app or in settings; there are no nested layers of settings to get lost in. #### The filter bar Above the dashboard and each of the three data views sit two controls: - The **project filter**, which narrows the view to one or more projects. Leaving everything selected (the default) shows the whole organization. Your selection is held in the page URL, so a filtered view is a link you can share. The dropdown also has a **New project** row, which is the quickest way to create one. - The **time range**, covering 15 minutes through to 90 days, clamped to your [plan](/platform/plans)'s retention window, along with the pause button for the live stream. ### What you get #### Events Every handler call your driver receives is captured automatically: `OnPropertyChanged`, `ExecuteCommand`, `ReceivedFromProxy`, and [100+ others](/sdk/automatic-capture). For each event you can see the exact arguments Control4 passed, how long your handler took to execute, and whether it succeeded or threw. [Learn more about Events →](/platform/events) #### Logs Forward your driver's log output to Anvil and see it in real time, persisted across driver reloads and Composer refreshes. Filter by level, search by message, and jump from a log entry to the event that produced it. [Learn more about Logs →](/platform/logs) #### Errors When your driver throws, Anvil captures the error with a full stack trace and groups identical errors together. See at a glance which errors are new, which are recurring, and how often each one occurs. [Learn more about Errors →](/platform/errors) ### The dashboard The dashboard is the organization's bird's-eye view, covering whatever the project filter has in scope: - **Events**, **Logs**, and **Errors** totals for the selected time range, each with a sparkline and a change indicator against the previous period. - **Recent Activity**, the latest errors and events as they arrive. - **Top Errors**, ranked by occurrence count. - **People**, **Projects**, and **Platforms** panels summarising the organization itself. If you narrow the filter to a single project that has never received data, the dashboard shows that project's setup instructions instead of empty tiles, complete with its project token. It reverts to the usual dashboard as soon as data starts flowing. ### Real-time streaming All three views stream in via WebSocket. You can pause the stream to inspect something, and a badge shows how many items are buffering while paused. Click play to flush the buffer and resume. ### Keyboard shortcuts Press `?` anywhere in Anvil for the full list. The essentials: | Keys | Action | |------|--------| | `?` | Show keyboard shortcuts | | `1` `2` `3` `4` | Dashboard, Events, Logs, Errors | | `j` / `k` (or `↓` / `↑`) | Move through the list | | `Enter` | Open the selected item | | `Esc` | Close a drawer or dialog | | `Ctrl+Alt+1` … `Ctrl+Alt+8` | Jump to a time range, 15 minutes through 30 days | | `Ctrl+Alt+L` | Play or pause the live stream | On macOS, `Ctrl+Alt` is shown as `⌃⌥`. ### Managing your workspace Beyond the data views, the platform is where you manage everything around your drivers: - [Organizations](/platform/organizations), your top-level workspace, with [members & roles](/platform/members) - [Your account](/platform/account), your personal login, separate from any organization - [Projects](/platform/projects), one per driver, each with its own [project token](/platform/project-tokens) - [Devices](/platform/devices), the controllers you deploy to - [Subscription](/platform/subscription) and [payment](/platform/billing), covering your [plan](/platform/plans), usage, and cards --- ## Installation ### Prerequisites #### Control4 OS 3.3.1 or newer {#control4-os-331-or-newer} Anvil requires **Control4 OS 3.3.1 or newer** on the controller running your driver. Telemetry needs the Anvil Agent alongside your driver, and the agent needs 3.3.1. Below that the SDK disables itself at load and your driver runs exactly as it would with no SDK vendored at all: same return values, same errors, nothing captured, nothing retained. It says so once on the console rather than failing quietly: ``` Anvil: this controller is running Control4 OS older than 3.3.1 - the SDK has disabled itself and the driver will run uninstrumented. ``` So a driver that ships with the SDK is safe to install anywhere; it simply produces no telemetry on a controller too old to deliver it. Ask the SDK what it is doing with `Anvil:TelemetryStatus()`, which reports `unsupported-runtime` in that case. #### The Anvil Agent The Driverforge SDK requires the Anvil Agent to be installed and authenticated on your controller. The agent is a one-time setup per controller; all drivers on the same controller share it. See the [Agent Installation](/agent/installation) guide for instructions. ### Download Download the latest Driverforge SDK and place the contents in your driver's `vendor/` directory: ``` your_driver/ ├── src/ │ ├── driver.lua │ ├── driver.xml │ └── vendor/ │ └── driverforge-sdk.lua └── manifest.c4zproj ``` #### Manifest configuration Include the vendor directory in your `manifest.c4zproj`: ```xml ``` #### Squish configuration If your project uses a squishy build file, you can bundle the SDK into your squished driver instead of shipping the vendor directory: ```lua Module "vendor.driverforge-sdk" "vendor/driverforge-sdk.lua" ``` The `require('vendor.driverforge-sdk')` call is identical either way: squish satisfies it from the bundle, otherwise Director resolves the vendored file from the packaged driver (which is how the worked example driver ships). #### Initialization Add the SDK initialization to your `OnDriverInit`, using your project's project token (in Anvil, open **Settings > Projects**, click the gear icon on your project, and copy the token from **Project Token**): ```lua function OnDriverInit(strDIR) require('vendor.driverforge-sdk') Driverforge:Init("YOUR_API_KEY") Anvil:OnDriverInit(function(strDIR) -- Your existing OnDriverInit code goes here end, strDIR) end ``` #### Why OnDriverInit needs wrapping `OnDriverInit` is a special case in the Control4 lifecycle. It runs before the SDK has a chance to instrument your handler functions, so it can't be auto-captured like other methods. The `Anvil:OnDriverInit(function(strDIR) ... end, strDIR)` wrapper ensures: - Your init code is captured as an event with timing and error handling - Any errors in your init code are reported with full stack traces - The SDK is fully initialized before your code runs **All other lifecycle methods are automatically instrumented.** You don't need to wrap `OnDriverLateInit`, `OnPropertyChanged`, `ExecuteCommand`, or any of the [100+ auto-captured handlers](/sdk/automatic-capture); just write them normally and they'll appear in Anvil. #### Load order: define handlers first When the SDK loads, it wraps every C4 event handler your driver has defined so far, taking ownership of the handler globals (`OnDriverLateInit`, `OnPropertyChanged`, and the rest) so their events can be observed. Requiring it from `OnDriverInit` satisfies this naturally: Control4 calls `OnDriverInit` after your whole file has executed, so every top-level handler already exists. The contract to keep in mind: **every C4 handler must be defined before the SDK loads.** A handler defined afterwards replaces the SDK's wrapper for that event: - Events for that handler stop appearing in Anvil. - If the replaced handler is `OnDriverLateInit`, the SDK never finishes initialising: [agent discovery](/sdk/automatic-capture#agent-discovery) never runs and nothing streams at all. The SDK detects the situation and prints a warning to the controller log naming the redefined handler. If events go missing, that warning is the first thing to look for. #### Advanced configuration `Driverforge:Init()` accepts an optional second argument for advanced options: ```lua Driverforge:Init("YOUR_API_KEY", { -- Forward your existing logger to Anvil logger = myLogger, -- Custom log method mapping (if your logger uses non-standard method names) logMap = { fatal = "critical", error = "err", }, }) ``` If your driver uses a logging library, passing it to `Driverforge:Init()` enables automatic log forwarding. See [Log Forwarding](/sdk/log-forwarding) for details. See the [API Reference](/sdk/api-reference) for the complete list of options. ### Shipping your driver There's no need for a separate release build without Anvil. Ship the driver you developed, SDK and `Driverforge:Init()` call included: - **The agent is the switch.** The SDK only captures on controllers where the Anvil Agent is installed and authenticated. On any other controller it goes inert after [agent discovery](/sdk/automatic-capture#agent-discovery): no capture, no queuing, and nothing leaves the controller. - **Your project token can ship too.** A project token is publishable: it identifies your project to the agent but grants no access to your data. - **Your telemetry can't be lured away.** Before a driver sends anything, the SDK cryptographically verifies that the device it discovered is the genuine Anvil Agent; an impostor posing as the agent gets nothing. See [Agent Verification](/sdk/trust). ### Troubleshooting #### SDK not loading - Check the `require()` path matches your directory structure - Verify the vendor directory is in `manifest.c4zproj` - Look for Lua errors in controller logs #### Driver not connecting to agent - Ensure `Driverforge:Init()` is called in `OnDriverInit` - Reload your driver (disable and re-enable in Composer) - Check the project token is correct #### No events in Anvil - Verify the agent's **Authentication status** property shows you're logged in - Confirm the project token matches the project you are watching - Check the controller log for a warning about a redefined handler (see [load order](#load-order-define-handlers-first)) - Try triggering an action manually See [Troubleshooting](/platform/troubleshooting) for more help. --- ## Manual Capture Some contexts can't be automatically instrumented. `C4` is a protected userdata object in Lua, so we can't wrap its methods. Timer callbacks and URL responses need explicit handling. > **Tip** > > This page covers **error** capture in async contexts. For **log** forwarding, see [Log Forwarding](/sdk/log-forwarding): Anvil can wrap your existing logger so log messages are forwarded automatically. ### Why This Matters Without manual capture, errors in these contexts are printed to the Lua output but **not captured by Anvil**: ```lua -- This error appears in Lua output but Anvil can't capture it C4:SetTimer(5000, function(timer) error("This won't show up in Anvil!") end) ``` Control4 logs the error to the Lua output, but it's easy to miss, buried in log output that gets lost between Composer refreshes and driver reloads. Anvil can't instrument `C4:SetTimer` callbacks automatically because `C4` is a protected userdata object. ### Timers: Use `Anvil:SetTimer()` Instead of `C4:SetTimer`, use `Anvil:SetTimer`: ```lua -- Before: errors only appear in Lua output, not captured by Anvil C4:SetTimer(5000, function(timer) DoSomething() -- if this throws, it's logged but not in Anvil end) -- After: errors captured by Anvil with full context Anvil:SetTimer(5000, function(timer) DoSomething() -- errors are captured with full stack trace end) ``` It's a drop-in replacement with the same signature: ```lua Anvil:SetTimer(duration, callback, ...) ``` #### Recurring Timers Works the same way: ```lua Anvil:SetTimer(30000, function(timer) PollDevice() timer:Start() -- restart for next poll end) ``` ### URL Callbacks: Use `Anvil:CaptureError()` URL callbacks need a bit more work. Wrap your code with `xpcall`: ```lua C4:url():OnDone(function(transfer, responses, errCode, errMsg) local ok, err = xpcall(function() -- Your code here local data = JSON:decode(responses[transfer].body) ProcessResponse(data) end, function(e) Anvil:CaptureError(e) return e end) end):Get("https://api.example.com/status") ``` #### Helper Pattern If you make lots of HTTP calls, create a helper: ```lua local function safeCallback(fn) return function(...) local args = {...} local ok, err = xpcall(function() fn(table.unpack(args)) end, function(e) Anvil:CaptureError(e) return e end) end end -- Then use it everywhere C4:url():OnDone(safeCallback(function(transfer, responses, errCode, errMsg) -- Your code - errors automatically captured ProcessResponse(responses[transfer]) end)):Get(url) ``` #### Adding Context Include context to make errors easier to understand: ```lua Anvil:CaptureError(err, nil, { eventName = "API_Request", args = { url = "https://api.example.com/status", method = "GET" } }) ``` This shows up in Anvil: ``` ✗ API_Request url: "https://api.example.com/status" method: "GET" ERROR: unexpected response format driver.lua:156: in function 'parseResponse' ``` ### `Anvil:CaptureError()` Reference ```lua Anvil:CaptureError(message, stacktrace?, context?) ``` | Parameter | Type | Description | |-----------|------|-------------| | `message` | string | The error message | | `stacktrace` | string or nil | Stack trace (auto-captured if nil) | | `context` | table or nil | Additional context | #### Context Fields | Field | Purpose | |-------|---------| | `eventName` | Groups errors in Anvil | | `args` | Key-value pairs shown with the error | ### Quick Reference **Timers:** ```lua -- Just swap C4:SetTimer for Anvil:SetTimer Anvil:SetTimer(5000, function(timer) -- errors captured automatically end) ``` **URL callbacks:** ```lua C4:url():OnDone(function(...) local ok, err = xpcall(function() -- your code end, function(e) Anvil:CaptureError(e) return e end) end):Get(url) ``` **Manual errors:** ```lua Anvil:CaptureError("Something went wrong", nil, { eventName = "CustomOperation", args = { detail = "value" } }) ``` --- ## API Reference Complete reference for the Driverforge SDK. --- ### `Driverforge:Init()` Initialize the SDK. Call this in `OnDriverInit` before anything else. ```lua Driverforge:Init(token, opts?) ``` #### Parameters | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `token` | string | Yes | Your project's [project token](/platform/project-tokens) (`drv_…`) | | `opts` | table | No | Configuration options | The driver's filename is not a parameter. The SDK reads it from `C4:GetDriverFileName()` itself, so the name it reports always matches the file actually running. #### Options | Option | Type | Default | Description | |--------|------|---------|-------------| | `logger` | table | — | Your existing logger instance (see [Automatic Logs](/sdk/log-forwarding)) | | `logMap` | table | — | Maps canonical levels to your logger's method names | ##### `logMap` For each canonical level (`fatal`, `error`, `warn`, `info`, `debug`, `trace`), Anvil probes your logger for a method matching common case variants in this order: lowercase → PascalCase → UPPERCASE. The first match is wrapped. So a logger with `info`/`Info`/`INFO` style methods works without any `logMap`. `logMap` is only needed when a method has a **genuinely renamed** counterpart: typically when the canonical level word doesn't appear in the method name at all. For example, a logger that uses `Alert` for the fatal level: ```lua Driverforge:Init("YOUR_API_KEY", { logger = Log, logMap = { fatal = "Alert", -- only the semantic mismatch needs an entry } }) ``` The keys are Anvil's canonical levels (always lowercase), the values are the method names on your logger. Only include levels where the method name doesn't match any case variant of the canonical word. #### Example ```lua function OnDriverInit(strDIR) require('vendor.driverforge-sdk') Driverforge:Init("YOUR_API_KEY") end ``` --- ### `Anvil:SetTimer()` Create a timer with automatic error capture. Drop-in replacement for `C4:SetTimer`. ```lua Anvil:SetTimer(duration, callback, ...) ``` #### Parameters | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `duration` | number | Yes | Milliseconds until callback fires | | `callback` | function | Yes | Function to call | | `...` | any | No | Additional args for `C4:SetTimer` | #### Returns The timer object from `C4:SetTimer`. #### Example ```lua -- One-shot timer Anvil:SetTimer(5000, function(timer) RefreshStatus() end) -- Recurring timer Anvil:SetTimer(30000, function(timer) PollDevice() timer:Start() end) ``` --- ### `Anvil:CaptureError()` Manually capture an error. Use this for URL callbacks and other async contexts. ```lua Anvil:CaptureError(message, stacktrace?, context?) ``` #### Parameters | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `message` | string | Yes | The error message | | `stacktrace` | string/nil | No | Stack trace (auto-captured if nil) | | `context` | table/nil | No | Additional context | #### Context Fields | Field | Type | Description | |-------|------|-------------| | `eventName` | string | Name shown in Anvil, used for grouping | | `args` | table | Key-value pairs displayed with the error | #### Examples ```lua -- Basic Anvil:CaptureError("Connection failed") -- With context Anvil:CaptureError("Parse error", nil, { eventName = "API_Response", args = { endpoint = "/devices", statusCode = 200 } }) -- In a URL callback C4:url():OnDone(function(transfer, responses, errCode, errMsg) local ok, err = xpcall(function() ProcessResponse(responses) end, function(e) Anvil:CaptureError(e, nil, { eventName = "HTTP_Callback", args = { url = requestUrl } }) return e end) end):Get(requestUrl) ``` --- ### `Anvil:OnDriverInit()` Wrap your `OnDriverInit` code. Ensures the SDK is fully ready before your code runs. ```lua Anvil:OnDriverInit(callback, ...) ``` #### Parameters | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `callback` | function | Yes | Your init function | | `...` | any | No | Arguments to pass to callback | #### Example ```lua function OnDriverInit(strDIR) require('vendor.driverforge-sdk') Driverforge:Init("YOUR_API_KEY") Anvil:OnDriverInit(function(strDIR) -- Your init code here C4:UpdateProperty("Version", C4:GetDriverConfigInfo("version")) InitializeDevice() end, strDIR) end ``` --- ### `Anvil:ForwardLog()` Manually forward a log message to Anvil. Not needed if you're using the `logger` option in `Driverforge:Init()`; see [Automatic Logs](/sdk/log-forwarding). ```lua Anvil:ForwardLog(level, ...) ``` #### Parameters | Parameter | Type | Required | Description | |-----------|------|----------|-------------| | `level` | string | Yes | "DEBUG", "INFO", "WARN", "ERROR", "TRACE" | | `...` | any | Yes | The same arguments as a log call. Tables and other non-string values are sent as structured data; see [Tables and Other Values](/sdk/log-forwarding#tables-and-other-values) | #### Example ```lua Anvil:ForwardLog("INFO", "Device connected") Anvil:ForwardLog("DEBUG", "Received response:", response) ``` --- --- ## Agent Verification When a driver instrumented with the Driverforge SDK sends telemetry, that data should reach the genuine Anvil agent on the controller, and nothing else. This page explains the mechanism that guarantees it, in enough detail that you can audit the claim rather than take our word for it. > **Info: Security by default** > > > Transparency, trust, and security by default are foundations of how Driverforge is built, baked in early rather than retrofitted when something demands them. Publishing mechanisms like this one, in full detail and with the code open to inspection, is how we'd rather earn your confidence: with a record you can verify, not assurances. > ### In short - **The agent proves its identity before any telemetry is sent.** The SDK challenges the device it discovered; only the real agent can answer. - **The proof relies on a private key that never leaves the controller.** It is generated on the device, is never transmitted, and is not present in any download. - **Verification happens entirely offline.** The SDK makes no network call to check a proof; it verifies against a public key built into the SDK itself. - **If verification fails, telemetry is withheld.** There is no "trust anyway" fallback. Silence is the safe answer. ### Why this exists The SDK finds the agent by looking for a device with the agent's driver filename. On a controller where the genuine agent is installed, that's unambiguous: Control4 treats the agent as a singleton, so only one can exist. The gap is a controller where **no** agent is installed: nothing stops another driver from adopting the agent's filename and presenting itself as the agent. Without verification, an instrumented driver would then hand that impostor its telemetry, including captured handler arguments and, on errors, local variable values. That's the exposure this mechanism closes. (Note that the project token a driver carries is _designed_ to be publishable: it is not a secret, and it is not what an impostor would be after. The telemetry stream is.) ### The two phases Verification rests on a one-time **setup** that happens when the agent registers with Anvil, and a **challenge** that runs every time a driver discovers the agent. ![Sequence diagram of the full agent-verification lifecycle: the agent generates its keypair and registers with Anvil, the cloud issues a signed attestation, and each driver's SDK then runs the challenge-response verification before releasing telemetry](/img/anvil-agent-verification-sequence.svg) #### Setup: the agent establishes its identity (once, at registration) 1. **The agent generates a keypair on the controller.** On first run it creates an RSA private key and a self-signed certificate. The private key is stored in the controller's protected storage and never leaves it: it is not bundled in the agent download, so every controller's key is unique to that controller. 2. **The agent registers with Anvil.** After the operator signs in, the agent authenticates to the Anvil cloud and registers the controller, sending the SHA-256 **fingerprint** of its certificate. The cloud records the binding: _this controller holds the key behind this fingerprint._ 3. **The cloud issues a signed attestation.** In response, Anvil returns a short-lived, signed statement (an **attestation**) that vouches for the binding: _"The controller with this identifier holds the certificate with this fingerprint."_ It is signed with Anvil's attestation key (held in a cloud key-management service) and is valid only for a bounded window and only for consumption by an Driverforge SDK. 4. **The agent keeps it fresh.** The agent re-registers on every boot, so the attestation it holds is always current. #### Verification: a driver confirms the agent (every discovery) 1. **The SDK issues a challenge.** When an instrumented driver discovers the agent, the SDK generates a fresh random number (a _nonce_) and sends it to the discovered device, along with the SDK's own device identifier. 2. **The agent answers with a proof.** The genuine agent replies with three things: its stored attestation, its certificate, and a **signature** made with its private key over a message that combines the challenge nonce, the controller's hardware identifier, the agent's device identifier, and the challenging SDK's device identifier. 3. **The SDK verifies the proof offline.** Using the Anvil attestation public key embedded in the SDK, and without contacting any server, the SDK checks, in order: - the attestation's signature is valid, it has not expired, and it was issued for this controller and for SDK consumption; - the certificate presented in the proof has the exact fingerprint the attestation vouches for; - the challenge signature is valid for that certificate's key, over the exact message expected. 4. **Only a complete pass releases telemetry.** If every check succeeds, the driver begins sending telemetry. If any check fails, or no valid proof arrives before a short deadline, telemetry is withheld and the driver reports the failure locally. It does not fall back to trusting the device. ### Why a fake agent can't just send the proof it wants The proof is only three values: an attestation, a certificate, and a signature. So why can't an impostor assemble a convincing set and send them? Walk through what an impostor would have to do: - **Use its own certificate.** Anyone can generate a keypair and a certificate and sign the challenge with it. But the SDK also demands an _attestation_ vouching for that certificate's fingerprint, and attestations are signed by Anvil's cloud key. The impostor has no attestation for its own certificate and cannot produce one. It fails the attestation check. - **Present the real agent's certificate instead.** A certificate is public, so an impostor can copy the genuine one, and it comes with a genuine attestation. But the challenge must be signed with _that certificate's private key_, and that key was generated on the real controller and has never left it. The impostor can show the certificate but cannot sign with it. It fails the signature check. - **Forge the attestation, or replay a real one.** Forging an attestation requires Anvil's signing key, which lives in a cloud key-management service and is never distributed. Replaying a whole proof captured from a genuine exchange fails too: that proof was signed over a one-time nonce the SDK will never issue again, and over the specific controller it was produced on. The trap is structural. **The attestation says "trust the key behind this fingerprint"; the signature is the only way to prove you actually hold that key.** An impostor can satisfy either requirement on its own (its own certificate with a signature it's able to make, or the real certificate with a real attestation), but never both at once, because doing so requires the one private key that never leaves the genuine controller. There is no set of three values a fake agent can send that passes all the checks, short of possessing that key. ### What each check defends against Beyond that core trap, each individual element of the proof closes a specific variant of attack. Removing any one of them would open a gap. | Element of the proof | What it prevents | | ---------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Random nonce, freshly generated per challenge | **Replay**: a proof captured from an earlier exchange cannot be reused, because it was signed over a nonce the SDK will never issue again. | | Controller hardware identifier bound into the signed message _and_ the attestation | **Relay / machine-in-the-middle**: a valid proof from a genuine agent on a _different_ controller cannot be forwarded here, because it is bound to that other controller's identifier. | | Certificate fingerprint must match the attestation | **A forged or borrowed certificate**: an impostor can present any certificate, but only the one whose fingerprint Anvil attested will match, and producing a matching one requires Anvil's signing key. | | Signature made with the certificate's private key | **Possession, not just presentation**: proving identity requires _using_ the private key, not merely showing a public certificate that anyone could copy. | | Bounded attestation lifetime | **A stale or compromised key**: even in the worst case, an attestation is only useful for a short window before it must be reissued through a fresh, authenticated registration. | | Offline verification against an embedded key | **A phone-home dependency**: the SDK reveals nothing and depends on nothing at verification time; the check works on an isolated network and cannot be defeated by blocking a server. | --- ## Log Forwarding The Driverforge SDK can forward your driver's log messages to Anvil in real time, so they appear on the [Logs](/platform/logs) page alongside your events and errors. No changes to your existing logging code required. ### Automatic Forwarding (Recommended) Pass your logger to `Driverforge:Init()` and all log calls are automatically intercepted and forwarded: ```lua Driverforge:Init("YOUR_API_KEY", { logger = myLogger }) ``` That's it. Calls to `myLogger:info()`, `myLogger:error()`, etc. now appear in Anvil automatically. Your logger continues to work exactly as before: same methods, same output. Every call is forwarded regardless of the log level set in Composer, so the [Logs](/platform/logs) page always has the full picture even when the controller's own output is filtered. #### Custom Method Names For each canonical level (`fatal`, `error`, `warn`, `info`, `debug`, `trace`), Anvil probes your logger for a method matching common case variants in this order: lowercase → PascalCase → UPPERCASE. The first match is wrapped automatically. In practice this means **most loggers work with no `logMap` at all**: - A Pino-style logger with `info`/`error`/etc., picked by the lowercase variant - Snap One's standard `c4_log`, with `Info`/`Error`/etc., picked by the PascalCase variant - A logger using `INFO`/`ERROR`: picked by the UPPERCASE variant `logMap` is only needed when a method has a **genuinely renamed** counterpart: typically when the canonical level word doesn't appear in the method name at all. For example, a logger that uses `Alert` for the fatal level: ```lua Driverforge:Init("YOUR_API_KEY", { logger = Log, logMap = { fatal = "Alert", -- only the semantic mismatch needs an entry } }) ``` The keys are Anvil's canonical levels (always lowercase), the values are the method names on your logger. Only include levels where the method name doesn't match any case variant of the canonical word. See the [API Reference](/sdk/api-reference#logmap) for full details. ### Tables and Other Values Pass tables straight to a log call; there's no need to encode them first. When any argument isn't a string, Anvil receives the arguments themselves as structured data, and the log's detail view shows them as a JSON tree: ```lua Log:Debug("Response received:", { status = 200, body = "OK" }) ``` The message still reads as text, so search keeps working. Numbers and booleans appear in it as themselves, and anything else by its type: ```text Response received: [table] ``` A table whose keys run 1 to n arrives as an array; any other table arrives as an object with string keys. Values JSON can't hold are sent as placeholders: `"[nil]"`, `"[function]"`, `"[userdata]"`, `"[thread]"`, `"[cycle]"` for a table that refers back to itself, and `"nan"`, `"inf"` or `"-inf"` for numbers that aren't finite. To keep logging cheap on the controller, each log call's arguments are capped: | Limit | Cap | |-------|-----| | Nesting | 6 levels | | Entries per table | 100 | | Bytes per string | 2 KiB, ending in `…` | | Values per call | 1000 | | Size per call | about 16 KiB | Anything a cap cuts is replaced with `"[truncated]"` (as the last array element, or a `"[truncated]": true` key in an object), and the detail view says the arguments were cut. ### Manual Forwarding If you don't have a logging library, or prefer to control exactly which messages are forwarded, use `Anvil:ForwardLog()` directly. It takes a level and then the same arguments as a log call: ```lua Anvil:ForwardLog("INFO", "Device connected successfully") Anvil:ForwardLog("DEBUG", "Received response:", response) Anvil:ForwardLog("WARN", "Retrying connection...") ``` ### Anvil and the Composer Log Level Every log line carries the level your code gave it; the level is an attribute of the line itself. What differs between the controller and Anvil is what gets filtered out, and when. The log level you set in Composer controls local output: lines below it are never written to the controller's log files. That filter exists to protect the controller's limited storage from verbose output, which is also why drivers conventionally revert it to a quiet level on a timer. Anvil doesn't apply it. The SDK forwards every line your logger emits, whatever the Composer level happens to be, and you narrow things down afterwards with the level filters on the [Logs](/platform/logs) page. This is why Anvil can show DEBUG lines while Composer is set to INFO. The Composer level decides what lands in the controller's log files; it has no effect on what streams to Anvil. On controllers without the Anvil Agent, the SDK captures and retains no logs at all (see [Agent Discovery](/sdk/automatic-capture#agent-discovery)). ### Log Levels | Level | Purpose | |-------|---------| | `FATAL` | Critical failures | | `ERROR` | Error conditions | | `WARN` | Warning conditions | | `INFO` | General informational messages | | `DEBUG` | Debug messages for development | | `TRACE` | Detailed diagnostic information | --- ## Overview (Sdk) The Driverforge SDK is a Lua library that instruments your Control4 driver. It captures every event the system sends to your handlers and streams them to Anvil. ### Open Source The SDK is open source under the MIT license, and the code lives at [github.com/driverforge/control4-sdk](https://github.com/driverforge/control4-sdk). Everything you vendor into your driver is plain, readable Lua. You can audit every line before it ships under your name, verify the [capture behaviour](/sdk/automatic-capture) matches what these docs claim and diff releases before upgrading. The SDK is exactly the kind of code that deserves this scrutiny. It sits inside your driver, wraps your handlers, and forwards telemetry, and you shouldn't have to take our word for what code with that much access does. There is no opaque blob in your `vendor/` directory, and there never will be. If you find something odd, or want to make the SDK better, [issues](https://github.com/driverforge/control4-sdk/issues) and [pull requests](https://github.com/driverforge/control4-sdk/pulls) are welcome. ### What It Does When you add the SDK to your driver: 1. **Every event is captured** - See what Control4 actually passes to your handlers 2. **Errors are caught** - Get full stack traces instead of silent failures 3. **Timing is recorded** - Know how long each handler takes to execute ### The two globals Loading the SDK gives you two globals, split by what they do. `Driverforge` is how you turn the SDK on, and `Init` is all it carries: ```lua require('vendor.driverforge-sdk') Driverforge:Init("YOUR_API_KEY") ``` `Anvil` is the instrumentation surface, everything you call while your driver runs: | Method | Purpose | | ------------------------- | ------------------------------------------- | | `Driverforge:Init()` | Initialize the SDK | | `Anvil:OnDriverInit()` | Wrap your `OnDriverInit` body so it captures | | `Anvil:SetTimer()` | Create a timer with error capture | | `Anvil:CaptureError()` | Manually report an error | | `Anvil:ForwardLog()` | Forward a log line | | `Anvil:TelemetryStatus()` | What the SDK is currently doing | ### Automatic vs Manual Capture #### Automatic The SDK automatically instruments all standard C4 event handlers. You don't need to change your code - just add the SDK and your existing handlers are captured: ```lua -- This just works - events stream to Anvil function OnPropertyChanged(sProperty) local value = Properties[sProperty] ProcessProperty(sProperty, value) end ``` See [Automatic Capture](/sdk/automatic-capture) for the full list of 100+ instrumented handlers. #### Manual Some contexts can't be automatically instrumented because `C4` is a protected userdata object. Timer callbacks and URL responses need explicit wrapping: ```lua -- Use Anvil:SetTimer instead of C4:SetTimer Anvil:SetTimer(5000, function(timer) -- Errors here are captured end) ``` See [Manual Capture](/sdk/manual-capture) for details. ### What Gets Streamed Each event includes: | Field | Description | | ------------------ | ---------------------------------------------------------------------- | | **Event name** | Which handler was called (`OnPropertyChanged`, `ExecuteCommand`, etc.) | | **Arguments** | The exact data Control4 passed to your handler | | **Duration** | How long your handler took to execute | | **Error** | Stack trace if something threw | | **Timestamp** | When the event occurred | | **Driver version** | From your `driver.xml` `` | ### Next Steps - See the [full list of auto-captured handlers](/sdk/automatic-capture) - Learn to [capture timer and URL errors](/sdk/manual-capture) - Check the [API reference](/sdk/api-reference) --- ## Automatic Capture The Driverforge SDK automatically instruments all standard Control4 event handlers. Every time Control4 calls one of these functions, you'll see it in Anvil with the exact arguments that were passed. ### How It Works When you load the SDK, it registers wrappers for each C4 event handler: ```lua -- Your code stays the same function OnPropertyChanged(sProperty) -- Do stuff end -- But now every call is captured with: -- - The sProperty value -- - How long your code took -- - Any errors that occurred ``` You don't need to modify your handler implementations at all. #### Agent Discovery Capture is only active when the [Anvil Agent](/agent/overview) is present on the controller. The SDK checks for it once Control4 has established bindings (in `OnDriverLateInit`): - **Agent found.** Anything captured during startup is delivered, and live streaming begins. - **No agent.** Startup capture is discarded and the SDK goes inert. Handler calls pass straight through to your code with no capture, no queuing, and no network activity, which is what makes it safe to [ship the same build everywhere](/sdk/installation#shipping-your-driver). Events that fire before discovery completes are buffered in memory, capped at 500 (oldest dropped first). If the agent is installed after your driver loads, the SDK detects it and starts capturing from that moment on. ### What You See For each event, Anvil shows: **The handler name:** ``` OnPropertyChanged ``` **The arguments Control4 passed**, matched to your parameter names where Lua's introspection allows (positional otherwise): ``` sProperty: "Volume" ``` **The return values** from your handler, including multiple returns. **Timing:** ``` Duration: 3ms ``` **And if something broke, the full error:** ``` ERROR: attempt to index nil value driver.lua:142: in function ``` Error stack traces include the value of every local variable in every frame at the moment of the error, so you can see exactly what your code was working with when it failed. Long values are bounded: strings truncate at 512 characters, and tables are capped in depth and size. #### Sensitive Data The SDK doesn't scan for or redact sensitive-looking values, so what your handler receives is what appears in Anvil. The exception is `GetPrivateKeyPassword`: the SDK records that the handler fired, but replaces its arguments with `[REDACTED]` and withholds its return value. The same goes for log messages you forward. If your driver handles access codes, credentials or personal information, that data can reach Anvil. Anvil is built for development, so in practice that should be test data on your development controller rather than real customer data. ### Captured Handlers The SDK instruments **157 handlers** across all Control4 event categories. Here's the complete list: #### Command & Action Handlers | Handler | When It Fires | |---------|---------------| | `ExecuteCommand` | Command sent to your driver | | `ExecuteAction` | Action triggered | #### Data & Communication Handlers | Handler | When It Fires | |---------|---------------| | `OnDataFromUI` | Data received from UI | | `OnDataToUI` | Data being sent to UI | | `GetPrivateKeyPassword` | Private key password requested | | `UIRequest` | UI request from navigator | | `ReceivedAsync` | Async response received | | `ReceivedFromProxy` | Data from a proxy binding | #### Driver Lifecycle Handlers | Handler | When It Fires | |---------|---------------| | `OnDriverInit` | Driver is initializing | | `OnDriverLateInit` | After bindings are established | | `OnDriverUpdate` | Driver is being updated | | `OnDriverDestroyed` | Driver is being unloaded | | `OnDriverAdded` | New driver added to project | | `OnDriverDisabled` | Driver was disabled | | `OnAlive` | Periodic health check | #### Connection & Network Handlers | Handler | When It Fires | |---------|---------------| | `OnConnectionStatusChanged` | Connection state changed | | `OnServerConnectionStatusChanged` | Server connection changed | | `OnNetworkBindingChanged` | Network binding changed | | `OnConnectionAuthorized` | Connection authorized | | `ReceivedFromNetwork` | Network data received | | `ReceivedFromSerial` | Serial data received | | `OnAuthorizedConnectionDisconnected` | Authorized connection lost | | `OnNetworkBindingStatusChanged` | Network binding status changed | #### Device Handlers | Handler | When It Fires | |---------|---------------| | `OnDeviceEvent` | Device-specific event | | `OnDeviceOnline` | Device came online | | `OnDeviceOffline` | Device went offline | | `OnDeviceDiscovered` | Device discovered | | `OnDeviceIdentified` | Device identified | | `OnDeviceIdentifying` | Device identification in progress | | `OnDevicePreIdentify` | Before device identification | | `OnDeviceIPAddressChanged` | Device IP changed | | `OnDeviceFirmwareChanged` | Device firmware updated | | `OnDeviceDataChanged` | Device data modified | | `OnDeviceUserInitiatedRemove` | User initiated device removal | | `OnDeviceAlreadyIdentified` | Device was already identified | | `OnDeviceCancelIdentify` | Device identification cancelled | | `OnDeviceIdentifiedNoLicense` | Device identified but no license | | `OnPhysicalDeviceAdded` | Physical device added | | `OnPhysicalDeviceRemoved` | Physical device removed | | `OnDiscoveredDeviceAdded` | Discovered device added | | `OnDiscoveredDeviceChanged` | Discovered device changed | | `OnDiscoveredDeviceRemoved` | Discovered device removed | | `OnSearchTypeFound` | Search type found | #### Event & Timer Handlers | Handler | When It Fires | |---------|---------------| | `OnEventFired` | Event fired | | `OnTimerExpired` | Legacy timer fired | | `OnScheduledEvent` | Scheduled event triggered | | `OnSystemEvent` | System-wide event | | `OnEventAdded` | Event added | | `OnEventRemoved` | Event removed | | `OnEventModified` | Event modified | | `OnWatchedVariableChanged` | Watched variable changed | | `OnAll` | Catch-all handler | #### Property & Variable Handlers | Handler | When It Fires | |---------|---------------| | `OnPropertyChanged` | Property value changed | | `OnProjectPropertyChanged` | Project property changed | | `OnVariableChanged` | Variable value changed | | `OnVariableAdded` | Variable created | | `OnVariableRemoved` | Variable deleted | | `OnVariableRenamed` | Variable renamed | | `OnUserVariableAdded` | User variable added | | `OnItemDataChanged` | Item data changed | | `OnAccessModeChanged` | Access mode changed | | `OnTimeChanged` | System time changed | | `OnLatitudeChanged` | Latitude changed | | `OnLongitudeChanged` | Longitude changed | #### Binding Handlers | Handler | When It Fires | |---------|---------------| | `OnBindingChanged` | Binding connection changed | | `OnBindingAdded` | New binding created | | `OnBindingRemoved` | Binding removed | | `OnBindingEntryAdded` | Binding entry added | | `OnBindingEntryRemoved` | Binding entry removed | | `OnBindingEntryRenamed` | Binding entry renamed | | `OnVariableBindingAdded` | Variable binding added | | `OnVariableBindingRemoved` | Variable binding removed | | `OnVariableBindingRenamed` | Variable binding renamed | | `OnVariableAddedToBinding` | Variable added to binding | | `OnVariableRemovedFromBinding` | Variable removed from binding | | `OnNetworkBindingAdded` | Network binding added | | `OnNetworkBindingRemoved` | Network binding removed | #### Network Binding Handlers | Handler | When It Fires | |---------|---------------| | `OnNetworkBindingRegistered` | Network binding registered | | `OnNetworkBindingUnregistered` | Network binding unregistered | | `OnNetworkBindingAddressChanged` | Network binding address changed | | `OnCIDRRulesChanged` | CIDR rules changed | | `OnDirectorIPAddressChanged` | Director IP changed | #### Project Handlers | Handler | When It Fires | |---------|---------------| | `OnProjectLoaded` | Project loaded | | `OnProjectLoading` | Project loading | | `OnProjectNew` | New project created | | `OnProjectChanged` | Project changed | | `OnProjectLocked` | Project locked | | `OnProjectEnterLock` | Entering project lock | | `OnProjectLeaveLock` | Leaving project lock | | `OnProjectClear` | Project cleared | | `OnLocaleChanged` | Locale changed | #### Server Handlers | Handler | When It Fires | |---------|---------------| | `OnServerStatusChanged` | Server status changed | | `OnServerDataIn` | Server data received | | `OnSDDPDeviceStatus` | SDDP device status update | #### Media Session Handlers | Handler | When It Fires | |---------|---------------| | `OnMediaSessionAdded` | Media session added | | `OnMediaSessionRemoved` | Media session removed | | `OnMediaSessionChanged` | Media session changed | | `OnMediaSessionVolumeLevelChanged` | Volume level changed | | `OnMediaSessionVolumeSliderStateChanged` | Volume slider state changed | | `OnMediaSessionMuteStateChanged` | Mute state changed | | `OnMediaSessionDiscreteMuteChanged` | Discrete mute changed | | `OnMediaSessionDiscreteVolumeChanged` | Discrete volume changed | | `OnMediaSessionSliderTargetVolumeReached` | Slider target volume reached | #### Media Device Handlers | Handler | When It Fires | |---------|---------------| | `OnMediaDeviceAdded` | Media device added | | `OnMediaDeviceRemoved` | Media device removed | | `OnMediaDeviceChanged` | Media device changed | | `OnMediaInfoAdded` | Media info added | | `OnMediaInfoModified` | Media info modified | | `OnMediaRemovedFromDevice` | Media removed from device | #### Media & Playlist Handlers | Handler | When It Fires | |---------|---------------| | `OnSongAddedToPlaylist` | Song added to playlist | | `OnSongRemovedFromPlaylist` | Song removed from playlist | | `OnMediaDataRemoved` | Media data removed | | `OnMediaSessionMediaInfoChanged` | Session media info changed | #### Item Handlers | Handler | When It Fires | |---------|---------------| | `OnItemAdded` | Item added | | `OnItemMoved` | Item moved | | `OnItemNameChanged` | Item name changed | | `OnItemRemoved` | Item removed | #### Code Item Handlers | Handler | When It Fires | |---------|---------------| | `OnCodeItemAdded` | Code item added | | `OnCodeItemRemoved` | Code item removed | | `OnCodeItemMoved` | Code item moved | | `OnCodeItemEnabled` | Code item enabled | | `OnCodeItemCommandUpdated` | Code item command updated | | `OnCodeItemAddedToExpression` | Code item added to expression | #### Zigbee Handlers | Handler | When It Fires | |---------|---------------| | `OnZigbeeNodeOffline` | Zigbee node went offline | | `OnZigbeeNodeOnline` | Zigbee node came online | | `OnZigbeeNodesChanged` | Zigbee nodes changed | | `OnZigbeeMeshChanged` | Zigbee mesh changed | | `OnZigbeeDuplicateMesh` | Duplicate Zigbee mesh detected | | `OnZigbeeNetworkHealth` | Zigbee network health update | | `OnZigbeeNodeUpdateStatus` | Node update status | | `OnZigbeeNodeUpdateSucceeded` | Node update succeeded | | `OnZigbeeNodeUpdateFailed` | Node update failed | | `OnZigbeeZserverChanged` | Zserver changed | | `OnZigbeeZapsChanged` | Zaps changed | | `OnZigBeeStickPresent` | Zigbee stick present | | `OnZigBeeStickRemoved` | Zigbee stick removed | #### System Update & Discovery Handlers | Handler | When It Fires | |---------|---------------| | `OnSystemUpdateStarted` | System update started | | `OnSystemUpdateFinished` | System update finished | | `OnSystemShutDown` | System shutting down | | `OnSDDPDeviceDiscover` | SDDP device discovered | | `OnSysmanResponse` | Sysman response received | | `OnReflashLockGranted` | Reflash lock granted | | `OnReflashLockRevoked` | Reflash lock revoked | | `OnControllerDisabled` | Controller disabled | #### Notification Handlers | Handler | When It Fires | |---------|---------------| | `GetNotificationAttachmentURL` | Get notification attachment URL | | `GetNotificationAttachmentFile` | Get notification attachment file | | `GetNotificationAttachmentBytes` | Get notification attachment bytes | | `FinishedWithNotificationAttachment` | Notification attachment finished | #### List Handlers | Handler | When It Fires | |---------|---------------| | `ListMIBReceived` | MIB list received | | `ListNewControl` | New control list | | `ListEvent` | List event | | `ListNewList` | New list created | #### Other Handlers | Handler | When It Fires | |---------|---------------| | `OnZipcodeChanged` | Zipcode changed | | `OnPIP` | PIP event | | `OnTimezoneChanged` | Timezone changed | ### What's NOT Captured Due to Lua limitations with protected userdata, these require [manual capture](/sdk/manual-capture): - `C4:SetTimer()` callbacks - `C4:url():OnDone()` callbacks - Other async callbacks passed to C4 methods The SDK can't wrap these automatically, but provides simple APIs to capture them. --- ## Installation (Agent) Install and authenticate the Anvil Agent on your development controller. ### Download ### Install the Driver 1. Open **Composer Pro** 2. Connect to your development controller 3. Select **Driver** > **Add or Update Driver or Agent** from the menu bar 4. Browse to `anvil-agent.c4z` and add it ### Add the Agent 1. Select the **Agents** view 2. Click **Add...** 3. Search for "Anvil" and double-click the agent from the list, or right click and select **Add to Project** ### Authenticate 1. Select **Anvil Agent** from the list of installed Agents 2. Navigate to the **Actions** tab 3. Click **Get authentication link** 4. Return to the **Properties** tab 5. Click the **Authentication URL** property 6. A web browser opens 7. Log in with your Driverforge account if required 8. Approve the request to connect Anvil to your Driverforge account 9. Close the browser and return to Composer The Anvil Agent is now ready. Any driver that includes the Driverforge SDK will discover the agent and stream events to the Anvil Platform. ### Verify After authentication, open the agent's Properties tab. The **Authentication status** property should show: `Logged in as you@youremail.com` ### Updating Run [`driverforge upgrade`](/cli/upgrade) and select the **Anvil Agent** row. The CLI downloads the new build, verifies its checksum, deploys it to the controller, and confirms the agent came back up. The agent reconnects automatically after updating. An agent too old to report its installed filename can't self-upgrade. Update it once manually in Composer Pro; after that `driverforge upgrade` can take over: 1. Download the new `anvil-agent.c4z` 2. Right-click the agent in Composer 3. Select **Update Driver** ### Removing To remove the agent: 1. Right-click the Anvil Agent 2. Select **Remove** Your drivers continue working normally - they just won't stream events until you reinstall the agent. --- ## Configuration The agent works out of the box with sensible defaults. These settings are available for troubleshooting. ### Properties View agent properties in Composer Pro by selecting the agent and opening the **Properties** tab. #### Status (Read-Only) | Property | Description | |----------|-------------| | **Agent Version** | Current version of the installed agent | | **Authentication status** | Login state (e.g., "Not logged in", "Logged in") | #### Authentication | Property | Description | |----------|-------------| | **Authentication URL** | Click to open the browser and authenticate with your DriverForge account | #### Logging | Property | Default | Description | |----------|---------|-------------| | **Log Mode** | Log | Where to output logs | | **Log Level** | 2 - Warning | Verbosity of log output | ##### Log Mode Options | Option | Description | |--------|-------------| | Off | No logging | | Print | Output to Lua Output window | | Log | Write to controller logs | | Print and Log | Both | ##### Log Level Options | Level | Description | |-------|-------------| | 0 - Fatal | Critical errors only | | 1 - Error | Errors | | 2 - Warning | Warnings and above (default) | | 3 - Info | Informational messages | | 4 - Debug | Detailed debug output | | 5 - Trace | Maximum verbosity | ### Troubleshooting with Logs To diagnose issues: 1. Select the Anvil Agent 2. Set **Log Mode** to "Print and Log" 3. Set **Log Level** to "4 - Debug" or "5 - Trace" 4. Check **Lua Output** in Composer You'll see: - Events received from drivers - Connection status changes - Any errors encountered > **Tip** > > If you set the log level to Debug or Trace, it will automatically revert to the previous setting after 30 minutes. This prevents accidentally leaving verbose logging enabled, which generates a lot of output. ### Multiple Controllers If you have multiple controllers in your dev setup: - Install and authenticate the agent on each controller - Each agent streams independently - All events appear in the same project in Anvil --- ## Deploy Server The deploy server is the part of the agent that receives drivers from the [Driverforge CLI](/cli/overview). When you run `driverforge deploy` or `driverforge sync`, the CLI connects to it directly over your local network, and the agent installs the driver and reloads it on the controller. It's on by default and needs no setup beyond signing the agent in. ### Requirements - The agent is [signed in](/agent/installation#authenticate) with the **same Driverforge account** you use for `driverforge login`. The deploy server only accepts drivers from the account the agent is signed in with. - The agent has connected to Driverforge at least once since it was signed in. That's when the controller is issued the certificate the deploy server uses for its secure connection. - Your computer can reach the controller on the deploy server port: | Direction | Port | Protocol | | -------------------------- | ---- | -------- | | Your computer → controller | 9443 | HTTPS | ### Properties The deploy server settings are under **Deploy Server Settings** on the agent's **Properties** tab in Composer Pro. | Property | Default | Description | | ------------------------- | ------- | ------------------------------------------------------------------------- | | **Documentation** | | Opens this page | | **Deploy Server Enabled** | On | Set to Off to stop the deploy server. The rest of the agent keeps running | | **Deploy Server Port** | 9443 | The port the deploy server listens on | Changing either property restarts the deploy server straight away. #### Using a different port If another driver on the controller already uses port 9443, set **Deploy Server Port** to a free port, then tell the CLI to use it: ```bash export DRIVERFORGE_AGENT_PORT=9444 driverforge deploy ``` ### Actions | Action | Description | | ------------------------- | ------------------------------------------------------------------------------- | | **Restart Deploy Server** | Stops and starts the deploy server again, picking up a newly issued certificate | Find it on the agent's **Actions** tab in Composer Pro. ### Security Installing a driver runs code on the controller, so the deploy server is locked down: - **Encrypted.** Connections use TLS with a certificate issued to that controller. The CLI checks the certificate, so it can't be sent to anything pretending to be your controller. - **Signed in.** Every request carries your Driverforge sign-in, and the agent checks it belongs to the account the agent is signed in with. Anyone else on the network is refused. - **Can be switched off.** On a development controller you don't deploy to from the CLI, set **Deploy Server Enabled** to Off. ### Troubleshooting To see what the deploy server is doing, turn on [debug logging](/agent/configuration#troubleshooting-with-logs) and look for lines starting `DeployServer:` in Lua Output. - **The CLI can't reach the agent**: check **Deploy Server Enabled** is On, that your computer and the controller are on networks that can reach each other on the deploy server port, and that `DRIVERFORGE_AGENT_PORT` matches **Deploy Server Port** if you changed it. - **Deploys are refused as not authorized**: the agent is signed in with a different account to the CLI, or isn't signed in. Check **Authentication status**, and sign in again if needed. - **`no certificate has been issued yet` in Lua Output**: the controller hasn't received its certificate yet. Check the agent is signed in and the controller can reach the internet, then run **Restart Deploy Server**. --- ## Overview (Agent) The Anvil Agent is a driver that runs on a Control4 controller and is used by the Driverforge SDK included with your drivers. It handles all the networking and authentication so your driver doesn't have to. ### Why Use an Agent? The agent keeps Anvil's footprint in your driver minimal: - **Fire and forget** - Your driver hands off events to the agent and moves on. No waiting for network responses. - **Handles authentication** - The agent manages your Anvil session. Your driver just needs a project ID. - **Handles delivery** - Retries, buffering, and connection management happen in the agent, not your driver. This design means adding Anvil to your driver has virtually no performance impact. ### Requirements - Control4 OS 3.3.1 or later - At least one driver with the Driverforge SDK - Outbound network access from the controller: | Host | Port | Protocol | |------|------|----------| | ingest.driverforge.com | 8883 | MQTTS (MQTT over TLS) | Most networks allow outbound connections by default. If you're behind a restrictive firewall, ensure this endpoint is permitted. ### Next Steps - [Install the agent](/agent/installation) - [Configure agent settings](/agent/configuration) --- ## Source maps Source maps let Anvil translate stack traces from a bundled Lua driver back to your original source files, so error reports point at real file names and line numbers instead of the squished output. ### Why source maps When a driver is bundled with squish, many source files collapse into a single `driver.lua`, so a runtime error like `driver.lua:1234: attempt to index a nil value` no longer points anywhere meaningful in your code. A source map records which bundled line came from which original file and line, so Anvil can show the true location in your [error reports](/platform/errors). ### Generating a source map Pass `--sourcemap` (or `-s`) to [`driverforge build`](/cli/build): ```bash driverforge build --sourcemap ``` This writes the map next to the bundled output as `dist/.lua.map`. It works for any squished driver; a driver that isn't squished has nothing to map, and the step is skipped. ```bash # A production build with a version bump and a source map driverforge build --configuration release -i --sourcemap ``` > **Info: Uploading to Anvil** > > Generating the map is built in today. Automatic upload to Anvil (so stack > traces are translated for you) isn't part of the CLI yet; reach out to > [support@driverforge.com](mailto:support@driverforge.com) if you need it for your > workflow. ### Prerequisites Source map generation reads your `squishy` file to find the module boundaries. This is the same file [`driverforge build`](/cli/build) uses to bundle the driver: ```lua Module "utils.logging" "src/utils/logging.lua" Module "utils.helpers" "src/utils/helpers.lua" Module "driver.init" "src/driver/init.lua" Main "src/main.lua" ``` ### Source map format The map is a JSON document mapping bundled line numbers to original source locations: ```json { "version": 1, "file": "driver.lua", "contentHash": "…", "generatedAt": "…", "sources": [ "src/utils/logging.lua", "src/utils/helpers.lua" ], "mappings": { "1234": { "source": 0, "line": 45 } } } ``` | Field | Description | |-------|-------------| | `version` | Source map format version | | `file` | Name of the bundled output file | | `contentHash` | Hash of the bundle the map was generated against | | `generatedAt` | When the map was generated | | `sources` | The original source files, in bundle order | | `mappings` | Bundled line number → `{ source index, original line }` | --- ## new Create a Control4 driver project from a template, then set it up for Driverforge. ### Usage ```bash driverforge new my-driver ``` `new` fetches a template, by default the official one from [`driverforge/control4-templates`](https://github.com/driverforge/control4-templates), and creates `./my-driver` from it with the driver's name filled in. It then runs [`init`](/cli/init) inside the new directory, which asks the same questions `driverforge init` does: which project to link or create, the [versioning scheme](/cli/versioning), [build configurations](/cli/build-configuration) and the logger to forward. `new` doesn't change your shell's directory. When it finishes: ```bash cd my-driver ``` For a walkthrough from an empty directory to telemetry in Anvil, see [Start a driver from a template](/platform/start-from-a-template). ### Prerequisites - You're [signed in](/cli/login) (`driverforge login`) with an [organization selected](/cli/org) (`driverforge org select`). Not needed with `--no-init`. - `git` installed, if `--repo` is a git URL. ### What it does 1. **Fetches the template.** Nothing is created until the template has downloaded and rendered cleanly. 2. **Creates the project directory**, replacing the template's [placeholders](/cli/templates#placeholders) with values derived from the name you gave: `driverforge new my-pool-pump` gives `${slug}` = `my-pool-pump`, `${id}` = `my_pool_pump` and `${title}` = `My Pool Pump`. 3. **Runs `init`**, which embeds the latest Driverforge SDK, wraps `OnDriverInit`, and links or creates the Anvil project. A new project has nothing to review against, so `init` applies its changes straight away, without the diff review or a git branch. 4. **Prints a link to the project in Anvil**, and in a terminal offers to open it. The page there picks up where `new` leaves off: deploying the driver and watching its first telemetry arrive. If `init` fails, for example because the project limit on your [plan](/platform/plans) is reached, the project directory stays. It's a complete driver; run `driverforge init` inside it to finish the setup. ### Choosing a template #### `--template` A template repository holds one directory per template. `--template` picks one: ```bash driverforge new acme-thermostat --repo acme/driver-templates --template thermostat ``` Without `--template`, `new` uses the repository root when it holds a `template.json` (a repository that is a single template), and otherwise the `driver` directory. #### `--repo` `--repo` points `new` at a different template repository. It takes: | Form | Example | | -------------------------------- | ---------------------------------------------- | | GitHub `owner/repo`, with `@ref` | `acme/driver-templates@v2` | | GitHub URL | `https://github.com/acme/driver-templates` | | Any git URL, with `#ref` | `https://gitlab.com/acme/templates.git#v2` | | | `ssh://git@git.acme.com/drivers/templates.git` | | | `git@bitbucket.org:acme/templates.git#main` | | | `git://git.acme.com/templates.git` | `@ref` and `#ref` name a branch or tag. Without one, `new` uses the repository's default branch. GitHub `owner/repo` and `https://github.com/...` forms are downloaded as an archive, so they must be public. Every other git URL is cloned with `git`, using your own git credentials, so it works for GitLab, Bitbucket, self-hosted servers and private repositories. `new` never prompts for git credentials: if the clone needs a password and no credential helper or SSH key supplies it, the clone fails. To write your own templates, see [Authoring templates](/cli/templates). ### Options | Option | Description | | -------------------- | ----------------------------------------------------------------------------------------------------- | | `--repo` | Repository holding the templates: `owner/repo[@ref]` on GitHub, or any git URL `[#ref]` | | `--template` | Template directory within the repository | | `--set key=value` | Set a variable the template declares. Repeatable | | `--no-init` | Create the project without setting it up for Driverforge | | `--project` | Link an existing Anvil project: `/`, or a project slug | | `--create-project` | Create an Anvil project with this name for the driver to report to | | `--org` | The organization to create the project in (default: the active one), or to qualify a `--project` slug | | `--platform` | The new project's platform, by id or name (default: the only supported one) | | `--description` | The new project's description | | `--versioning` | How deploys bump ``: `date` (`YYYYMMDDNN`) or `integer` | | `--build-configs` | Add the `config.lua` and `config.release.lua` build configurations | | `--no-build-configs` | Don't add build configurations | | `--logger` | Forward logs from this logger global, for example `Log` | | `--no-logger` | Don't forward the driver's logs | | `--sdk-dir` | Source-relative directory to install the Driverforge SDK in | The options from `--project` down are `init`'s, and mean the same thing as on [`driverforge init`](/cli/init#options). `--no-init` can't be combined with them. `--set` only accepts variables the template's `template.json` declares; any other name fails and lists the variables it does accept. A required variable you don't set is asked for in a terminal. `new` has no `--yes` or `--dry-run`: there's no existing project to review changes against. ### Without a terminal Under a coding agent, in CI, or with `--no-tui`, `new` can't ask, so every question needs its flag. Missing answers fail with `input_required` before anything is fetched or created, and `details.missing` names the flags still needed. Required template variables you didn't `--set` fail the same way, naming each one. ```bash driverforge new pool-pump --create-project "Pool Pump" --versioning date \ --no-build-configs --no-logger ``` In JSON output, the result lists the created files, `init`'s result, and `setup_url`: the Anvil link `new` prints at the end. ### Examples ```bash # The official template, answering init's questions as you go driverforge new my-driver # One of your own templates, from a private GitLab repository, at tag v2 driverforge new my-driver --repo https://gitlab.com/acme/templates.git#v2 # A template that declares a vendor variable driverforge new acme-thermostat --repo acme/driver-templates@v2 \ --template thermostat --set vendor=Acme # Just the project, no Driverforge setup driverforge new scratch --no-init ``` --- ## Installation (Cli) The Driverforge CLI (`driverforge`) is a single, dependency-free binary. Install it with your platform's package manager, or with the install script on Linux. ### macOS ```bash brew tap driverforge/tap brew install driverforge ``` Homebrew (6.0 and later) refuses to install from a third-party tap until you explicitly trust it; this is standard for all non-official taps, not specific to Driverforge. When brew asks, review the tap and trust it: ```bash brew trust driverforge/tap ``` then re-run `brew install driverforge`. Trusting records your one-time consent to install packages from our tap. What you're trusting is [`driverforge/homebrew-tap`](https://github.com/driverforge/homebrew-tap): it contains only the machine-generated cask, updated automatically on each release, and the binaries it installs are downloaded from `releases.driverforge.com`. ### Linux / WSL ```bash sh -c "$(curl -fsSL https://go.driverforge.com/get)" ``` The installer names the release it found and the directory it will write to, then asks before installing anything. It verifies the download against a signed release manifest and stops if the signature or the checksum does not match, so a failed check never leaves a partial install behind. It finishes by pointing you at [`driverforge login`](/cli/login) and [`driverforge init`](/cli/init). Note the shape of the command: `curl` runs inside `$(...)` so the whole script is downloaded before a single line of it executes, and stdin stays attached to your terminal so the installer's prompts have somewhere to read from. Piping into `sh` gives up both. Keep `-f` as well, or curl hands an HTTP error page to the shell to run. Two variables change what gets installed and where. Both go before the command: ```bash DRIVERFORGE_VERSION=0.5.1 sh -c "$(curl -fsSL https://go.driverforge.com/get)" DRIVERFORGE_INSTALL_DIR=$HOME/.local/bin sh -c "$(curl -fsSL https://go.driverforge.com/get)" ``` Without a terminal, in CI or under a script driving the install, the prompts are skipped and every default is taken. Set `DRIVERFORGE_NONINTERACTIVE=1` to force that even when a terminal is present. ### Windows ```bash scoop bucket add driverforge https://github.com/driverforge/scoop-bucket scoop install driverforge ``` ### Verify the install Check the install worked and see the version: ```bash driverforge version ``` ### Staying current The CLI is owned by the package manager that installed it, so upgrades happen the same way: `brew upgrade driverforge`, `scoop update driverforge`, or re-run the install script. See [Upgrading](/cli/upgrading) for how the CLI, the Anvil Agent, and the embedded SDK each stay up to date. --- ## build Bundle your Lua source and produce a `.c4z` driver package. Building is entirely local: no account or controller required. > **Tip: Fast by design** > > `driverforge` is a self-contained native binary. It runs the whole build in one > process (bundling, encryption, and packaging) instead of orchestrating the > chain of separate scripts and tools typically needed to package Control4 > drivers. Builds finish in a fraction of the time, and produce a standard `.c4z` > that Composer and your controllers install and run exactly like any other. ### Usage ```bash driverforge build [options] ``` Run it from a driver project: a directory with `src/manifest.c4zproj` (the CLI walks up from the current directory to find it, or point `--c4zproj` at a manifest elsewhere). The driver name comes from the manifest; `driver.xml` and the `squishy` build file live alongside it in `src/`. ### What it does 1. Reads `src/manifest.c4zproj` to determine the driver name and contents 2. Bundles the Lua modules described by your `squishy` file into a single `driver.lua` 3. Stamps `driver.xml` (modified time, plus the version when you ask for a bump) and, when configured, encrypts the driver script 4. Packages everything into a `.c4z` in `dist/` 5. Optionally emits a source map and/or an unpacked copy ### Options | Option | Description | | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `--configuration`, `-c` | Build a named configuration: swaps `src/config..lua` in as `config.lua` for this build. Omit to build the default `config.lua` as-is | | `--increment`, `-i` | Bump the version per the project's [versioning scheme](/cli/versioning) before building. Requires an [initialised](/cli/init) project | | `--version` | Stamp an exact `` for this build, persisted to `driver.xml` on success. Works without init; mutually exclusive with `--increment` | | `--c4zproj` | Path to the `.c4zproj` manifest (default `src/manifest.c4zproj`) | | `--output-dir`, `-o` | Directory for the built `.c4z` (default `dist/`) | | `--sourcemap`, `-s` | Also emit a Lua source map (`dist/.lua.map`) | | `--unpack`, `-u` | Also leave an unpacked copy of the package in `dist/` | | `--encrypt` | Force script encryption on for this build (`--encrypt=false` forces it off). Default follows the configuration's entry in the project config, then `driver.xml` | | `--no-suffix` | Build a named configuration under the naked driver name: no `-` artifact or `(name)` device-name suffix (`--no-suffix=false` forces suffixing back on) | | `--allow-execute` | Development build: append `C4:AllowExecute(true)` to the built driver script, enabling Director's Lua command window. Applied to the artifact only, never written to source | | `--warnings-as-errors` | Fail the build (before packaging) when any warning fires. Recommended for CI, where a warned build must not produce an artifact; see [Warnings](#warnings) | Shipping is its own command now: [`driverforge sync`](/cli/sync) and [`driverforge deploy`](/cli/deploy) each build first, so there is no `build --sync` or `build --deploy`. ### Warnings While bundling, the build checks every `require` in the files your squishy manifest names (the `Main` file plus every `Module`). A require whose target exists as a Lua file in your source tree but has no `Module` line in `src/squishy` produces a warning naming the module and the require that needs it: ``` ⚠ driver.lua:12 requires "lib.actions", but squishy has no Module entry for it — the module will not be bundled ``` Without that entry the module is left out of the packaged `driver.lua`, so the build succeeds and the driver dies at that require on the controller. The fix is the missing line in `src/squishy`: ``` Module "lib.actions" "lib/actions.lua" ``` Only requires that resolve to a file under `src/` are checked: `.lua` (dots in the module name act as path separators) or `/init.lua`. A require with no matching local file, such as `require('openssl')`, is assumed to come from the controller's runtime and never warns. Warnings are advisory by default: the build completes and packages the artifact. Pass `--warnings-as-errors` to fail the build before packaging when any warning fires. Use it in CI, where a warned build must not produce an artifact; the [GitHub Action](/cicd/github-actions#fail-on-warnings), [Buildkite plugin](/cicd/buildkite#fail-on-warnings) and [GitLab template](/cicd/gitlab) recipes show it wired in. ### Output A build writes to `dist/` (or the directory you pass with `-o/--output-dir`): ``` dist/ ├── my-driver.c4z # packaged driver ├── driver.lua.map # source map (with --sourcemap, when the driver is squished) └── my-driver/ # unpacked copy (with --unpack) ``` #### Build configurations `driverforge build` uses your committed `src/config.lua` as the driver's configuration. Pass `--configuration ` (or `-c `) to swap a committed `src/config..lua` override in for the build instead, for example `--configuration release`. It's an opt-in system; see [Build configuration](/cli/build-configuration) for the full picture. **Naming.** A plain build (the default configuration) keeps the driver's naked name (`my-driver.c4z`). A named configuration is suffixed so builds coexist: `driverforge build --configuration release` produces `my-driver-release.c4z` and adds a `(release)` suffix to the device name in Composer. A release configuration can opt out of the suffixes (`--no-suffix`, or `"suffix": false` in the project config) to ship under the naked name; see [Per-configuration defaults](/cli/build-configuration#per-configuration-defaults). **Per-configuration defaults.** An [initialised](/cli/init) project can set encryption and naming defaults per configuration in `.driverforge/config.json`, so `driverforge build -c release` alone produces the final release artifact. Flags always override the config. See [Per-configuration defaults](/cli/build-configuration#per-configuration-defaults). #### Versioning A plain build never touches the driver's ``: what's authored is what ships. Pass `--increment` to bump it per the project's versioning scheme, or `--version` to stamp an exact value. See [Versioning](/cli/versioning) for the schemes and the full picture of when versions change. #### What it prints **Interactive** ```text ┃ ✓ Build complete ┃ ┃ driver poolpump ┃ version 20261105.2 ┃ artifact dist/poolpump.c4z ``` **Structured** Progress is abbreviated here: each build step reports `running`, then `ok` or `skipped`. A build warning is reported as a `warning` progress line and listed again in the result's `warnings`. stdout: ```json { "driver": "poolpump", "configuration": "default", "version": "20261105.2", "artifact": "dist/poolpump.c4z", "encrypted": false, "unpacked": null, "sourcemap": null, "warnings": [] } ``` stderr: ```json {"progress": {"status": "running", "message": "Building (default)"}} {"progress": {"status": "running", "message": "Resolve project"}} {"progress": {"status": "ok", "message": "Resolve project (4ms)"}} {"progress": {"status": "running", "message": "Squish Lua"}} {"progress": {"status": "ok", "message": "Squish Lua (38ms)"}} {"progress": {"status": "running", "message": "Package .c4z"}} {"progress": {"status": "ok", "message": "Package .c4z (12ms)"}} {"progress": {"status": "ok", "message": "Build complete"}} ``` ### Examples Basic build: ```bash driverforge build ``` Release build (swaps in `config.release.lua`) with a version bump and a source map: ```bash driverforge build --configuration release -i -s ``` Full release artifact (encrypted, naked name) with no config file, using flags alone (or set these once per configuration in the [project config](/cli/build-configuration#per-configuration-defaults) and drop the flags): ```bash driverforge build -c release --encrypt --no-suffix ``` Build with the manifest and output directory somewhere non-standard: ```bash driverforge build --c4zproj packaging/manifest.c4zproj -o build/out ``` ### Source maps Build with `--sourcemap` to emit a `.map` alongside the package so Anvil can map error stack traces back to your original source files instead of the bundled output. See [`driverforge sourcemap`](/cli/source-maps) for the details. ```bash driverforge build --sourcemap ``` ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## Spaceship prompt Show your active Driverforge [context](/cli/context) (the selected organization and controller) right in your shell prompt, the way [Spaceship](https://spaceship-prompt.sh) shows the git branch or the Azure subscription: ``` ~/drivers/acme-thermostat on main 󰢛 acme/living-room ``` The section reads only the local context file (`driverforge org current` / `driverforge device current`; no network), renders asynchronously so it never blocks your prompt, and disappears entirely when no organization is selected. ### Install Save the snippet below as `~/.config/spaceship/driverforge.zsh`, then in your `~/.zshrc`, **after** Spaceship is initialised: ```bash source ~/.config/spaceship/driverforge.zsh ``` and add `driverforge` to your prompt order: ```bash SPACESHIP_PROMPT_ORDER=( dir git driverforge line_sep char ) ``` ### The section ```bash # Driverforge — active org/device section for the Spaceship prompt. # Configuration (override any of these in ~/.zshrc before sourcing). SPACESHIP_DRIVERFORGE_SHOW="${SPACESHIP_DRIVERFORGE_SHOW=true}" SPACESHIP_DRIVERFORGE_SHOW_DEVICE="${SPACESHIP_DRIVERFORGE_SHOW_DEVICE=true}" SPACESHIP_DRIVERFORGE_PREFIX="${SPACESHIP_DRIVERFORGE_PREFIX="using "}" SPACESHIP_DRIVERFORGE_SUFFIX="${SPACESHIP_DRIVERFORGE_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"}" SPACESHIP_DRIVERFORGE_SYMBOL=${SPACESHIP_DRIVERFORGE_SYMBOL=$'\U000F089B '} # nf-md-anvil (Nerd Font) SPACESHIP_DRIVERFORGE_DEVICE_SEPARATOR="${SPACESHIP_DRIVERFORGE_DEVICE_SEPARATOR="/"}" SPACESHIP_DRIVERFORGE_COLOR="${SPACESHIP_DRIVERFORGE_COLOR="#79C0FF"}" SPACESHIP_DRIVERFORGE_COMMAND="${SPACESHIP_DRIVERFORGE_COMMAND=driverforge}" # spaceship_driverforge renders the active driverforge org (and device, if # selected), or nothing. spaceship_driverforge() { [[ $SPACESHIP_DRIVERFORGE_SHOW == false ]] && return # Only render when the driverforge CLI is on PATH. spaceship::exists "$SPACESHIP_DRIVERFORGE_COMMAND" || return local org org=$($SPACESHIP_DRIVERFORGE_COMMAND org current 2>/dev/null) || return [[ -z $org ]] && return local label="$org" if [[ $SPACESHIP_DRIVERFORGE_SHOW_DEVICE != false ]]; then local device device=$($SPACESHIP_DRIVERFORGE_COMMAND device current 2>/dev/null) [[ -n $device ]] && label="${org}${SPACESHIP_DRIVERFORGE_DEVICE_SEPARATOR}${device}" fi spaceship::section::v4 \ --color "$SPACESHIP_DRIVERFORGE_COLOR" \ --prefix "$SPACESHIP_DRIVERFORGE_PREFIX" \ --suffix "$SPACESHIP_DRIVERFORGE_SUFFIX" \ --symbol "$SPACESHIP_DRIVERFORGE_SYMBOL" \ "$label" } ``` ### Options Override any of these in `~/.zshrc` before sourcing the file: | Variable | Default | Effect | | --------------------------------------- | -------------- | -------------------------------------------------------------- | | `SPACESHIP_DRIVERFORGE_SHOW` | `true` | `false` hides the section entirely | | `SPACESHIP_DRIVERFORGE_SHOW_DEVICE` | `true` | `false` shows only the org, never the controller | | `SPACESHIP_DRIVERFORGE_PREFIX` | `using ` | Text before the section (matches Spaceship's Azure section) | | `SPACESHIP_DRIVERFORGE_SYMBOL` | `󰢛 ` (anvil) | Section symbol: see the font note below | | `SPACESHIP_DRIVERFORGE_DEVICE_SEPARATOR` | `/` | Separator in `org/device` | | `SPACESHIP_DRIVERFORGE_COLOR` | `#79C0FF` | Section colour (any zsh `%F` value: ANSI index or `#rrggbb`) | | `SPACESHIP_DRIVERFORGE_COMMAND` | `driverforge` | Binary to query: point at a dev build if you have one | ### Font note The default symbol is the Material Design *anvil* glyph (`nf-md-anvil`, `U+F089B`), which needs a full **Nerd Font**: a plain Powerline font (including plain Fira Code) only carries the Powerline glyphs and will show a missing-glyph box. Either install one: ```bash brew install --cask font-fira-code-nerd-font # then select "FiraCode Nerd Font" in your terminal ``` or override the symbol with an emoji, which renders anywhere: ```bash SPACESHIP_DRIVERFORGE_SYMBOL="🛠️ " ``` ### Related - [Context](/cli/context): how org and controller selection works - [`driverforge org`](/cli/org) / [`driverforge device`](/cli/device): the commands the section reads --- ## Authentication The Driverforge CLI authenticates you with Driverforge so it can act on your behalf: listing your organizations, talking to your controllers, and deploying drivers. You sign in once with [`driverforge login`](/cli/login); the CLI stores the credentials locally and refreshes them automatically, so you rarely think about it again until you [`driverforge logout`](/cli/logout). ### Do I have to log in? No: the core of the CLI works anonymously. You can author, [build](/cli/build), package, encrypt, and [source-map](/cli/source-maps) a driver entirely offline, with no account and nothing to sign up for. That's the whole local development loop, available the moment you install `driverforge`. Signing in unlocks the parts that go through the Anvil cloud: anything that needs Driverforge to know who you are and which controllers are yours: [`deploy`](/cli/deploy) and [`sync`](/cli/sync) to push a build to a controller, [`upgrade`](/cli/upgrade) to update its agent, and [`org`](/cli/org) / [`device`](/cli/device) to choose where those act. ### How it works `driverforge login` uses the OAuth 2.0 device authorization grant: it shows a short code, opens your browser to confirm it, and waits while you authorize; your password is never entered into or seen by the CLI. Credentials are stored locally and refreshed automatically. ### Commands - [`driverforge login`](/cli/login): sign in to Driverforge - [`driverforge logout`](/cli/logout): sign out and remove stored credentials - [`driverforge whoami`](/cli/whoami): show the currently signed-in user --- ## Error reporting When something goes wrong, the CLI distinguishes a condition it *expected* from a genuine *bug*, and treats them differently. ### Expected conditions Things like "you're not logged in", "this isn't a driver project", "no controller selected", or "the Anvil Agent is unreachable" are expected. The CLI shows a short, friendly card explaining what happened and how to fix it, and **never** reports them anywhere. ### Unexpected errors If the CLI hits something it didn't anticipate, it shows a crash card and **offers to send an error report** so we can fix it. Reporting is **opt-in, per error**: you're asked each time, and nothing is sent unless you agree. A report contains the command you ran, which flags were set (their names only, not their values), and the error itself, **never your source code or file contents**. ### Turning it off Error reporting is off automatically in CI and non-interactive shells, and is never offered to a [coding agent](/cli/agents). To disable it everywhere, set any of: - `DRIVERFORGE_NO_ERROR_REPORTING=1` - `DO_NOT_TRACK=1` - `DRIVERFORGE_NO_METRICS=1` See also [Telemetry](/cli/telemetry) for anonymous usage metrics, which are separate and likewise opt-in. --- ## sync Build your driver and hot-swap its Lua into the running instance on a controller: fast, with no full reload. Ideal for tight edit-test loops while developing. ### Usage ```bash driverforge sync [options] ``` `sync` builds first (respecting `-c/--configuration`, including the configuration's [defaults](/cli/build-configuration#per-configuration-defaults) from the project config), then ships the bundled Lua to the [Anvil Agent](/agent/overview), which swaps it into the already-loaded driver. What you sync is always your current source: there is no stale artifact to forget about. Because it skips the install-and-reload cycle a full [`deploy`](/cli/deploy) does, it's much faster, but it only applies when the driver's structure hasn't changed. A sync never changes the driver's [version](/cli/versioning). ### Prerequisites - The project is [initialised](/cli/init) (`driverforge init`) - You're [signed in](/cli/login) (`driverforge login`) - A target controller is [selected](/cli/device) (`driverforge device select`) - The [Anvil Agent](/agent/overview) is installed and running on the controller - The driver is already installed on the controller; [`deploy`](/cli/deploy) it once first so there's a running instance to hot-swap into ### When sync applies (and when it doesn't) Sync only hot-swaps when `driver.xml` is **structurally unchanged** since the running build (same actions, properties, commands, connections, etc.). If you've changed any of that, a full reload is required and `sync` will offer to run a [`deploy`](/cli/deploy) for you (or do it directly with `--deploy`). The escalation runs the full deploy flow, rebuild and [version bump](/cli/versioning) included. Run by a [coding agent](/cli/agents), `sync` doesn't offer: it stops with the error code `deploy_required`, and the agent runs it again with `--deploy`. Keep these in mind: - **Load-time init doesn't re-run.** Sync re-runs top-level Lua but not `OnDriverInit` / `OnDriverLateInit`, so keep load-time initialization idempotent if you rely on it during development. - **Encrypted drivers can't be hot-swapped.** The Anvil Agent can't update an encrypted driver's contents in place. Build unencrypted during development to take advantage of hot reloading with `sync`; to update an encrypted driver, use [`deploy`](/cli/deploy), which installs the new version and reloads it in full. (An encrypted build passed to `sync` falls back to a deploy automatically.) ### Options | Option | Description | | ----------------------- | -------------------------------------------------------------------------- | | `--device` | Controller to sync to (name, hostname, or id); overrides the selected one | | `--select` | Re-select the target controller first | | `--configuration`, `-c` | Build configuration to build and sync | | `--deploy` | Do a full [deploy](/cli/deploy) instead of a hot-swap | | `--refresh-navigators` | When sync performs a full deploy, refresh navigators even if `driver.xml` is unchanged | ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text ┃ ✓ Sync complete ┃ ┃ driver poolpump ┃ version 20261105.2 ┃ artifact dist/poolpump.c4z ┃ controller Living Room ┃ devices Pool Pump ``` **Structured** Progress is abbreviated. When the change needs a full deploy, `sync` stops with the error code `deploy_required` instead; run it again with `--deploy`, and the result has `"action": "deploy"`. stdout: ```json { "action": "sync", "reason": null, "build": { "driver": "poolpump", "configuration": "default", "version": "20261105.2", "artifact": "dist/poolpump.c4z", "encrypted": false, "unpacked": null, "sourcemap": null, "warnings": [] }, "device": { "id": "9e8d7c6b-5a4f-4e3d-a2c1-b0a9f8e7d6c5", "name": "Living Room" }, "state": "synced", "version": "20261105.2", "report_url": null, "instances": ["Pool Pump"], "verified": true, "warnings": [] } ``` stderr: ```json {"progress": {"status": "ok", "message": "Build complete"}} {"progress": {"status": "running", "message": "Connecting to Living Room"}} {"progress": {"status": "ok", "message": "Connected to Living Room (Anvil Agent 1.0.0)"}} {"progress": {"status": "running", "message": "Hot-swapping the driver's Lua"}} {"progress": {"status": "ok", "message": "Lua hot-swapped on 1 device"}} {"progress": {"status": "ok", "message": "Sync complete"}} ``` ### Examples Build and hot-swap onto the selected controller: ```bash driverforge sync ``` Build and sync the `release` configuration: ```bash driverforge sync -c release ``` Force a full deploy instead: ```bash driverforge sync --deploy ``` ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## doctor Check that a driver project still has everything [`driverforge init`](/cli/init) set up, and restore whatever is missing. > **Warning: Repairs modify your driver project** > > Checking is read-only and safe to run any time, but the repairs it offers **modify files in your driver project**: they > are the same transforms [`driverforge init`](/cli/init) applies. It shows you a > per-file diff for approval and backs up edited files before writing, but always > review the changes before committing. ### Usage ```bash driverforge doctor ``` Run it from inside a driver project that has already been set up. It reports each part of the setup individually, then, if anything is missing, proposes the repairs and asks before writing. ### When to reach for it Two situations, both of which look like the project has quietly stopped working: - **It used to build or sync, and now it doesn't.** A file was moved, an edit was reverted, a merge dropped a hunk. - **Someone cloned the repo and it doesn't build for them.** The vendored SDK or the entry wiring didn't survive the trip: a `.gitignore` rule, an export, a zip that skipped a directory. `init` sets a project up exactly once and won't touch an initialised project again, and [`driverforge upgrade`](/cli/upgrade) only swaps the embedded SDK for a newer one. Neither notices a project that has lost a piece of its setup. `doctor` is the command that does. ### What it checks Each check is reported pass or fail on its own line, so a healthy run tells you what it verified rather than printing nothing: | Check | What it means | | -------------------------------------------------------------- | ------------------------------------------------------------------ | | The driver entry requires the SDK and calls `Driverforge:Init` | The lines `init` inserts into your entry Lua are still there. | | `src/vendor/driverforge-sdk.lua` is present | The embedded SDK bundle exists and isn't empty. | | `manifest.c4zproj` sets `squishLua="true"` | The project still squishes its Lua, which is what embeds the SDK. | | `manifest.c4zproj` ships the vendor dir | The vendored SDK is included in the built `.c4z`. | | squishy declares the vendored SDK module | The squishy names the SDK module. | | squishy declares the config module | The same for `config.lua`, when the project has build configurations. | The two squishy checks matter more than they look. The squisher only preloads modules the squishy declares, so a missing declaration isn't a cosmetic omission; it's a driver-load error on the controller. The config module is only checked when the project has [build configurations](/cli/build-configuration). The same class of mistake in your own modules is caught at build time: [`driverforge build` warns](/cli/build#warnings) when a bundled file requires a local module the squishy doesn't declare. A healthy project finishes here: ``` Checking this driver's Driverforge setup: ✓ the driver entry requires the SDK and calls Driverforge:Init ✓ src/vendor/driverforge-sdk.lua is present ✓ manifest.c4zproj sets squishLua="true" ✓ manifest.c4zproj ships the vendor dir ✓ squishy declares the vendored SDK module Everything init sets up is in place. ``` ### Repairing When a check fails, `doctor` works out the file changes that would fix it and shows them to you before anything is written: ``` Checking this driver's Driverforge setup: ✓ the driver entry requires the SDK and calls Driverforge:Init ✗ src/vendor/driverforge-sdk.lua is present ✓ manifest.c4zproj sets squishLua="true" ✓ manifest.c4zproj ships the vendor dir ✗ squishy declares the vendored SDK module ``` The repairs are the same transforms `init` uses, re-planned against your project, not a separate repair path that could drift out of step with how a project is set up in the first place. They're idempotent, so the parts that already pass are left alone and only the missing pieces are proposed. The SDK it restores is the version recorded in `.driverforge/config.json`, so a repair puts the project back to what it claimed to be. Moving to a newer SDK stays [`driverforge upgrade`](/cli/upgrade)'s job. You review a per-file diff and approve it, exactly as with `init`. Run by a [coding agent](/cli/agents) without `--yes`, `doctor` lists the repairs it would make, writes nothing, and exits `1`. Run it again with `--yes` to apply them. ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text Checking this driver's Driverforge setup: ✓ the driver entry requires the SDK and calls Driverforge:Init ✓ src/vendor/driverforge-sdk.lua is present ✓ manifest.c4zproj sets squishLua="true" ✗ manifest.c4zproj ships the vendor dir ``` **Structured** Without `--yes`, `doctor` lists the files it would change in `changes`, writes nothing, and exits `1`. With `--yes` it applies them and `repaired` is `true`. Each check is also reported on stderr as it runs. stdout: ```json { "healthy": false, "checks": [ { "name": "entry wiring", "what": "the driver entry requires the SDK and calls Driverforge:Init", "ok": true }, { "name": "embedded SDK", "what": "src/vendor/driverforge-sdk.lua is present", "ok": true }, { "name": "squishLua", "what": "manifest.c4zproj sets squishLua=\"true\"", "ok": true }, { "name": "vendor item", "what": "manifest.c4zproj ships the vendor dir", "ok": false } ], "changes": ["src/manifest.c4zproj"], "repaired": false, "warnings": [ { "code": "repair_pending", "message": "Not repaired: re-run with --yes to write the listed changes." } ] } ``` ### Options | Option | Description | | ------------- | -------------------------------------------------------------------------------------- | | `--yes`, `-y` | Apply the repairs without asking. For CI and scripts, where there's nobody to confirm. | ### Network and sign-in **Diagnosis is entirely local.** No network, no sign-in: you can run `driverforge doctor` on a plane and get a complete answer about what's missing. Repairs are almost all local too. The one exception is rewriting the entry Lua: that line carries the project's driver token, and `.driverforge/config.json` deliberately holds no secrets, so the token is fetched from your project. That one repair needs you to be [signed in](/cli/login). Every other repair (restoring the bundle, fixing the manifest, fixing the squishy) works offline. So a run that only needs the bundle put back never touches the network, and a run that needs the entry rewired will ask you to sign in first. ### When it can't help If the project has no `.driverforge/config.json` at all, there's nothing to diagnose against: it was never set up. `doctor` says so and points you at [`driverforge init`](/cli/init). If checks fail but no file change would fix them, it tells you that too rather than reporting a success the checks plainly contradict. ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## events (Cli) Read the events your driver handled, with their arguments and results, from the terminal, scoped to the controller and the exact version you just deployed. ### Usage ```bash driverforge events [options] ``` `events` lists the Control4 callbacks your driver handled (`ReceivedFromProxy`, `OnPropertyChanged`, `OnTimerExpired`, …), oldest first, each with the arguments it was called with, what it returned, its status and how long it took. It works exactly like [`driverforge logs`](/cli/logs): the same [scope rules](/cli/logs#choosing-what-to-read), [versions](/cli/logs#versions), [waiting and following](/cli/logs#waiting-for-output), [output](/cli/logs#output) and [exit statuses](/cli/logs#exit-status). ### Prerequisites - You're [signed in](/cli/login) (`driverforge login`) - Your driver uses the Anvil SDK and the [Anvil Agent](/agent/overview) is installed on the controller ### Options | Option | Description | | --------------------- | -------------------------------------------------------------------------------------- | | `--org` | Organization slug, name or id | | `--project` | Project slug, name or id | | `--device` | Controller name, hostname, hardware id or id | | `--version` | A version number or `latest` | | `--since` | Start of the window: a duration (`30s`, `10m`, `2h`) or an RFC 3339 time | | `--until` | End of the window, in the same forms | | `--tail` | How many of the newest events to return (default 100, at most 1000) | | `--before` | Page back from the `next_cursor` of a previous response | | `--name` | Only events with this name, e.g. `ReceivedFromProxy` | | `--grep` | Regular expression matched against the event's arguments and result | | `--ignore-case`, `-i` | Make `--grep` case-insensitive | | `--correlation-id` | Only the event with this trace id | | `--field` | A `key=value` facet filter; repeatable. Keys: `controller`, `driver`, `name`, `status` | | `--until-match` | Wait until an event matching this regular expression arrives | | `--min-events` | Wait until this many events match | | `--timeout` | Longest wait (default 30s when waiting, at most 10m) | | `--follow`, `-f` | Stream events as they arrive, until interrupted or `--timeout` | | `--output`, `-o` | `text`, `json` or `jsonl` | | `--max-payload-bytes` | Cap each event's arguments and result (default 65536; `0` for no cap) | ### What each event carries An event's `payload` is `{"args": …, "result": …}`, exactly as recorded: structured values stay nested JSON, in the order the driver produced them. Its `id` is the event's trace id, which the logs and errors raised while handling it carry as their `correlation_id`: ```bash driverforge logs --correlation-id ``` ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text scope: org=acme project=poolpump device=Living Room version=20261105.2 2026-11-05T03:12:44.201Z EVENT v20261105.2 ExecuteCommand ok { "args": ["PLAY", {}], "result": null } ``` **Structured** The scope goes to stderr and the entries to stdout, so `jq` sees only the data. Structured, the scope is in the document itself; `count`, `has_more` and `next_cursor` page through larger results, and `wait` is added when the read waited on `--until-match` or `--min-events`. stdout: ```json { "scope": { "org": "acme", "project": "poolpump", "device": { "id": "9e8d7c6b-5a4f-4e3d-a2c1-b0a9f8e7d6c5", "name": "Living Room" }, "version": "20261105.2", "since": null, "until": null }, "entries": [ { "id": "5b0e8c3a1f7d4e269a4c0b8d7e6f5a41", "type": "event", "timestamp": "2026-11-05T03:12:44.201Z", "level": null, "name": "ExecuteCommand", "message": null, "payload": { "args": ["PLAY", {}], "result": null }, "status": "ok", "duration_ms": 31.4, "error_id": null, "ref": null, "driver": "poolpump.c4z", "driver_version": "20261105.2", "device": { "id": "000FFF1A2B3C", "name": "Living Room" }, "correlation_id": "5b0e8c3a1f7d4e269a4c0b8d7e6f5a41", "truncated": null } ], "count": 1, "has_more": false, "next_cursor": null, "warnings": [] } ``` #### Warnings A read that succeeds can still carry warnings, each with a stable `code`: | Code | Meaning | | ---------------------- | ------- | | `no_entries` | Nothing matched the scope and filters. | | `retention_clamped` | `--since` reaches past your plan's retention; only the last `details.window_minutes` were searched. | | `tail_clamped` | `--tail` is over the maximum; the newest page was returned. Page further with `--before`. | | `payload_truncated` | Some entries were cut at `--max-payload-bytes`. Each is listed in `details.entries`; [`driverforge get`](/cli/get) fetches it in full. | | `device_not_reporting` | The controller hasn't reported to Driverforge for 5 minutes or more; `details.last_seen_at` is when it last did (RFC 3339, UTC). Empty results from a controller that isn't reporting say nothing about the driver: check the controller first. | A wait that times out on a controller that isn't reporting still exits `3`; its `wait_timeout` error carries `details.device_not_reporting: true` and `details.last_seen_at`, and its hint says to check the controller and its Anvil agent rather than to wait longer. ### Examples What the driver received from its proxy since the last deploy: ```bash driverforge events --version 2026110502 --name ReceivedFromProxy ``` Wait for the next property change: ```bash driverforge events --name OnPropertyChanged --min-events 1 --timeout 2m ``` ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## login Authenticate with Driverforge. Sign in once and the CLI stores and refreshes your credentials, so the commands that reach the Anvil cloud ([`deploy`](/cli/deploy), [`sync`](/cli/sync), [`org`](/cli/org), [`device`](/cli/device), [`upgrade`](/cli/upgrade)) work without prompting again. ### Usage ```bash driverforge login [options] ``` ### What it does `driverforge login` uses the OAuth 2.0 device authorization grant: it shows a short code, opens your browser to confirm it, and waits while you authorize. **Your password is never entered into or seen by the CLI.** After you authorize, it stores the credentials locally and prompts you to pick the [organization](/cli/org) to work in (skipped if you belong to only one). See [Authentication](/cli/authentication) for the bigger picture. Run by a [coding agent](/cli/agents), `login` doesn't open a browser. It writes the link and code as an [`action_required`](/coding-agents/skills/cli#when-a-person-has-to-act) line for the agent to hand to you, and waits while you approve. It can't show the organization picker, so pass `--org` if you belong to more than one. ### Options | Option | Description | |--------|-------------| | `--no-browser` | Don't open a browser automatically; visit the printed URL yourself | | `--org` | Organization to use after signing in (name, slug, or id); skips the picker | ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text ┃ To authorize driverforge, open this link in your browser: ┃ ┃ https://auth.driverforge.com/device?user_code=WDJB-MJHT ┃ ┃ and check it shows this code: ┃ ┃ WDJB-MJHT Opened your browser… ✓ Logged in as Jane Citizen (jane@example.com) Using organization: Acme Integration (acme) ``` **Structured** No browser opens. The agent hands you the link and code from the `action_required` line, and `login` waits while you approve. stdout: ```json { "user": { "id": "6a1f0c2e-9b7d-4e3a-8f21-0d5c4b3a2e10", "name": "Jane Citizen", "email": "jane@example.com", "session_expires_at": "2026-11-05T07:30:00Z" }, "organization": { "id": "c2d4e6f8-1a3b-4c5d-9e7f-8a6b4c2d0e1f", "name": "Acme Integration", "slug": "acme", "current": true }, "warnings": [] } ``` stderr: ```json {"action_required": {"message": "Open the link in a browser and approve the sign-in with this code.", "url": "https://auth.driverforge.com/device", "url_with_code": "https://auth.driverforge.com/device?user_code=WDJB-MJHT", "code": "WDJB-MJHT", "expires_at": "2026-11-05T07:40:00Z"}} {"progress": {"status": "running", "message": "Waiting for authorization"}} {"progress": {"status": "ok", "message": "Logged in as Jane Citizen (jane@example.com)"}} {"progress": {"status": "info", "message": "Using organization: Acme Integration (acme)"}} ``` ### Examples Sign in interactively: ```bash driverforge login ``` Sign in on a headless machine and pick an org non-interactively: ```bash driverforge login --no-browser --org acme ``` ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## upgrade See, and interactively apply, everything upgradable in the current context: the `driverforge` CLI itself, the [Anvil Agent](/agent/overview) on the selected controller, and the [Driverforge SDK](/sdk/overview) embedded in the current project. ### Usage ```bash driverforge upgrade ``` ### The picker `driverforge upgrade` shows one row per component: **driverforge CLI**, **Anvil Agent** (the [selected controller](/cli/device)), and **Driverforge SDK** (the current project). Each row shows current → latest versions and status. The CLI's version check here is always live, never the daily cached answer behind the passive [update notice](/cli/upgrading#update-notices). Available upgrades are selectable when their prerequisites are met. **Nothing is pre-selected**: confirming the selection starts the upgrades. For SDK changes, the CLI also offers an optional git branch and commit, as described below. | Key | Action | |-----|--------| | `space` | Select / deselect a row | | `enter` | Upgrade the selected rows | | `r` | Open the highlighted row's release notes | | `q` | Quit | What confirming does, per row: - **Anvil Agent**: upgrades the agent on the selected controller directly (download, SHA-256 verify, deploy under the installed filename, restart, and confirm it came back up via a health poll). - **Driverforge SDK**: re-embeds the latest Driverforge SDK in the current project (`src/vendor/driverforge-sdk.lua`, and `.driverforge/config.json` is bumped to match). With a dirty git tree, the update remains visible but cannot be selected: commit or stash your changes, then re-run. - **driverforge CLI**: verifies and replaces the installed binary when its location is writable. The new version runs on your next command. If it cannot update itself, the CLI provides the upgrade command for your installation. `r` on the SDK row opens that release's notes on GitHub (`github.com/driverforge/control4-sdk/releases`). > **Note** > > An agent too old to report its installed filename can't self-upgrade. Update it > once in Composer Pro ([instructions](/agent/installation#updating)); after that > `driverforge upgrade` can take over. ### SDK branch and commit prompts When an SDK upgrade will change files in a git repository with an existing commit, it offers the same git workflow as [`init`](/cli/init): 1. **Create a git branch for these changes?** Accept to choose a branch name. The default is `driverforge-sdk-`, for example `driverforge-sdk-0.9.2`. If that name already exists, the suggestion gets a numeric suffix such as `-2`. Decline to apply the update on your current branch without committing. 2. **Commit message** appears if you choose a branch. The default is `chore: update Driverforge SDK to `. Accept or edit it to commit the update, or clear it to leave the changes uncommitted on the new branch. If the SDK bundle and configuration already match the target release, the CLI reports that there is nothing to update and skips both prompts. Projects outside git, or without an initial commit, also skip the branch and commit prompts. ### Non-interactive behaviour Piped, under `CI`, or with `--no-tui`, `driverforge upgrade` is report-only: it prints the status table and never mutates. There is **no non-interactive way to upgrade an agent**; this is deliberate. Upgrades act on a connected controller and are always an interactive choice. ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text COMPONENT CURRENT LATEST STATUS driverforge CLI 1.0.0 1.0.0 ✓ up to date Anvil Agent (Living Room) 1.0.0 1.0.1 ⬆ update available → driverforge upgrade Driverforge SDK 1.0.0 1.0.0 ✓ up to date ``` **Structured** The table is what prints when `upgrade` isn't attached to a terminal; in a terminal it's [the picker](#the-picker). Under a coding agent, `upgrade` only reports: it never shows the picker or applies an upgrade. A component's `status` is `up_to_date`, `update_available`, `blocked` (available, but `note` says why it can't be applied yet), `unknown` (couldn't check) or `not_applicable`. stdout: ```json { "components": [ { "name": "driverforge CLI", "detail": null, "current": "1.0.0", "latest": "1.0.0", "status": "up_to_date", "note": "up to date", "command": null, "release_notes_url": null }, { "name": "Anvil Agent", "detail": "Living Room", "current": "1.0.0", "latest": "1.0.1", "status": "update_available", "note": "update available", "command": "driverforge upgrade", "release_notes_url": null }, { "name": "Driverforge SDK", "detail": null, "current": "1.0.0", "latest": "1.0.0", "status": "up_to_date", "note": "up to date", "command": null, "release_notes_url": null } ] } ``` ### Examples ```bash driverforge upgrade ``` ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## Upgrade (Cli) `driverforge` keeps itself, the Anvil Agent, and your embedded SDK current. Here's how the pieces fit. ### Update notices After a command runs, the CLI checks (at most once a day, cached) whether a newer `driverforge` release is available, and prints a one-line notice if so. It's quiet by design: the notice goes to stderr, never stdout, and never appears in CI or non-interactive shells. Turn it off with `--no-update-check`. ### Upgrading the CLI Select **driverforge CLI** in [`driverforge upgrade`](/cli/upgrade) to verify and replace the installed binary. This requires a writable installation location; the new version runs on your next command. You can also update it through your original installation method: ```bash brew upgrade driverforge # macOS scoop update driverforge # Windows # Linux / WSL: re-run the install script sh -c "$(curl -fsSL https://go.driverforge.com/get)" ``` [`driverforge upgrade`](/cli/upgrade) shows everything upgradable in one place: the CLI itself, the agent, and the embedded SDK. It applies selected upgrades interactively. If the CLI cannot update itself, it provides the command for your installation method. ### Upgrading the Anvil Agent The [`driverforge upgrade`](/cli/upgrade) picker is how agents get upgraded: select the **Anvil Agent** row and confirm, and the CLI updates the agent on the [selected controller](/cli/device) to the latest release. Upgrades are interactive-only: non-interactively, `driverforge upgrade` reports and never mutates. ### Upgrading the SDK The Driverforge SDK is embedded in your driver, and the SDK row of the [`driverforge upgrade`](/cli/upgrade) picker is the only way to update it. It re-embeds the latest release. With a dirty git tree, the update is visible but cannot be selected; commit or stash your changes first. In a git repository with an existing commit, the SDK upgrade offers two optional steps, just like `init`: create a branch (default `driverforge-sdk-`, such as `driverforge-sdk-0.9.2`), then supply a commit message. The suggested message is `chore: update Driverforge SDK to `; clear it to leave the changes uncommitted. Declining the branch keeps the update on your current branch without committing it. An upgrade that would make no file changes skips both prompts. See the [branch and commit prompts](/cli/upgrade#sdk-branch-and-commit-prompts) for details. --- ## run Run your driver's Lua on your own machine while a real controller drives it. Save a file, trigger the action again, and the new code handles it: no build, no deploy, no waiting for the driver to reload. When you need to look closer, attach a debugger and step through your handlers with breakpoints. > **Info: Coming soon** > > `driverforge run` isn't available in the current release; running it reports > that it's coming soon. This page describes how it will work. ### Usage ```bash driverforge run [options] ``` `run` swaps your driver on the controller for a small **stub** and runs your real source in a Lua process on your machine. Every callback the controller makes is handed to your local code, and every `C4:*` call your code makes is carried out on the controller, with the real result handed back. From your driver's point of view it is running on the controller; from your machine's point of view it is an ordinary local Lua process, which your editor, your coding agent and your debugger can all work with directly. Ctrl+C stops it. Run [`driverforge deploy`](/cli/deploy) to put your real driver back, or pass `--deploy-on-exit` and `run` does it for you. ### Prerequisites - The project is [initialised](/cli/init) (`driverforge init`) - You're [signed in](/cli/login) (`driverforge login`) - A target controller is [selected](/cli/device) (`driverforge device select`) - The [Anvil Agent](/agent/overview) is installed and running on the controller - A Lua 5.1 interpreter is on your machine. LuaJIT is the easiest to get (`brew install luajit`); the CLI looks for `lua5.1`, `luajit` or `lua` on your `PATH`, or uses whatever `--lua` or `DRIVERFORGE_LUA` points at. ### The edit loop The usual way to try a change is build, deploy, wait for the driver to reload, then trigger the behaviour you changed. `run` removes everything but the last step: 1. Start `driverforge run` once. 2. Edit a file and save it, in your editor or from your coding agent. 3. Trigger the action again: press the button in Composer or the app, send the command, wait for the next poll. The new code handles it. Saving reloads your driver in place, under the same rules as [`sync`](/cli/sync): handlers are redefined, `OnDriverInit` and `OnDriverLateInit` don't run again, and in-memory state survives. A file that fails to compile is reported, and the previous code keeps running. `print` output and errors appear in your terminal as they happen, so a coding agent running `run` sees the result of each change in the same place it made it. With `--verbose`, so does every `C4` call and its result. ### How it works The stub that replaces your driver has no business logic of its own. It forwards each callback (`OnDriverInit`, `ReceivedFromProxy`, `OnPropertyChanged`, `OnTimerExpired`, …) to your machine, and executes the `C4:*` calls your code makes in reply. Every `C4:*` call is a round trip to the controller, so the route matters: - **Over your local network, through the Anvil Agent**, when your machine can reach the controller and the agent supports it. This is the fast path: each call costs a LAN round trip. You'll see `Local network relay up through the agent` once it's in use. - **Through Anvil's broker**, the cloud service the Anvil Agent reports to. Both ends connect outbound, so this works across VLANs and through a customer's firewall, at the cost of an internet round trip per call. The broker connection is set up first and stays up for the whole run. If the local network path drops, `run` falls back to the broker without losing a call, and says so. `--no-relay` keeps everything on the broker. ### A run, step by step 1. **Your driver compiles locally first.** A driver that fails to compile stops here, before the controller is touched. 2. **The stub is built.** The CLI builds your project exactly as `deploy` does, then replaces the Lua inside the `.c4z` with the stub. `driver.xml` is left byte-for-byte as it was, so your bindings, proxies and properties stay put. 3. **The stub is deployed** through the agent, like any `deploy`. 4. **The controller now drives your local code**, over the local network when it can and through the broker when it can't. 5. **Saving a file reloads your driver in place** (see [the edit loop](#the-edit-loop)). 6. **Ctrl+C stops it.** The stub stays on the controller, inert, until you run [`driverforge deploy`](/cli/deploy). With `--deploy-on-exit`, `run` builds and deploys your driver as `deploy` would, and confirms when it's back. ### Debugging with breakpoints Because your driver runs in a local Lua process, you can stop it at a breakpoint while the controller is talking to it, inspect variables and step through handlers. `--debug` connects that process to a Lua debugger using [MobDebug](https://github.com/pkulchenko/MobDebug), the remote debugging protocol ZeroBrane Studio and the VS Code "Lua MobDebug adapter" speak: ```bash driverforge run --debug # debugger listening on localhost:8172 driverforge run --debug=192.168.1.20:8172 # debugger on another address ``` The debugger must already be listening when `run` starts: the Lua process connects out to it before your driver loads. Without `--debug`, no debugger is loaded and your code runs at full speed. #### 1. Install MobDebug for the Lua that `run` uses MobDebug needs the `mobdebug` module and LuaSocket, built for the same Lua 5.1 interpreter `run` uses. Pick one: - **With LuaRocks**, for Lua 5.1: ```bash luarocks --lua-version 5.1 install mobdebug # also installs LuaSocket eval "$(luarocks --lua-version 5.1 path)" # in the shell you run driverforge from ``` - **From ZeroBrane Studio**, which ships both for Lua 5.1. On macOS: ```bash ZBS=/Applications/ZeroBraneStudio.app/Contents/ZeroBraneStudio export LUA_PATH="./?.lua;$ZBS/lualibs/?/?.lua;$ZBS/lualibs/?.lua" export LUA_CPATH="$ZBS/bin/clibs/?.dylib" ``` `run` passes your environment to the Lua process, so `LUA_PATH` and `LUA_CPATH` set in your shell reach it. If MobDebug can't be loaded, `run` warns and carries on without a debugger. #### 2. Start the debugger, then `run` **VS Code** Install the **Lua MobDebug adapter** extension (`AlexeyMelnichuk.lua-mobdebug`), then add a configuration that listens for `run` to `.vscode/launch.json` in your driver project: ```json { "version": "0.2.0", "configurations": [ { "name": "driverforge run --debug", "type": "luaMobDebug", "request": "attach", "workingDirectory": "${workspaceFolder}", "sourceBasePath": "${workspaceFolder}", "listenPublicly": false, "listenPort": 8172, "stopOnEntry": false, "sourceEncoding": "UTF-8" } ] } ``` 1. Set breakpoints in your driver's source files. 2. Start the **driverforge run --debug** configuration (F5). VS Code waits for a connection on port 8172. 3. In a terminal in the project, run `driverforge run --debug`. 4. Trigger the action on the controller. VS Code stops at your breakpoint. `stopOnEntry` is `false` because the first line after the debugger connects belongs to `run`'s own loader, not your driver. Set `listenPublicly` to `true` only when `run` connects from another machine (`--debug=:8172`). **ZeroBrane Studio** 1. Open your driver project's folder and set it as the project directory (**Project → Project Directory → Choose…**). 2. Choose **Project → Start Debugger Server**. ZeroBrane listens on port 8172. 3. Set breakpoints in your driver's source files. 4. In a terminal in the project, run `driverforge run --debug`. 5. ZeroBrane stops on the first line after the debugger connects, which is in `run`'s own loader. Continue (F5), then trigger the action on the controller; ZeroBrane stops at your breakpoint. **Other editors** Any editor or debugger that runs a MobDebug server works the same way: start its server on a port, then pass that address to `--debug`: ```bash driverforge run --debug=localhost:9000 ``` Your driver's files are loaded from their absolute paths on your machine, so breakpoints set on the files in your project match without any path mapping. #### While you're stopped at a breakpoint Only your local Lua process pauses. The controller and the stub keep running: callbacks that arrive while you're stopped wait in line and reach your code when you continue, and the connection to the controller stays up. The controller doesn't wait for your answer to a callback in any case (see [what's different](#whats-different-from-running-on-the-controller)), so a long pause doesn't stall the controller, but anything time-based in your driver will see the time you spent paused. Saving a file while you're stopped reloads it when the process continues. ### Options | Option | Description | | ----------------------- | -------------------------------------------------------------------------------------------------------------- | | `--device` | Controller to run against (name, hostname, or id); overrides the selected one | | `--select` | Re-select the target controller first | | `--configuration`, `-c` | Build configuration to run; also selects `config..lua` in the local process | | `--debug[=host:port]` | Connect the local Lua process to a MobDebug debugger; `localhost:8172` when given without an address | | `--deploy-on-exit` | When `run` stops, build and deploy your driver to replace the stub, as `driverforge deploy` would | | `--no-relay` | Send everything through the broker, not over your local network through the agent | | `--no-reload` | Don't reload your driver when source files change | | `--lua` | Lua 5.1 interpreter to run your driver with (default: `lua5.1`, `luajit` or `lua` on `PATH`) | An address for `--debug` needs the `=`: `--debug=host:port`. A bare `--debug` followed by a separate word is read as `--debug` plus that word. ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text ✓ Stub online as poolpump; starting the driver locally ✓ Local network relay up through the agent: C4 calls skip the cloud ✓ Driver running locally (12 handlers) ← ExecuteCommand("SET_SPEED",{SPEED="2400"}) | pump speed set to 2400 rpm changed: driver.lua ✓ Reloaded driver source ``` **Structured** `run` writes one JSON object per event on stdout, as it happens, until it stops. `event` is one of `compiled`, `ready`, `callback`, `callback_result`, `c4_call`, `c4_result`, `print`, `runtime_log`, `reloaded`, `fatal`, `stub_online`, `stub_offline`, `stub_log` or `runtime_exited`. Fields that don't apply to an event are left out. stdout: ```json {"event": "stub_online", "driver": "poolpump"} {"event": "ready", "handlers": ["ExecuteCommand", "ReceivedFromProxy", "OnPropertyChanged"]} {"event": "callback", "summary": "ExecuteCommand(\"SET_SPEED\",{SPEED=\"2400\"})", "name": "ExecuteCommand", "args": ["SET_SPEED", {"SPEED": "2400"}]} {"event": "print", "text": "pump speed set to 2400 rpm"} {"event": "callback_result", "name": "ExecuteCommand", "ok": true, "handled": true} ``` ### Examples Run on the selected controller, and put the real driver back when you stop: ```bash driverforge run --deploy-on-exit ``` Run the `release` configuration on a specific controller, showing every `C4` call as it happens: ```bash driverforge run -c release --device "Plant Room" --verbose ``` Debug under VS Code or ZeroBrane Studio, with the debugger already listening on port 8172: ```bash driverforge run --debug ``` Debug from a machine that can't reach the controller directly, through the broker: ```bash driverforge run --debug --no-relay ``` ### What's different from running on the controller Your code is real and so is the controller, but there's a network between them. A few things behave differently because of that: - **Callbacks don't wait for your answer.** The controller hands a callback over and carries on. A handler whose return value the controller uses (`UIRequest`, `GetPrivateKeyPassword`, the `List*` family) still runs, but the controller sees `nil`. - **Every `C4:*` call is a round trip.** Over your local network that's quick; through the broker it's an internet round trip. Either way, timing-sensitive code won't behave exactly the way it does in production. - **State starts fresh.** Swapping the stub in reloads the driver, so anything it held in memory is gone. `Properties` and `PersistData` are copied to your local process on every callback, but writes to `PersistData` aren't saved while `run` is running. - **Timers, URL requests and other controller objects work.** Callbacks you pass to `C4:SetTimer` or `C4:url():OnDone` fire in your local code, and objects the controller returns can be used and cancelled as usual. - **Anvil reports from the stub, not your SDK.** The stub is instrumented, so the console shows one event per callback and every error your handlers raise. Your driver's own Anvil SDK stays quiet while `run` is running. - **One `run` per driver.** If a colleague is already running the same driver on the same controller, starting a second `run` replaces their stub. ### Troubleshooting - **"Your sign-in has expired, so the driver can't start"**: run `driverforge login`, then `driverforge run` again. `run` needs a current sign-in to connect, and yours has expired or been revoked. - **"Couldn't reach Driverforge to start the driver"**: your machine couldn't reach Driverforge to set the run up. Check your connection and try again; there's no need to sign in again. - **"no Lua 5.1 interpreter found"**: install one (`brew install luajit`) or point `--lua` at one you already have. - **Nothing arrives after "Running. Ctrl+C to stop."**: the stub reaches the broker from the controller, so the controller needs outbound access to `ingest.driverforge.com:8883`, the same route the Anvil Agent uses. Check the agent's connectivity in the console. - **"can't relay over the local network yet"**: the controller's agent predates the local network path. `run` works through the broker; update the agent with [`driverforge upgrade`](/cli/upgrade) for the faster path. - **"mobdebug not installed"**: the Lua process couldn't load MobDebug, so it carried on without a debugger. Install it for the same Lua 5.1 interpreter ([step 1](#1-install-mobdebug-for-the-lua-that-run-uses)) and check that `LUA_PATH` and `LUA_CPATH` are set in the shell you run `driverforge` from. - **The debugger never connects**: start the debugger's server before `driverforge run --debug`, and check that the port matches (`--debug=host:port`). For a debugger on another machine, it must listen on all interfaces (`listenPublicly: true` in VS Code). - **Breakpoints aren't hit**: set them in your project's source files, the ones `run` loads, not in a built copy under `dist/`. - **You quit without deploying**: the stub is still installed, and does nothing. Run [`driverforge deploy`](/cli/deploy) whenever you're ready; the next `run` replaces it too. ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## deploy Build and deploy your driver to a controller without leaving the terminal or switching contexts. ### Usage ```bash driverforge deploy [options] ``` `deploy` builds your driver (respecting `-c/--configuration`, including the configuration's [defaults](/cli/build-configuration#per-configuration-defaults) from the project config), then sends the `.c4z` to the [Anvil Agent](/agent/overview) on the controller over a secure connection. The agent installs it and reloads the running driver for you. What you deploy is always your current source: there is no stale artifact to forget about. Every deploy **bumps the driver's version** per the project's [versioning scheme](/cli/versioning): Director only reloads a driver when it sees a higher ``, so each deploy consumes a version slot. The bump is persisted back to your `driver.xml` after the build succeeds. The command prints the version it deployed. Pass it to [`driverforge logs --version`](/cli/logs#versions) (and `errors` and `events`) to read back exactly what that deploy reported. Navigators cache each driver's UI schema. After a first deploy or a structural change to `driver.xml` (such as screens, tabs, properties, or actions), deploy automatically refreshes them so they load the new UI. Use `--refresh-navigators` to force the refresh when `driver.xml` is unchanged. ### Prerequisites - The project is [initialised](/cli/init) (`driverforge init`) - You're [signed in](/cli/login) (`driverforge login`) - A target controller is [selected](/cli/device) (`driverforge device select`) - The [Anvil Agent](/agent/overview) is installed and running on the controller ### Options | Option | Description | | ----------------------- | ---------------------------------------------------------------------------- | | `--device` | Controller to deploy to (name, hostname, or id); overrides the selected one | | `--select` | Re-select the target controller before deploying | | `--configuration`, `-c` | Build configuration to build and deploy | | `--refresh-navigators` | Refresh navigators even when `driver.xml` is unchanged | ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text ┃ ✓ Deployed version 20261105.2 ┃ ┃ driver poolpump ┃ version 20261105.2 ┃ artifact dist/poolpump.c4z ┃ controller Living Room ``` **Structured** Progress is abbreviated: the build's own steps come first. `state` is `confirmed` once the driver restarts; `confirmed_with_errors` when its init handler threw (`report_url` links to the error); `unconfirmed` when the controller didn't report back in time. stdout: ```json { "action": "deploy", "reason": null, "build": { "driver": "poolpump", "configuration": "default", "version": "20261105.2", "artifact": "dist/poolpump.c4z", "encrypted": false, "unpacked": null, "sourcemap": null, "warnings": [] }, "device": { "id": "9e8d7c6b-5a4f-4e3d-a2c1-b0a9f8e7d6c5", "name": "Living Room" }, "state": "confirmed", "version": "20261105.2", "report_url": null, "warnings": [] } ``` stderr: ```json {"progress": {"status": "running", "message": "Deploying to Living Room"}} {"progress": {"status": "ok", "message": "Build complete"}} {"progress": {"status": "running", "message": "Connecting to Living Room"}} {"progress": {"status": "ok", "message": "Connected to Living Room (Anvil Agent 1.0.0)"}} {"progress": {"status": "running", "message": "Uploading the driver"}} {"progress": {"status": "running", "message": "Waiting for Director"}} {"progress": {"status": "running", "message": "Restarting the driver"}} {"progress": {"status": "ok", "message": "Deployed version 20261105.2"}} ``` ### Examples Build and deploy to the selected controller: ```bash driverforge deploy ``` Build and deploy the `release` configuration to a specific controller: ```bash driverforge deploy --configuration release --device "Plant Room" ``` Force a navigator refresh without changing the driver's structure: ```bash driverforge deploy --refresh-navigators ``` ### First deploy The first time you deploy a new driver, it doesn't exist in the controller's project yet, so the CLI walks you through adding it. It guides you through choosing where in the project to create the device, naming it, and setting any property values the driver needs, then finishes the deploy. Every deploy after that updates the driver in place automatically. Prefer to set it up by hand? Add the driver to a room once in Composer Pro and run `driverforge deploy` again; the CLI picks up from there. Once it's deployed, read what the driver reports, using the version it printed: ```bash driverforge logs --version 2026110502 ``` ### Troubleshooting - **Agent unreachable**: the Anvil Agent isn't installed, isn't running, or can't be reached at the controller's address. See the [agent docs](/agent/overview). - **Agent out of date**: the agent on the controller is too old to accept a deploy. Update it with the [`driverforge upgrade`](/cli/upgrade) picker. - **Deploy failed**: the controller rejected the driver or it errored on init. When the agent captures an Anvil error report, the CLI prints a link to it. ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## logout Log out and remove your stored Driverforge credentials. ### Usage ```bash driverforge logout ``` ### What it does Revokes the stored credentials and clears your saved [organization](/cli/org) and [device](/cli/device) context. It's safe to run when you're already signed out. ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text ✓ Logged out. ``` **Structured** `revoked` is `false` if the session couldn't be revoked server-side; the local credentials are removed either way. stdout: ```json { "was_logged_in": true, "revoked": true } ``` ### Examples ```bash driverforge logout ``` ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## whoami Show the currently signed-in user. ### Usage ```bash driverforge whoami ``` ### What it does Prints the user you're signed in as, refreshing the access token first if it has expired. If you're not signed in, it tells you to run [`driverforge login`](/cli/login). ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text Jane Citizen (jane@example.com) token expires Thu, 05 Nov 2026 18:30:00 AEDT ``` **Structured** stdout: ```json { "user": { "id": "6a1f0c2e-9b7d-4e3a-8f21-0d5c4b3a2e10", "name": "Jane Citizen", "email": "jane@example.com", "session_expires_at": "2026-11-05T07:30:00Z" }, "organization": { "id": "c2d4e6f8-1a3b-4c5d-9e7f-8a6b4c2d0e1f", "name": "Acme Integration", "slug": "acme", "current": true } } ``` ### Examples ```bash driverforge whoami ``` ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## Versioning Control4 identifies a driver build by the integer `` in `driver.xml`, and Director only reloads a driver when it sees a **higher** number. `driverforge` manages that integer for you, using a versioning scheme you choose once during [`driverforge init`](/cli/init). ### The two schemes Your scheme is recorded in `.driverforge/config` when you initialise the project: **Date** is the default for new drivers. Versions are the date plus a two-digit sequence: `2026070501` is the first version of 5 July 2026. The first bump on a given day jumps to that day's `01`; later bumps the same day count up from there. The number always grows, reads as a date at a glance, and needs no bookkeeping. (Ship more than 99 times in a day and the sequence simply spills forward; it stays monotonic.) **Integer** is a plain counter: each bump adds one, preserving any zero-padding. This is what `driverforge init` proposes for an existing driver whose `` doesn't look like a date, so an established numbering scheme is never silently converted. The wizard states which scheme it detected before anything is written. ### When the version changes | Command | Effect on `` | | ------------------------- | ---------------------------------------------------------------------------------------------------------- | | `driverforge build` | Never changes it. The driver builds exactly as authored. | | `driverforge build --increment` | Bumps per your scheme, persisted to `driver.xml` after a successful build. | | `driverforge build --version N` | Stamps the exact value you give, persisted to `driver.xml` after a successful build. | | `driverforge sync` | Never changes it. A hot-swap updates the running instance without a reload. | | `driverforge deploy` | Bumps per your scheme. Director needs a higher version to reload, so every deploy consumes a version slot. | ### Uninitialised projects Plain `driverforge build` works on any driverpackager-style project with no account and no setup, and the version passes through exactly as authored. What [`driverforge init`](/cli/init) unlocks is version management and the ship commands: bumping needs a scheme, and the scheme is chosen during init. Without one, `--increment` stops with a friendly "Versioning not configured" pointing you at `driverforge init`, and [`sync`](/cli/sync)/[`deploy`](/cli/deploy) require an initialised project up front. `--version` is the exception: an explicit value needs no scheme, so it works anywhere, initialised or not. --- ## Organizations & devices The deploy commands act on a specific controller inside a specific organization. The CLI remembers both so you don't have to pass them every time: pick an **organization** with [`driverforge org`](/cli/org), then a target **device** (controller) with [`driverforge device`](/cli/device). Both require you to be [signed in](/cli/authentication). ### How the target is chosen When you run a controller-scoped command ([`deploy`](/cli/deploy), [`sync`](/cli/sync), [`upgrade`](/cli/upgrade)), the CLI resolves the controller in this order: 1. An explicit `--device ` flag 2. The remembered controller for the active organization 3. An interactive picker (when nothing is remembered) Pass `--select` to any deploy command to force the picker and re-choose. The CLI never silently picks a default: deploying to the wrong controller is risky, so the choice is always explicit. ### Reading telemetry [`logs`](/cli/logs), [`errors`](/cli/errors) and [`events`](/cli/events) read from the same remembered organization and controller, but never show a picker. Each part of their scope comes from a flag (`--org`, `--project`, `--device`), then a `DRIVERFORGE_ORG`/`DRIVERFORGE_PROJECT`/`DRIVERFORGE_DEVICE` variable, then the project's `.driverforge/config.json`, then the remembered selection. With no controller remembered they use your organization's only controller, and stop with a list to choose from when there are several. ### Why the IP, not the hostname A Control4 controller's hostname (e.g. `core1-000FFF…`) is an identifier, not a resolvable DNS name, so the CLI connects by IP address. Selecting a controller also pins its TLS certificate fingerprint, so the CLI can verify it's talking to the right one on later deploys. ### Commands - [`driverforge org`](/cli/org): choose the active organization (`list` / `select` / `show`) - [`driverforge device`](/cli/device): choose the target controller (`list` / `select` / `show`) ### In your prompt Using the [Spaceship prompt](/cli/spaceship)? A small zsh section can show the active org and controller right in your shell prompt, so you always know what a deploy will target. --- ## completion Generate a shell autocompletion script for `driverforge`, so commands, subcommands, and flags tab-complete. `driverforge completion` on its own does nothing; run the subcommand for your shell. ### Usage ```bash driverforge completion ``` ### Subcommands Each subcommand prints a completion script for that shell. Run `driverforge completion --help` for the authoritative, shell-specific install steps; the essentials are below. #### driverforge completion zsh ```bash driverforge completion zsh > "${fpath[1]}/_driverforge" ``` Ensure `autoload -U compinit && compinit` is in your `~/.zshrc`, then restart your shell. #### driverforge completion bash ```bash # current session source <(driverforge completion bash) # or persist it (requires bash-completion installed) driverforge completion bash > /etc/bash_completion.d/driverforge ``` #### driverforge completion fish ```bash driverforge completion fish > ~/.config/fish/completions/driverforge.fish ``` #### driverforge completion powershell ```powershell driverforge completion powershell | Out-String | Invoke-Expression ``` ### Output `completion` prints a shell script, so its output is the same text under a [coding agent](/coding-agents/skills/cli) or with `DRIVERFORGE_OUTPUT=json`. ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## version Print the `driverforge` CLI version and, when a controller is selected, the Director and Anvil Agent versions running on it. ### Usage ```bash driverforge version ``` With no controller selected, it prints just the CLI version. ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text Driverforge CLI 1.0.0 (commit 4f2a9c1, built 2026-11-05T02:14:09Z) Cloud 2026.11.05 poolpump Driverforge SDK 1.0.0 Living Room Anvil Agent 1.0.0 Director 4.0.0.1234 ``` **Structured** `cloud` is `null` when the service doesn't answer, and `driver` and `controller` are `null` outside a driver project or with no controller selected. A controller's `status` is `ok`, `unreachable` or `certificate_mismatch`; its versions are `null` unless it's `ok`. stdout: ```json { "cli": { "version": "1.0.0", "commit": "4f2a9c1", "date": "2026-11-05T02:14:09Z" }, "cloud": "2026.11.05", "driver": { "name": "poolpump", "sdk_version": "1.0.0" }, "controller": { "device": { "id": "9e8d7c6b-5a4f-4e3d-a2c1-b0a9f8e7d6c5", "name": "Living Room" }, "status": "ok", "agent_version": "1.0.0", "director_version": "4.0.0.1234" } } ``` ### `--version` The conventional flag works too, printing the same CLI version line and nothing else: ```bash driverforge --version ``` Unlike the subcommand, the flag never reaches out to a controller and skips the CLI's first-run prompts and update check entirely, so it is safe for scripts and shell prompts. Once you've [selected a controller](/cli/context) (`driverforge device select`), `version` also reaches that controller's [Anvil Agent](/agent/overview) (best-effort) and reports: - **Controller**: the controller's name - **Director**: the Control4 Director (OS) version - **Anvil Agent**: the agent version installed on the controller - **MAC**: the controller's MAC address If the controller can't be reached, that line reads `unreachable`; the CLI version is always printed regardless. ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## logs (Cli) Read your driver's log entries from the terminal, scoped to the controller and the exact version you just deployed. No copying them out of the web app. ### Usage ```bash driverforge logs [options] ``` `logs` prints the newest log entries your driver reported to Anvil, oldest first. Inside a driver project it needs no flags: it reads the project from `.driverforge/config.json` and the controller you chose with [`driverforge device select`](/cli/device). The usual loop after a change is to deploy, trigger the driver action, and read what the driver logged for that deploy only: ```bash driverforge deploy driverforge logs --version 2026110502 --until-match '"data"' --timeout 30s ``` `driverforge errors` and `driverforge events` work the same way, with the same options, for error occurrences and events. ### Prerequisites - You're [signed in](/cli/login) (`driverforge login`) - Your driver uses the Anvil SDK and the [Anvil Agent](/agent/overview) is installed on the controller, so there is telemetry to read ### Choosing what to read Each part of the scope is taken from the first place that sets it: 1. A flag: `--org`, `--project`, `--device` 2. An environment variable: `DRIVERFORGE_ORG`, `DRIVERFORGE_PROJECT`, `DRIVERFORGE_DEVICE` 3. The project's `.driverforge/config.json` (organization and project) 4. Your selected [organization and controller](/cli/context) A flag only affects that one run; it never changes your selection. With `--org`, `--project`, `--device` and `--version`, the command works anywhere, with no project and no saved selection, which is what CI needs. Without `--since`, a read searches as far back as your plan keeps telemetry, and so does `--version latest`. `--since` takes a duration such as `30s`, `10m` or `720h` (30 days), or an RFC 3339 time. The CLI never prompts here. If no controller is selected and your organization has more than one, the command stops and lists them so you can pass `--device`. #### Versions | `--version` | Reads | | ------------- | ----------------------------------------------- | | _(not given)_ | Every version | | `` | That driver version | | `latest` | The highest version the controller has reported | Pass the version `driverforge deploy` printed. `latest` may be another developer's deploy on a shared controller. Version filtering needs a driver built with an SDK that tags logs and events with their version. Entries from older SDKs have no version and only appear when you don't filter by one. ### Options | Option | Description | | --------------------- | ----------------------------------------------------------------------------- | | `--org` | Organization slug, name or id | | `--project` | Project slug, name or id | | `--device` | Controller name, hostname, hardware id or id | | `--version` | A version number or `latest` (see above) | | `--since` | Start of the window: a duration (`30s`, `10m`, `2h`) or an RFC 3339 time | | `--until` | End of the window, in the same forms | | `--tail` | How many of the newest entries to return (default 100, at most 1000) | | `--before` | Page back from the `next_cursor` of a previous response | | `--level` | Comma-separated levels, e.g. `warn,error` | | `--grep` | Regular expression matched against the message | | `--ignore-case`, `-i` | Make `--grep` case-insensitive | | `--correlation-id` | Only entries from one event (its trace id) | | `--field` | A `key=value` facet filter; repeatable. Keys: `controller`, `driver`, `level` | | `--until-match` | Wait until an entry matching this regular expression arrives | | `--min-events` | Wait until this many entries match | | `--timeout` | Longest wait (default 30s when waiting, at most 10m) | | `--follow`, `-f` | Stream entries as they arrive, until interrupted or `--timeout` | | `--output`, `-o` | `text`, `json` or `jsonl` | | `--max-payload-bytes` | Cap each entry's message and arguments (default 65536; `0` for no cap) | ### Waiting for output `--until-match` and `--min-events` turn a read into a wait: the command returns as soon as the condition is met, including by entries that had already arrived, and gives up after `--timeout`. It watches the same live stream the web app does, falling back to polling if the stream is unavailable, and never shows an entry twice. `--follow` streams every new entry until you press Ctrl+C. ### Output On a terminal the output is readable text, with the scope it used printed first. Piped, or run by a [coding agent](/cli/agents), it is JSON: one document with a `scope`, the `entries` and any `warnings`; with `--follow`, one JSON line per entry. Data goes to stdout and everything else to stderr, so you can pipe straight into `jq`. Messages are printed exactly as the driver logged them. A log's `payload` is `{"args": […], "argsTruncated": false}` when the log call was given anything but strings, and `null` otherwise: `args` holds the call's arguments as structured JSON, and `argsTruncated` is `true` when the SDK's size limits cut them (see [Tables and Other Values](/sdk/log-forwarding#tables-and-other-values)). As text, the arguments print as indented JSON under the log line. A message or arguments longer than `--max-payload-bytes` is cut, marked as truncated, and the command prints a [`driverforge get`](/cli/get) command that fetches the entry in full. #### Example **Interactive** ```text scope: org=acme project=poolpump device=Living Room version=20261105.2 2026-11-05T03:12:44.218Z INFO v20261105.2 ExecuteCommand playing episode 4812 ``` **Structured** The scope goes to stderr and the entries to stdout, so `jq` sees only the data. Structured, the scope is in the document itself; `count`, `has_more` and `next_cursor` page through larger results, and `wait` is added when the read waited on `--until-match` or `--min-events`. stdout: ```json { "scope": { "org": "acme", "project": "poolpump", "device": { "id": "9e8d7c6b-5a4f-4e3d-a2c1-b0a9f8e7d6c5", "name": "Living Room" }, "version": "20261105.2", "since": null, "until": null }, "entries": [ { "id": "0d2f6b1a-7c4e-4a39-9b85-3e1f0c7d2a64", "type": "log", "timestamp": "2026-11-05T03:12:44.218Z", "level": "info", "name": "ExecuteCommand", "message": "playing episode 4812", "payload": null, "status": null, "duration_ms": null, "error_id": null, "ref": null, "driver": "poolpump.c4z", "driver_version": "20261105.2", "device": { "id": "000FFF1A2B3C", "name": "Living Room" }, "correlation_id": "5b0e8c3a1f7d4e269a4c0b8d7e6f5a41", "truncated": null } ], "count": 1, "has_more": false, "next_cursor": null, "warnings": [] } ``` #### Warnings A read that succeeds can still carry warnings, each with a stable `code`: | Code | Meaning | | ---------------------- | ------- | | `no_entries` | Nothing matched the scope and filters. | | `retention_clamped` | `--since` reaches past your plan's retention; only the last `details.window_minutes` were searched. | | `tail_clamped` | `--tail` is over the maximum; the newest page was returned. Page further with `--before`. | | `payload_truncated` | Some entries were cut at `--max-payload-bytes`. Each is listed in `details.entries`; [`driverforge get`](/cli/get) fetches it in full. | | `device_not_reporting` | The controller hasn't reported to Driverforge for 5 minutes or more; `details.last_seen_at` is when it last did (RFC 3339, UTC). Empty results from a controller that isn't reporting say nothing about the driver: check the controller first. | A wait that times out on a controller that isn't reporting still exits `3`; its `wait_timeout` error carries `details.device_not_reporting: true` and `details.last_seen_at`, and its hint says to check the controller and its Anvil agent rather than to wait longer. ### Exit status | Status | Meaning | | ------ | ----------------------------------------------------------------------------- | | `0` | Success, including a read that found nothing | | `1` | Unexpected failure, or the connection dropped for over a minute | | `2` | A bad flag or value | | `3` | A wait ended at `--timeout` without its condition being met | | `4` | Not signed in, or the session expired | | `5` | The organization, project or device couldn't be resolved | | `6` | Rate limited | | `130` | Interrupted | ### Examples Read what the last deploy logged: ```bash driverforge logs --version 2026110502 ``` Read from a specific controller and version, with no project or selection: ```bash driverforge logs --org acme --project smart-tv --device bench-a --version 12 --tail 50 ``` Warnings and errors from the last ten minutes: ```bash driverforge logs --level warn,error --since 10m ``` ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## Authoring templates [`driverforge new`](/cli/new) creates a driver project from a template. The official templates cover a plain Control4 driver; your own let a team start every driver from the same structure, conventions and boilerplate. ### What a template is A template is a directory in a git repository holding a driver project: ``` driver-templates/ ├── thermostat/ │ ├── template.json │ └── src/ │ ├── ${slug}.c4zproj │ ├── driver.lua │ └── driver.xml └── pool-pump/ └── ... ``` It needs a `.c4zproj` manifest and a `driver.lua` that defines `OnDriverInit`, because that's what [`init`](/cli/init) wraps. Leave the Driverforge SDK out. `new` embeds the latest SDK when it runs `init`, so a copy in the template would only go stale. A repository can hold one template per directory, picked with `--template`, or be a single template itself, with its `template.json` at the root. ### Placeholders Placeholders are replaced in file contents and in file and directory names. Every template gets these, derived from the name passed to `new`: | Placeholder | `driverforge new My-Pool_pump` gives | | ----------- | ------------------------------------------------------ | | `${name}` | `My-Pool_pump`, as typed | | `${slug}` | `my-pool-pump` | | `${id}` | `my_pool_pump`, safe in Lua identifiers and file names | | `${title}` | `My Pool Pump` | | `${year}` | the current year | ```lua -- ${title}, copyright ${year} Acme ${id} = {} function OnDriverInit(strDIR) print("${title} starting") end ``` Write `$${` for a literal `${`. Placeholders use `${ }` rather than `{{ }}` because `{{` is ordinary Lua: a table nested in a table. A placeholder that isn't one of the built-ins or a variable the template declares fails the run, so a typo can't slip through into the generated project. Binary files, meaning any file containing a NUL byte, are copied untouched. ### template.json An optional `template.json` describes the template and declares the extra variables it accepts: ```json { "description": "Thermostat driver with a proxy binding", "variables": { "vendor": { "description": "Manufacturer name shown in Composer", "required": true }, "poll_seconds": { "description": "How often to poll the device", "default": "30" } } } ``` | Field | Description | | ------------- | ----------------------------------------------------------------- | | `description` | Shown when `new` fetches the template | | `variables` | A map of variable name to `description`, `default` and `required` | Each variable is used as `${vendor}`, `${poll_seconds}` and so on, and set with `--set vendor=Acme`. A variable that isn't set takes its `default`. A required variable with no default is asked for in a terminal, and without one must be passed with `--set`. An optional variable with no default is empty. Variable names are letters, digits and underscores, and can't redeclare the built-ins (`name`, `slug`, `id`, `title`, `year`). `template.json` itself isn't copied into the project. ### Trying a template Point `new` at your repository and branch, and skip `init` while you iterate: ```bash driverforge new scratch --repo https://gitlab.com/acme/templates.git#my-branch \ --template thermostat --set vendor=Acme --no-init ``` Then build the result with [`driverforge build`](/cli/build) to check the template produces a working driver. --- ## Build configuration `driverforge` gives your driver an opt-in **build configuration** system: committed Lua config files, with a named override swapped in at build time. It's a lot like Release/Debug builds in C++ or .NET: one default, plus named variants you select when you build. It's entirely optional. A driver can inline its settings (including its Anvil [project token](/platform/project-tokens)) directly and never use any of this. ### `config.lua`: your default Your driver's configuration lives in `src/config.lua`: a **committed, real** Lua file your driver loads with `require('config')`. It's the default configuration: the one a plain `driverforge build` uses as-is. Because it's a normal file on disk, your editor, linters, and the driver all resolve it without a build step. ### `config..lua`: named overrides To vary config per build, commit an override named `src/config..lua`, for example `src/config.release.lua`. Building with that configuration: ```bash driverforge build --configuration release # or: -c release ``` swaps `config.release.lua` in as `config.lua` **for that build only**, in a temporary work directory, so your source tree is never touched. If `src/config..lua` doesn't exist, the build stops and tells you. There's no separate default/`debug` file: the default configuration **is** `config.lua`, so there's no `--configuration debug`. ### Everything is committed and safe to commit `config.lua` and its overrides are committed, real files: nothing is generated and nothing is gitignored. That's safe because **config files hold no secrets**: your Anvil project token is a publishable value inlined directly in the driver (see [Project tokens](/platform/project-tokens)), not stored in config. This is deliberate. `config.lua` has to exist on disk for `require('config')`, your IDE, and your linter. Making it a real committed file, rather than a gitignored artifact that only appears after a build, keeps the project honest: what you see is what ships. ### Setting it up It's opt-in. [`driverforge init`](/cli/init) offers to set it up for you: it creates `src/config.lua` plus a `src/config.release.lua` override and wires `require('config')` into your driver. Decline, and you can inline your settings directly instead. ### Naming A plain build (the default configuration) keeps the driver's naked name (`my-driver.c4z`). A named configuration is suffixed so builds coexist: `driverforge build --configuration release` produces `my-driver-release.c4z` and adds a `(release)` suffix to the device name in Composer. That default is right for dev variants, but a release configuration usually wants the naked name: the artifact you ship shouldn't be decorated. A configuration can opt out of the suffixes with `suffix: false` in the project config (below) or per-invocation with `--no-suffix`. ### Per-configuration defaults If your project is [initialised](/cli/init), the committed `.driverforge/config.json` can attach defaults to a configuration, keyed by its name, so one flagless command produces the right artifact: ```json "configurations": { "release": { "encrypt": true, "suffix": false } } ``` | Key | Effect | | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | | `encrypt` | Default for script encryption: `true` always encrypts this configuration, `false` never does. Unset follows `driver.xml` as authored | | `suffix` | `false` builds the naked driver name: no `-` artifact suffix and no `(name)` device-name suffix. Unset/`true` keeps the standard suffixing | With that entry, `driverforge build -c release` alone produces an encrypted `my-driver.c4z`: no remembering `--encrypt` for the build that matters most. The defaults also apply when [`sync`](/cli/sync) or [`deploy`](/cli/deploy) build that configuration, so shipping produces the same artifact as building. **Precedence: flag → project config → authored source.** Explicit flags always win: `--encrypt=false` overrides `"encrypt": true`, and `--no-suffix=false` forces the suffix back on over `"suffix": false`. With no config file (or no entry for the configuration), nothing changes: the block is a defaults overlay, never a requirement. **The config file never defines what configurations exist.** That stays with the `config..lua` files: an entry here with no matching file is inert, and `-c ` without the file still stops the build. > **Caution: Suffix opt-out shares the default build's output path** > > A `suffix: false` configuration writes `dist/my-driver.c4z`: the same path as > a plain `driverforge build`. That's the point for a release configuration (the > shipped artifact gets the real name), but the two builds overwrite each other > in `dist/`. ### Related - [`driverforge build`](/cli/build): the `--configuration` flag - [`driverforge init`](/cli/init): opt into a build config - [Project tokens](/platform/project-tokens): why the token is safe to inline --- ## Telemetry This page is about the CLI's own usage metrics. To read your **driver's** telemetry, see [`driverforge logs`](/cli/logs). The CLI can collect **anonymous usage metrics** to help us improve it. It's opt-in: on first interactive launch, `driverforge` asks once whether you'd like to share them. ### What's collected If you opt in, the CLI records things like which commands you run, build timings, and errors, tagged with a random anonymous id. **No source code, file contents, or personal data is ever sent.** ### Opting out You can change your mind anytime by setting `DO_NOT_TRACK=1` (or `DRIVERFORGE_NO_METRICS=1`). Telemetry is also off automatically in CI and in non-interactive shells, where the consent prompt never appears. A [coding agent](/cli/agents) is never asked either; your existing choice stands. See also [Error reporting](/cli/error-reporting), which is separate and asks before sending each crash report. --- ## errors (Cli) Read your driver's error occurrences from the terminal, scoped to the controller and the exact version you just deployed. ### Usage ```bash driverforge errors [options] ``` `errors` lists individual error occurrences, oldest first, each with its message, error type, stack trace and the arguments of the event it was raised in. Occurrences are listed one by one, not grouped the way the web app's errors view groups them, so you see every time it happened. To read the group, run [`driverforge get `](/cli/get#error-groups) with the `ref` an error carries. It works exactly like [`driverforge logs`](/cli/logs): the same [scope rules](/cli/logs#choosing-what-to-read), [versions](/cli/logs#versions), [waiting and following](/cli/logs#waiting-for-output), [output](/cli/logs#output) and [exit statuses](/cli/logs#exit-status). ### Prerequisites - You're [signed in](/cli/login) (`driverforge login`) - Your driver uses the Anvil SDK and the [Anvil Agent](/agent/overview) is installed on the controller ### Options | Option | Description | | --------------------- | ------------------------------------------------------------------------ | | `--org` | Organization slug, name or id | | `--project` | Project slug, name or id | | `--device` | Controller name, hostname, hardware id or id | | `--version` | A version number or `latest` | | `--since` | Start of the window: a duration (`30s`, `10m`, `2h`) or an RFC 3339 time | | `--until` | End of the window, in the same forms | | `--tail` | How many of the newest occurrences to return (default 100, at most 1000) | | `--before` | Page back from the `next_cursor` of a previous response | | `--grep` | Regular expression matched against the message and the error's details | | `--ignore-case`, `-i` | Make `--grep` case-insensitive | | `--correlation-id` | Only errors raised in one event (its trace id) | | `--field` | A `key=value` facet filter; repeatable. Keys: `controller`, `driver` | | `--until-match` | Wait until an error matching this regular expression arrives | | `--min-events` | Wait until this many errors match | | `--timeout` | Longest wait (default 30s when waiting, at most 10m) | | `--follow`, `-f` | Stream errors as they arrive, until interrupted or `--timeout` | | `--output`, `-o` | `text`, `json` or `jsonl` | | `--max-payload-bytes` | Cap each error's details (default 65536; `0` for no cap) | ### What each error carries The error's message is the entry's `message`. Its `payload` holds the details as recorded: the error `type`, the `stacktrace`, the `args` of the event it was raised in, and the `lastLog` line the driver logged before it. The `correlation_id` is the trace id of that event, so you can pull everything around an error: ```bash driverforge logs --correlation-id ``` Its `ref` is the reference of the error group it belongs to, such as `POOL-PUMP-4F2A9C1B`, or `null` if its fingerprint can't form one. Pass it to [`driverforge get`](/cli/get#error-groups) for the group's history: how often the error has occurred, since when, and on which versions and controllers. To start from the latest error: ```bash driverforge errors --tail 1 driverforge get ``` ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text scope: org=acme project=pool-pump device=Living Room version=20261105.2 2026-11-05T03:12:44.231Z ERROR v20261105.2 ExecuteCommand POOL-PUMP-4F2A9C1B attempt to index a nil value (field 'episode') { "type": "lua:runtime_error", "stacktrace": "driver.lua:212: in function 'PlayEpisode'\ndriver.lua:88: in function 'ExecuteCommand'", "args": ["PLAY", {}], "lastLog": "playing episode 4812" } ``` **Structured** The scope goes to stderr and the entries to stdout, so `jq` sees only the data. Structured, the scope is in the document itself; `count`, `has_more` and `next_cursor` page through larger results, and `wait` is added when the read waited on `--until-match` or `--min-events`. stdout: ```json { "scope": { "org": "acme", "project": "pool-pump", "device": { "id": "9e8d7c6b-5a4f-4e3d-a2c1-b0a9f8e7d6c5", "name": "Living Room" }, "version": "20261105.2", "since": null, "until": null }, "entries": [ { "id": "8c1d3e5f-2a4b-4c6d-8e0f-1a3b5c7d9e2f", "type": "error", "timestamp": "2026-11-05T03:12:44.231Z", "level": "error", "name": "ExecuteCommand", "message": "attempt to index a nil value (field 'episode')", "payload": { "type": "lua:runtime_error", "stacktrace": "driver.lua:212: in function 'PlayEpisode'\ndriver.lua:88: in function 'ExecuteCommand'", "args": ["PLAY", {}], "lastLog": "playing episode 4812" }, "status": null, "duration_ms": null, "error_id": null, "ref": "POOL-PUMP-4F2A9C1B", "driver": "poolpump.c4z", "driver_version": "20261105.2", "device": { "id": "000FFF1A2B3C", "name": "Living Room" }, "correlation_id": "5b0e8c3a1f7d4e269a4c0b8d7e6f5a41", "truncated": null } ], "count": 1, "has_more": false, "next_cursor": null, "warnings": [] } ``` #### Warnings A read that succeeds can still carry warnings, each with a stable `code`: | Code | Meaning | | ---------------------- | ------- | | `no_entries` | Nothing matched the scope and filters. | | `retention_clamped` | `--since` reaches past your plan's retention; only the last `details.window_minutes` were searched. | | `tail_clamped` | `--tail` is over the maximum; the newest page was returned. Page further with `--before`. | | `payload_truncated` | Some entries were cut at `--max-payload-bytes`. Each is listed in `details.entries`; [`driverforge get`](/cli/get) fetches it in full. | | `device_not_reporting` | The controller hasn't reported to Driverforge for 5 minutes or more; `details.last_seen_at` is when it last did (RFC 3339, UTC). Empty results from a controller that isn't reporting say nothing about the driver: check the controller first. | A wait that times out on a controller that isn't reporting still exits `3`; its `wait_timeout` error carries `details.device_not_reporting: true` and `details.last_seen_at`, and its hint says to check the controller and its Anvil agent rather than to wait longer. ### Examples Errors from the last deploy: ```bash driverforge errors --version 2026110502 ``` Errors from the last ten minutes on one controller: ```bash driverforge errors --device bench-a --since 10m ``` Wait for an error after triggering an action, and fail if none arrives: ```bash driverforge errors --version 2026110502 --min-events 1 --timeout 60s ``` ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## device Manage the active deploy target: the Control4 controller that [`deploy`](/cli/deploy), [`sync`](/cli/sync), and [`upgrade`](/cli/upgrade) act on, and that [`logs`](/cli/logs), [`errors`](/cli/errors) and [`events`](/cli/events) read from. The CLI remembers it so you don't pass it every time. `driverforge device` on its own does nothing; run one of its subcommands. ### Usage ```bash driverforge device ``` ### Prerequisites - You're [signed in](/cli/login) (`driverforge login`) with an [organization](/cli/org) selected (`driverforge org select`) ### Subcommands #### driverforge device list List the controllers registered to your active organization; `*` marks the selected one. A controller registers itself when the [Anvil Agent](/agent/overview) is installed on it. ```bash driverforge device list ``` **Interactive** ```text NAME HOST STATUS * Living Room 192.168.1.40 ACTIVE Bench A 192.168.1.52 ACTIVE ``` **Structured** stdout: ```json { "devices": [ { "id": "9e8d7c6b-5a4f-4e3d-a2c1-b0a9f8e7d6c5", "name": "Living Room", "hardware_id": "000FFF1A2B3C", "hostname": "control4-ea3-000fff1a2b3c", "ip": "192.168.1.40", "status": "ACTIVE", "current": true }, { "id": "4c3b2a19-0f8e-4d7c-b6a5-948372615f0e", "name": "Bench A", "hardware_id": "000FFF4D5E6F", "hostname": "control4-ea1-000fff4d5e6f", "ip": "192.168.1.52", "status": "ACTIVE", "current": false } ] } ``` #### driverforge device select [name|id] Choose the active controller. Matches its friendly name, hostname, Control4 device id, or id. It shows a picker when given no argument. Only **active** controllers can be selected, and selecting one pins its TLS certificate fingerprint so later deploys verify they're talking to the right controller. ```bash driverforge device select "Living Room Controller" ``` **Interactive** ```text Using device: Living Room ``` **Structured** With no argument, there's no picker: it stops with `input_required`. Pass the controller to select. stdout: ```json { "device": { "id": "9e8d7c6b-5a4f-4e3d-a2c1-b0a9f8e7d6c5", "name": "Living Room", "hardware_id": "000FFF1A2B3C", "hostname": "control4-ea3-000fff1a2b3c", "ip": "192.168.1.40", "current": true } } ``` #### driverforge device show Print the active controller. ```bash driverforge device show ``` **Interactive** ```text Living Room ``` **Structured** stdout: ```json { "device": { "id": "9e8d7c6b-5a4f-4e3d-a2c1-b0a9f8e7d6c5", "name": "Living Room", "hardware_id": "000FFF1A2B3C", "hostname": "control4-ea3-000fff1a2b3c", "ip": "192.168.1.40", "current": true } } ``` #### driverforge device refresh-navigators Make the controller's navigators re-read cached driver UI schemas. Use this when a driver's screens or tabs look stale. A deploy refreshes navigators automatically after a structural `driver.xml` change; this command is the standalone option when you need to refresh them on demand. ```bash driverforge device refresh-navigators ``` Pass `--device ` to target a controller other than the selected one, or `--select` to choose the target again before refreshing. The controller agent must support navigator refresh; update it with [`driverforge upgrade`](/cli/upgrade) if it does not. See [Organizations & devices](/cli/context) for how the deploy target is resolved. ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## get Fetch one log, error or event by its id, with its full, untruncated payload, or an error group by its reference. ### Usage ```bash driverforge get [options] driverforge get [options] ``` [`logs`](/cli/logs), [`errors`](/cli/errors) and [`events`](/cli/events) cut any entry larger than `--max-payload-bytes` and print a ready-to-run `get` command for each one they cut. Run it to read that entry in full. Logs and errors have a UUID id; an event's id is its 32-character trace id. `get` works out which from the id, or you can say with `--type`. An error group is every occurrence of one error in a project, the same grouping the web app's errors view shows. Its reference is `-`, for example `POOL-PUMP-4F2A9C1B`: the label the web app shows and people quote, and the `ref` every error entry carries. A reference can't be confused with an id, so `get` recognises it in any casing without `--type`. The group is found however long ago it last occurred, as long as that's within your plan's retention. ### Prerequisites - You're [signed in](/cli/login) (`driverforge login`) ### Options | Option | Description | | --------------------- | ----------------------------------------------------------------- | | `--org` | Organization slug, name or id | | `--project` | Project slug, name or id | | `--type` | `log`, `error`, `event` or `error_group`, to skip working it out | | `--output`, `-o` | `text` or `json` | | `--max-payload-bytes` | Cap an entry's payload (default `0`: no cap). Entries only | The organization and project are chosen the [same way as for `logs`](/cli/logs#choosing-what-to-read). No controller is needed: an id is unique within the project. A reference names its project, so fetching a group needs no `--project` and works from any directory. A `--project` naming a different project, or `--max-payload-bytes` with a reference, is a usage error (`usage_error`). ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** ```text scope: org=acme project=poolpump device=Living Room 2026-11-05T03:12:44.201Z EVENT v20261105.2 ExecuteCommand ok { "args": ["PLAY", {}], "result": null } ``` **Structured** `get` returns one entry, untruncated, under `entry` rather than `entries`. stdout: ```json { "scope": { "org": "acme", "project": "poolpump", "device": { "id": "9e8d7c6b-5a4f-4e3d-a2c1-b0a9f8e7d6c5", "name": "Living Room" }, "version": null, "since": null, "until": null }, "entry": { "id": "5b0e8c3a1f7d4e269a4c0b8d7e6f5a41", "type": "event", "timestamp": "2026-11-05T03:12:44.201Z", "level": null, "name": "ExecuteCommand", "message": null, "payload": { "args": ["PLAY", {}], "result": null }, "status": "ok", "duration_ms": 31.4, "error_id": null, "ref": null, "driver": "poolpump.c4z", "driver_version": "20261105.2", "device": { "id": "000FFF1A2B3C", "name": "Living Room" }, "correlation_id": "5b0e8c3a1f7d4e269a4c0b8d7e6f5a41", "truncated": null }, "warnings": [] } ``` #### Error groups **Interactive** A short summary: the reference, type and count, then the message, when it was first and last seen, the versions and controllers it occurred on, the callback of the newest occurrence, and the command that fetches that occurrence. ```text scope: org=acme project=pool-pump POOL-PUMP-4F2A9C1B lua:runtime_error 37 occurrences driver.lua:212: attempt to index a nil value (field 'pump') first seen 2026-11-05T08:12:03.441Z, last seen 2026-11-07T21:47:55.018Z versions: 2026110501, 2026110502 devices: Living Room latest in: ReceivedFromProxy latest occurrence: driverforge get 6f1c2f9e-6c1a-4c39-9a51-0d4b8e1f2a3b --type error --org acme --project pool-pump ``` **Structured** A group comes back under `error_group`. stdout: ```json { "scope": { "org": "acme", "project": "pool-pump", "device": null, "version": null, "since": null, "until": null }, "error_group": { "ref": "POOL-PUMP-4F2A9C1B", "fingerprint": "4f2a9c1b", "type": "lua:runtime_error", "message": "driver.lua:212: attempt to index a nil value (field 'pump')", "count": 37, "first_seen": "2026-11-05T08:12:03.441Z", "last_seen": "2026-11-07T21:47:55.018Z", "driver_versions": ["2026110501", "2026110502"], "drivers": ["poolpump.c4z"], "devices": [{ "id": "000FFF1A2B3C", "name": "Living Room" }], "latest_event": "ReceivedFromProxy", "latest_stacktrace": { "frames": ["…"] }, "latest_occurrence": { "id": "6f1c2f9e-6c1a-4c39-9a51-0d4b8e1f2a3b", "command": "driverforge get 6f1c2f9e-6c1a-4c39-9a51-0d4b8e1f2a3b --type error --org acme --project pool-pump" } }, "warnings": [] } ``` | Field | Meaning | | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | | `ref`, `fingerprint` | The group's reference, and its fingerprint (the 8 hex characters) | | `type`, `message` | The error's type and message | | `count` | How many occurrences are still retained | | `first_seen`, `last_seen` | RFC 3339, UTC | | `driver_versions`, `drivers`, `devices` | Where it occurred. Each device is `{"id", "name"}`; `name` is `null` if the controller isn't registered to the organization | | `latest_event` | The callback the newest occurrence was raised in, or `null` | | `latest_stacktrace` | The newest occurrence's stack trace, as stored | | `latest_occurrence` | `{"id", "command"}`: a ready `get` command for the newest occurrence, with its arguments and last log. `null` when unknown | ### Examples ```bash driverforge get 6f1c2f9e-6c1a-4c39-9a51-0d4b8e1f2a3b driverforge get 0123456789abcdef0123456789abcdef --type event -o json driverforge get POOL-PUMP-4F2A9C1B ``` An id or reference that isn't in the project, or is older than your plan's retention, exits `1` with `entry_not_found`. ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## Overview (Cli) The Driverforge CLI (`driverforge`) is a single, dependency-free binary for Control4 driver development. It builds and packages drivers locally, and, once you're signed in, deploys them straight to a controller through the Anvil Agent, no manual Composer import required. ### What it does - **Build drivers**: Bundle Lua source with squish and produce a `.c4z` package, with optional script encryption and source maps - **Deploy**: Build your driver and push it to a controller through the Anvil Agent, watching it reload, without switching to Composer - **Sync**: Build and hot-swap a driver's Lua into the running instance for fast iteration, skipping the full reload - **Manage context**: Sign in once, then choose the organization and the target controller the deploy commands act on - **Read telemetry**: Read your driver's logs, errors and events for the version you just deployed, or wait for the next one to arrive - **Upgrade the agent**: Update the Anvil Agent running on a controller to the latest release ### Quick Start First, [install the CLI](/cli/installation) if you haven't already. Building is entirely local and needs no account. Deploying does: it acts on a real controller, so you sign in and pick a target first. ```bash # 1. Build a .c4z from the current project driverforge build # 2. Sign in (opens your browser) and choose an organization driverforge login # 3. Set up the project for Anvil (SDK, project link, versioning scheme) driverforge init # 4. Pick the controller to deploy to driverforge device select # 5. Build and deploy in one step driverforge deploy ``` ### Commands **Set up** - [`driverforge init`](/cli/init): Add Anvil to an existing driver project **Build & package** - [`driverforge build`](/cli/build): Bundle and package your driver - [Source maps](/cli/source-maps): Generate source maps for readable stack traces (`driverforge build -s`) **Deploy** - [`driverforge deploy`](/cli/deploy): Build and deploy your driver to a controller (full reload) - [`driverforge sync`](/cli/sync): Build and hot-swap your driver's Lua without a full reload **Account & context** - [`driverforge login`](/cli/login): Sign in to Driverforge - [`driverforge logout`](/cli/logout): Sign out and remove stored credentials - [`driverforge whoami`](/cli/whoami): Show the signed-in user - [`driverforge org`](/cli/org): Choose the active organization - [`driverforge device`](/cli/device): Choose the target controller **Read telemetry** - [`driverforge logs`](/cli/logs): Read or stream your driver's logs, scoped to a controller and version - [`driverforge errors`](/cli/errors): Read or stream your driver's error occurrences - [`driverforge events`](/cli/events): Read or stream the events your driver handled - [`driverforge get`](/cli/get): Fetch one log, error or event in full **Maintenance** - [`driverforge upgrade`](/cli/upgrade): Show and apply available upgrades (CLI, agent, SDK) - [`driverforge version`](/cli/version): Print the CLI version (and the selected controller's versions) - [`driverforge completion`](/cli/completion): Generate a shell autocompletion script **Coming soon** - [`driverforge run`](/cli/run): Run your driver locally against a real controller, with no build or deploy between changes, and an optional debugger Run `driverforge --help` (or `driverforge help `) for the full flags and usage of any command. ### Global Flags These apply to every command: | Flag | Description | | ------------------- | -------------------------------------------------------------------------------------------------------- | | `--verbose`, `-v` | Verbose output | | `--project-dir` | Driver project directory (default: current directory) | | `--no-tui` | Disable the interactive TUI and print plain output (also applied automatically when piped or under `CI`) | | `--no-update-check` | Don't check for a newer `driverforge` release after the command runs | | `--help`, `-h` | Show help for the command | Running under a coding agent? See [Coding agents](/cli/agents) for how the CLI adapts its output. `driverforge --version` (on the bare command) prints the CLI version and exits; see [`driverforge version`](/cli/version) for the richer report that includes the selected controller. --- ## org Manage the active organization: the workspace your projects, devices, and billing belong to. The CLI remembers it so the deploy commands don't need it every time. `driverforge org` on its own does nothing; run one of its subcommands. ### Usage ```bash driverforge org ``` ### Prerequisites - You're [signed in](/cli/login) (`driverforge login`) ### Subcommands #### driverforge org list List the organizations you can access; `*` marks the active one. ```bash driverforge org list ``` **Interactive** ```text NAME SLUG ROLE * Acme Integration acme OWNER Bench Labs bench-labs MEMBER ``` **Structured** stdout: ```json { "organizations": [ { "id": "c2d4e6f8-1a3b-4c5d-9e7f-8a6b4c2d0e1f", "name": "Acme Integration", "slug": "acme", "role": "OWNER", "current": true }, { "id": "1b3d5f7a-9c2e-4a6b-8d0f-2e4c6a8b0d1f", "name": "Bench Labs", "slug": "bench-labs", "role": "MEMBER", "current": false } ] } ``` #### driverforge org select [name|slug|id] Switch the active organization. Matches a slug, id, or exact name. It shows a picker when given no argument. ```bash driverforge org select acme ``` **Interactive** ```text Using organization: Acme Integration (acme) ``` **Structured** With no argument, there's no picker: it stops with `input_required`. Pass the organization to select. stdout: ```json { "organization": { "id": "c2d4e6f8-1a3b-4c5d-9e7f-8a6b4c2d0e1f", "name": "Acme Integration", "slug": "acme", "current": true } } ``` #### driverforge org show Print the active organization. ```bash driverforge org show ``` **Interactive** ```text Acme Integration (acme) ``` **Structured** stdout: ```json { "organization": { "id": "c2d4e6f8-1a3b-4c5d-9e7f-8a6b4c2d0e1f", "name": "Acme Integration", "slug": "acme", "current": true } } ``` See [Organizations & devices](/cli/context) for how the active org and device fit together. ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## init Set up Anvil in an existing Control4 driver project: embed the SDK, wrap `OnDriverInit`, link an Anvil project, and (optionally) add a build config. > **Warning: Modifies your driver project** > > `driverforge init` **modifies files in your driver project**; that's the point: > it embeds the SDK, wraps `OnDriverInit`, and writes config. It shows you a > per-file diff for approval (or, with `--dry-run`, before anything is created) > and backs up edited files before writing, but always review the changes before > committing. ### Usage ```bash driverforge init ``` Run it from inside an existing driver project: a directory with `src/manifest.c4zproj`. In a terminal it asks its questions as it goes. Every question also has a flag, so a [coding agent](/coding-agents/skills/cli) or a script can run it without a terminal (see [Without a terminal](#without-a-terminal)). `init` sets a project up exactly **once** and never mutates an initialised project (see [Running it again](#running-it-again)). SDK updates have one owner, the [`driverforge upgrade`](/cli/upgrade) picker. To start a new driver instead, [`driverforge new`](/cli/new) creates the project from a template and runs `init` in it. ### Prerequisites - An existing Control4 driver project - You're [signed in](/cli/login) (`driverforge login`) with an [organization selected](/cli/org) (`driverforge org select`) ### What it does `driverforge init` retrofits your driver for Anvil, walking you through: 1. **Embedding the Driverforge SDK** into your project (under `src/vendor/`): the newest locally cached SDK, or, if none is cached, it offers to download the latest. Updating it later is the [`driverforge upgrade`](/cli/upgrade) picker's job. 2. **Wrapping your driver's `OnDriverInit`** so Anvil initializes when the driver loads. 3. **Linking an Anvil project** (an existing one, or a new one it creates) and provisioning an [API key](/platform/project-tokens). 4. **Choosing a [versioning scheme](/cli/versioning)**: date-based for new drivers; for an existing driver the wizard inspects the current ``, proposes the matching scheme (date-shaped stays date, anything else becomes an incrementing integer), and states the choice before writing it. The scheme is what `--increment` and the ship commands bump with. 5. **Optionally setting up a [build config](/cli/build-configuration)**: a committed `src/config.lua` (your default configuration) plus a `src/config.release.lua` override, loaded by your driver via `require('config')` and swapped per build with [`driverforge build --configuration`](/cli/build). These are committed and hold no secrets (your Anvil key is inlined in the driver, not in config). 6. **Detecting a logger** in your entry file to forward log output from. 7. **Writing `.driverforge/config`**: a committed record of the integration (including your versioning scheme), with no secrets in it. Initialising is also what unlocks version management and the ship commands: [`sync`](/cli/sync) and [`deploy`](/cli/deploy) require an initialised project, and `build --increment` needs the versioning scheme recorded here. ### Review before anything is written Before changing a single file, `driverforge init` shows you a **per-file diff of every proposed change** and asks for approval. If your project is a git repository, it offers to create a branch first. Edited files are backed up to `.bak` while writing, and the changes are applied atomically: if anything fails, it rolls back. `--dry-run` shows the same plan and diffs and stops there: it creates no project and writes no files, so it runs on a working tree with uncommitted changes too. `--yes` applies the plan without the review and the final confirmation. ### Options Each flag answers one of the questions `init` would otherwise ask. In a terminal, any question without its flag is still asked. | Option | Description | | ----------------------- | ----------------------------------------------------------------------------------------------------------------- | | `--project` | Link an existing Anvil project: `/`, or a project slug | | `--create-project` | Create an Anvil project with this name for the driver to report to | | `--org` | The organization to create the project in (default: the active one), or to qualify a bare `--project` slug | | `--platform` | The new project's platform, by id or name (default: the only supported one) | | `--description` | The new project's description | | `--versioning` | How deploys bump ``: `date` (`YYYYMMDDNN`) or `integer`. See [versioning](/cli/versioning) | | `--build-configs` | Add the `config.lua` and `config.release.lua` [build configurations](/cli/build-configuration) | | `--no-build-configs` | Don't add build configurations | | `--logger` | Forward logs from this logger global, for example `Log` | | `--no-logger` | Don't forward the driver's logs | | `--branch` | Create this git branch and commit the changes to it | | `--no-branch` | Write the changes to the current branch, uncommitted | | `--commit-message` | The commit message on `--branch` (default `chore: add Anvil developer tooling support`). Empty leaves the changes uncommitted | | `--dry-run` | Report the plan and its diffs without creating or writing anything | | `--yes`, `-y` | Apply the plan without reviewing the changes | `--project` and `--create-project` can't be used together, nor can a flag and its `--no-` form, or `--dry-run` and `--yes`. `--platform` and `--description` only apply with `--create-project`, and `--commit-message` only with `--branch`. A conflicting combination fails as a usage error with exit status `2`. ### Without a terminal Under a coding agent, in CI, or with `--no-tui`, `init` can't ask, so every question needs its flag. Run it without them and it fails once, before any network call, with `input_required`. `details.missing` lists every flag still needed, and `details.detected` gives the versioning scheme and logger it found in the driver, to help choose the answers: ```bash driverforge init ``` ```json { "error": { "code": "input_required", "message": "driverforge init can't ask its questions without a terminal, and these weren't answered: --project or --create-project, --versioning, --build-configs or --no-build-configs, --logger or --no-logger, --branch or --no-branch, --dry-run or --yes.", "hint": "Pass them as flags (see `driverforge init --help`); preview with --dry-run before applying with --yes.", "details": { "missing": [ "--project or --create-project", "--versioning", "--build-configs or --no-build-configs", "--logger or --no-logger", "--branch or --no-branch", "--dry-run or --yes" ], "detected": { "versioning": "date", "logger": "Log" } } } } ``` `--org` is listed too when no organization is active, and `--branch or --no-branch` only when the project is in a git repository with at least one commit. If more than one platform is available, `--create-project` without `--platform` fails with `input_required` and lists the choices in `details.candidates`. Preview the plan, then apply it with the same answers: ```bash driverforge init --create-project "Pool Pump" --versioning date \ --no-build-configs --logger Log --branch driverforge-init --dry-run driverforge init --create-project "Pool Pump" --versioning date \ --no-build-configs --logger Log --branch driverforge-init --yes ``` Without a terminal, running `init` is consent to download the SDK into the local cache when no copy is cached; in a terminal it asks first. Creating a project counts against your organization's [plan](/platform/plans). When the plan has no room for another, `init` fails with `project_limit_reached` (exit status `6`); when the organization's subscription is suspended, it fails with `subscription_suspended`. ### Running it again `driverforge init` on an already-initialised project reports the existing setup as an advisory card and exits without touching anything: ``` ┃ This project is already set up for Driverforge. ┃ ┃ project Eight Sleep ┃ SDK 0.3.0 ┃ targets debug, release ┃ ┃ 💡 Run `driverforge upgrade` to update the embedded SDK. ``` In structured output, the result has `already_set_up: true` and describes the existing setup. The one exception: a config predating the [versioning scheme](/cli/versioning) field still gets the one-time versioning interview backfilled: a migration, not a setup change. If the setup has since been *broken* rather than merely already done (a reverted edit, a missing `src/vendor/`, a file that didn't survive a clone), that's [`driverforge doctor`](/cli/doctor). It checks each piece `init` puts in place and offers to restore what's gone. To update the embedded SDK, select the SDK row in the [`driverforge upgrade`](/cli/upgrade) picker. ### After setup ```bash driverforge deploy ``` If you set up a build config, review the committed `src/config.lua` (and any `src/config..lua` override), and build a named configuration with [`driverforge build --configuration release`](/cli/build). It's also worth reviewing the wrapped `OnDriverInit` in your driver's entry file. ### Output In a terminal the output is for reading. Under a [coding agent](/coding-agents/skills/cli), or with `DRIVERFORGE_OUTPUT=json`, the result is one JSON document on stdout and progress is one JSON object per line on stderr. **Interactive** Without `--yes`, `init` walks you through linking or creating the project, choosing a versioning scheme, and reviewing the per-file diff before anything is written. With `--dry-run`, it prints the diffs and the plan, then stops: ```text On apply, Driverforge will: • Create project "Pool Pump" (Control4) • Create git branch driverforge-init • Embed the Driverforge SDK • Write 3 file changes • Commit the changes ("chore: add Anvil developer tooling support") Dry run: nothing was created or written. Re-run with --yes to apply. ``` **Structured** `--dry-run` returns the plan, with each file's diff. `applied` is `false`, and a project it would create has no `id` or `slug` yet. The vendored SDK bundle is listed without a diff. stdout: ```json { "applied": false, "dry_run": true, "already_set_up": false, "org": { "slug": "acme", "name": "Acme Integration" }, "project": { "action": "create", "name": "Pool Pump", "platform": "control4" }, "sdk_version": "0.3.0", "versioning": "date", "build_configs": false, "logger": "Log", "branch": "driverforge-init", "commit_message": "chore: add Anvil developer tooling support", "changes": [ { "path": "src/vendor/driverforge-sdk.lua", "kind": "create" }, { "path": "src/driver.lua", "kind": "modify", "diff": "+ require('vendor.driverforge-sdk')\n function OnDriverInit(driverInitType)\n…" }, { "path": ".driverforge/config.json", "kind": "create", "diff": "+ {\n+ \"org\": \"acme\",\n…" } ], "warnings": [] } ``` With `--yes`, `applied` is `true`, `project` carries the `id` and `slug` of the project it created or linked (`action` is `create` or `link`), and `changes` lists the files it wrote: ```json { "applied": true, "dry_run": false, "already_set_up": false, "org": { "slug": "acme", "name": "Acme Integration" }, "project": { "action": "create", "id": "8f3c2a1e-5b7d-4e19-a6c2-0d4b9e7f1a23", "slug": "pool-pump", "name": "Pool Pump", "platform": "control4" }, "sdk_version": "0.3.0", "versioning": "date", "build_configs": false, "logger": "Log", "branch": "driverforge-init", "commit_message": "chore: add Anvil developer tooling support", "changes": [ { "path": "src/vendor/driverforge-sdk.lua", "kind": "create" }, { "path": "src/driver.lua", "kind": "modify", "diff": "…" }, { "path": ".driverforge/config.json", "kind": "create", "diff": "…" } ], "warnings": [] } ``` ### Global flags Every `driverforge` command also accepts these global flags: `--verbose`/`-v`, `--project-dir`, `--no-tui`, `--no-update-check`, and `--help`/`-h`. See the [overview](/cli/overview#global-flags) for details. --- ## Coding agents Coding agents such as Claude Code, Cursor, Gemini CLI and Codex can drive `driverforge` for you: deploy a change, trigger the driver, read what it reported, fix the code, and deploy again. The CLI recognises when an agent is running it and switches to agent mode: - **No prompts.** A command that would have asked a question stops with an error naming it, so the agent can pass the flag that answers it. - **Structured output.** Every command writes its result as JSON on stdout, and its progress as JSON lines on stderr. - **Errors an agent can act on.** Every failure carries a stable `code`, a `hint` naming the fix, and a documented exit status. Set `DRIVERFORGE_OUTPUT=json` to get the same structured output in your own scripts, or `DRIVERFORGE_AGENT_MODE=false` to turn agent mode off. Each command's page shows its output both ways. For the full contract, and how an agent puts the CLI to work, see [Coding Agents](/coding-agents/overview): - [Agents using the CLI](/coding-agents/skills/cli): detection, the output streams, error codes and exit statuses, and installing skills - [Available skills](/coding-agents/skills/available): what each skill teaches your agent, including the driver dev/test cycle: deploy, trigger, read, compare, repeat --- ## MCP tools These are the tools the [Anvil MCP server](/coding-agents/mcp/setup) offers. You don't call them yourself: your agent chooses them from what you ask. Knowing what they do helps you ask for the right thing. Every tool except `authenticate` and `auth_status` needs you to be [signed in](/coding-agents/mcp/setup#sign-in), and the telemetry tools only return data from projects your account belongs to. Every tool only reads: none of them changes a project, a device or a driver. Tools that take a `projectId` accept either the project's ID or its slug. All results are JSON. Apart from the two sign-in tools, a successful result carries `status: "ok"` and a failed one a [failure code](#when-a-tool-fails) in the same field. Every tool publishes an output schema describing its successful result, so an agent that supports structured tool output can read the result's shape before calling the tool. A successful result comes back as structured content that matches the schema, and as text for agents that don't read structured content. ### Signing in #### `authenticate` Signs the session in through your browser. The first call returns a link and a code for you to approve; calling it again once you've approved completes the sign-in. See [Sign in](/coding-agents/mcp/setup#with-the-authenticate-tool). Takes no inputs. #### `auth_status` Reports whether the session is signed in, and as whom. Takes no inputs. ### Organizations, projects and devices #### `list_organizations` Lists the [organizations](/platform/organizations) you belong to, with your role in each. Takes no inputs. #### `list_projects` Lists the Anvil projects you belong to, with each one's ID, slug, name, platform, organization, your role in it, and its [project token](/platform/project-tokens). Agents usually call this first to find the project you're talking about. Takes no inputs. #### `get_project` Returns the details of one project, including its project token. | Input | Required | Description | | ----------- | -------- | ------------------------- | | `projectId` | Yes | The project's ID or slug. | #### `list_devices` Lists an organization's [controllers](/platform/devices): each one's name, hardware ID, hostname, IP address, platform and status. Pass a device's name or hardware ID as `device` to the telemetry tools to read only that controller. Listing devices needs admin access to the organization. Without it, an agent can still read one controller's telemetry by passing its hardware ID as `device`. | Input | Required | Description | | -------------- | -------- | ----------------------------------------------------------------------------------------------- | | `organization` | No | The organization's slug, name or ID. Only needed when you belong to more than one organization. | #### `get_integration_guide` Returns step-by-step instructions for adding the [Driverforge SDK](/sdk/installation) to a driver, filled in with the project's own token. If your agent can run the CLI, the first step is [`driverforge init`](/cli/init), which does it all for you. This is what an agent uses when you ask it to set Anvil up in a driver. | Input | Required | Description | | ----------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | `projectId` | Yes | The project's ID or slug. | | `platform` | No | The target platform: `CONTROL4` or `SAVANT`. Defaults to the project's platform. Only Control4 is supported yet: `SAVANT` returns `platform_not_supported`. | ### Control4 documentation The server carries Snap One's DriverWorks documentation in full, synced daily from Snap One's published docs: the Lua API, driver XML, the fundamentals guide, and every proxy and protocol guide. When your agent writes or debugs a Control4 driver, it looks the API up here instead of relying on what it remembers. #### `search_control4_docs` Searches the documentation and returns the best-matching sections, each with a link to it on Snap One's site and the passages that matched. An API name (`C4:SendToProxy`) or a proxy command (`SET_SETPOINT_HEAT`) finds its section first. | Input | Required | Description | | --------------------- | -------- | -------------------------------------------------------------------------------------------------------------------- | | `query` | Yes | An API or command name, or a few specific words. | | `source` | No | Search one guide only: `api`, `fundamentals`, `xml`, `introduction`, or a proxy guide such as `proxyprotocol-tstat`. | | `limit` | No | How many sections to return. Defaults to 8; at most 20. | | `controllerOsVersion` | No | The oldest Control4 OS the driver supports, such as `3.3.1`: its `driver.xml` ``. | #### `get_control4_doc` Returns one section in full, as Snap One wrote it: signature, parameters, return value, version notes and examples. | Input | Required | Description | | --------------------- | -------- | ------------------------------------------------------------------------------ | | `id` | Yes | The section's ID, as `search_control4_docs` returned it. | | `maxBytes` | No | Cap the section's content. Defaults to 65536; `0` for no cap; at most 1048576. | | `controllerOsVersion` | No | The oldest Control4 OS the driver supports, as for `search_control4_docs`. | #### Control4 OS versions Each section carries the OS version it became available in, when the documentation gives one (`versionIntroduced`). Pass `controllerOsVersion` and each section also says whether it's available on that version (`availableOnTarget`). Search lists what isn't available after what is, and both tools add a `requires_newer_os` warning naming each section that needs a newer OS. Your agent is told not to use those unless the driver checks the OS version at runtime first. Version notes on single parameters or values stay in the section content. ### Events #### `list_events` Lists the [events](/platform/events) a project recorded, newest first: every Control4 callback your driver handled, with its status, driver version, controller, duration, arguments and result. This is how an agent finds out what your driver actually did, and which callbacks Control4 called in what order. Takes the [shared scoping inputs](#scoping-telemetry-reads) (`limit` defaults to 25, at most 500; `timeRangeMinutes` defaults to 15), plus: | Input | Required | Description | | ------------ | -------- | ----------------------------------------------------------------- | | `eventNames` | No | Only callbacks with one of these names, such as `ExecuteCommand`. | | `statuses` | No | Only events with one of these statuses. | | `traceId` | No | Only the event with this `traceId`. | #### `get_event` Returns one event with every log line it produced, in order: the arguments the handler received, the result it returned, its status, and what it logged along the way. | Input | Required | Description | | ----------- | -------- | ---------------------------------------------------- | | `projectId` | Yes | The project the event belongs to. | | `traceId` | Yes | The event's `traceId`, as returned by `list_events`. | Nothing is cut, so this is also where an agent goes after `list_events` warns `payload_truncated`. ### Logs #### `list_logs` Lists the [log lines](/platform/logs) a project recorded, newest first, so the agent can read your driver's output without you pasting it in. Takes the [shared scoping inputs](#scoping-telemetry-reads) (`limit` defaults to 100, at most 1000; `timeRangeMinutes` defaults to 15), plus: | Input | Required | Description | | --------------- | -------- | --------------------------------------------------------------------- | | `levels` | No | Only lines at one of these levels, such as `ERROR`, `WARN` or `INFO`. | | `messageSearch` | No | Only lines whose message contains this text. Not case-sensitive. | | `traceId` | No | Only lines emitted during the event with this `traceId`. | #### `get_log` Returns one log line whole, by the ID `list_logs` gave it. Nothing is cut, so this is where an agent goes after `list_logs` warns `payload_truncated`. | Input | Required | Description | | ----------- | -------- | ---------------------------------------------- | | `projectId` | Yes | The project's ID or slug. | | `id` | Yes | The log line's ID, as `list_logs` returned it. | ### Errors #### `list_errors` Lists the [errors](/platform/errors) a project recorded, grouped by cause and most frequent first. Each one carries the reference to pass to `get_error`. Scoped to a `driverVersion`, `device` or `since`, a group's count and affected drivers and versions cover only the occurrences in that scope. Takes the [shared scoping inputs](#scoping-telemetry-reads) (`limit` defaults to 25, at most 100; `timeRangeMinutes` defaults to 1440). #### `get_error` Returns everything Anvil knows about one error, found by the reference shown against it in Anvil, such as `POOLPUMP-4F2A9C1B`. Paste a reference into your agent and it can investigate from there. The result includes: - the error's type and message - how many times it has happened, and when it was first and last seen - the drivers, driver versions and controllers it affected - the most recent occurrence's stack trace, mapped back to your source where you've uploaded a [source map](/cli/source-maps) - the arguments the failing handler was called with - the logs emitted during the same event | Input | Required | Description | | ----- | -------- | ---------------------------------------- | | `ref` | Yes | The error reference. Not case-sensitive. | #### `list_error_occurrences` Lists each time a handler threw, newest first, rather than grouping them: the message, the callback it was raised in, its arguments and the last log line before it. Scoped to a `driverVersion`, it answers "did my change raise any errors?". Takes the [shared scoping inputs](#scoping-telemetry-reads) (`limit` defaults to 25, at most 500; `timeRangeMinutes` defaults to 1440), plus: | Input | Required | Description | | --------- | -------- | -------------------------------------------------------- | | `traceId` | No | Only errors raised during the event with this `traceId`. | #### `get_error_occurrence` Returns one error occurrence whole, by the ID `list_error_occurrences` gave it: the message, the callback it was raised in, its arguments, the last log line before it and its stack trace, mapped back to your source where you've uploaded a [source map](/cli/source-maps). Where `get_error` reads the whole error, this reads one time it happened. Nothing is cut, so this is also where an agent goes after `list_error_occurrences` warns `payload_truncated`. | Input | Required | Description | | ----------- | -------- | ------------------------------------------------------------- | | `projectId` | Yes | The project's ID or slug. | | `id` | Yes | The occurrence's ID, as `list_error_occurrences` returned it. | ### Waiting for an action #### `wait_for_telemetry` Waits until logs, events or error occurrences matching a condition arrive, then returns them, oldest first. Instead of you pasting logs after you press a button, the agent records the time, asks you to press it, and waits: 1. The agent notes the current time. 2. It tells you what to do on the controller. 3. It calls `wait_for_telemetry` with that time as `since`, and returns as soon as the entry arrives. The result lists the matching `entries`, oldest first, with their `count` and the scope that was read (`project`, `device`, `driverVersion`, `since`), plus a `wait` block: | Field | Meaning | | ---------------- | ---------------------------------------------------------------------------- | | `wait.satisfied` | Whether the condition was met before the timeout. | | `wait.reason` | `condition_met`, `timeout`, or `cancelled` when your agent stopped the wait. | | `wait.elapsedMs` | How long it waited. | | `wait.polls` | How many times it read. | Unlike the list tools, the result has no `warnings` or `windowMinutes`. An entry cut at `maxPayloadBytes` still lists what was cut in its own `truncated` field: fetch it whole with `get_event`, `get_log` or `get_error_occurrence`. While it waits, the server sends progress notifications to agents that ask for them. Takes `projectId`, `device` and `driverVersion` as in [Scoping telemetry reads](#scoping-telemetry-reads), plus: | Input | Required | Description | | ----------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `kind` | Yes | What to wait for: `logs`, `events` or `errors`. | | `since` | Yes | Where to start looking: usually the time noted before the action. | | `match` | No | Wait for entries containing any of these strings, anywhere in the entry. Not case-sensitive, and not regular expressions. Up to 10 strings of up to 200 characters. Omit to count every entry. | | `minCount` | No | How many matching entries to wait for. Defaults to 1; at most 100. | | `timeoutSeconds` | No | The longest to wait. Defaults to 30; at most 120. | | `eventNames` | No | For `events`: only callbacks with one of these names. | | `levels` | No | For `logs`: only lines at one of these levels. | | `traceId` | No | Only entries from the event with this `traceId`. | | `maxPayloadBytes` | No | Cap each entry's message or payload. Defaults to 16384; `0` for no cap; at most 1048576 (1 MiB). | ### Scoping telemetry reads `list_events`, `list_logs`, `list_errors` and `list_error_occurrences` share these inputs, so an agent can scope every read the same way. | Input | Description | | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `projectId` | Required. The project's ID or slug. | | `device` | Only telemetry from this controller: its name, hostname, hardware ID or ID. | | `driverVersion` | Only telemetry from this driver version: the version your deploy returned, or `latest` for the highest version in the newest telemetry. Someone else may deploy to the same controller, so a version number is safer than `latest`. The server can't see your deploys, so `current` is rejected. | | `since` | Where the window starts: a duration back from now (`30s`, `10m`, `2h`, `1d`) or a time with a timezone, such as `2026-11-05T09:00:00Z` or `2026-11-05T19:00:00+10:00`. A time in the future is rejected. Takes precedence over `timeRangeMinutes`. | | `timeRangeMinutes` | How far back to look, in minutes, when `since` isn't given. At most 129600 (90 days). | | `drivers` | Only entries from one of these drivers, such as `poolpump.c4z`. | | `controllers` | Only entries from one of these controllers, by hardware ID. `device` takes precedence. | | `limit` | The most entries to return. | | `cursor` | Fetch the next, older page: pass `nextCursor` from the previous result. | | `maxPayloadBytes` | Cap each entry's message or payload at this many bytes. Defaults to 16384; `0` for no cap; at most 1048576 (1 MiB). | Each result reports the scope it actually read (`project`, `device`, `driverVersion`, `since`) and `windowMinutes`, the look-back that was searched. Your [plan's retention](/platform/plans) can make that shorter than you asked for. Results can carry warnings, each with a stable `code`: | Code | Meaning | | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | `no_entries` | Nothing matched the scope and filters. | | `retention_clamped` | The window reached past your plan's retention, so older entries weren't searched. | | `payload_truncated` | Some entries were cut at `maxPayloadBytes`. Each is listed by ID; `get_event`, `get_log` or `get_error_occurrence` fetches it whole. | ### When a tool fails A call that can't return what was asked is marked as an error, and its result carries a stable code in its `status` field and a `message` saying what to do next. A failed result comes back as text only; the output schemas describe successful results. Any tool that needs sign-in can return: | Code | Meaning | | --------------------- | ------------------------------------------------------------------------------------------------------- | | `auth_required` | The session isn't signed in, or its sign-in expired. [Sign in](/coding-agents/mcp/setup#sign-in) again. | | `rate_limited` | Too many requests. Wait `retryAfterMs`, then narrow the query. | | `access_denied` | Your account can't see this. | | `service_unavailable` | Anvil couldn't load the data. Try again. | The telemetry tools (`list_events`, `list_logs`, `list_errors`, `list_error_occurrences` and `wait_for_telemetry`) check their scope first: | Code | Meaning | | ------------------- | --------------------------------------------------------------------------------- | | `project_not_found` | No project you can access matches `projectId`. | | `device_not_found` | No controller matches `device`. Without admin access, pass its hardware ID. | | `device_ambiguous` | More than one controller matches `device`. `candidates` lists their hardware IDs. | | `invalid_since` | `since` isn't a duration or a time with a timezone, or it's in the future. | | `invalid_version` | `driverVersion` isn't a version, or it's `current`. | | `no_versions_seen` | `driverVersion` is `latest`, but no telemetry carries a driver version yet. | Other tools have their own: | Code | Tool | Meaning | | ------------------------ | ----------------------------------------------------------- | ----------------------------------------------------------------------------- | | `project_not_found` | Any tool that takes `projectId` | No project you can access matches it. | | `not_found` | `get_event`, `get_log`, `get_error_occurrence`, `get_error` | Nothing in the project has that ID or reference. | | `invalid_id` | `get_log`, `get_error_occurrence` | The ID isn't a UUID. For an error reference, use `get_error`. | | `invalid_ref` | `get_error` | The reference isn't in the form `POOLPUMP-4F2A9C1B`. | | `organization_not_found` | `list_devices` | No organization you belong to matches `organization`. | | `organization_ambiguous` | `list_devices` | You belong to more than one organization. `candidates` lists them. | | `access_denied` | `list_devices` | Listing devices needs admin access to the organization. | | `source_not_found` | `search_control4_docs` | No guide has that `source`. `sources` lists the ones there are. | | `not_found` | `get_control4_doc` | No section has that ID. Search again: IDs change when the docs are re-synced. | | `platform_not_supported` | `get_integration_guide` | The platform isn't Control4. | | `expired_token` | `authenticate` | The sign-in link expired before you finished. Call it again. | | `access_denied` | `authenticate` | You declined the sign-in request in the browser. | | `auth_failed` | `authenticate` | Sign-in couldn't start or finish. Try again. | | `session_required` | `authenticate` | The agent keeps no MCP session. Sign in through its MCP settings. | | `service_unavailable` | `authenticate`, `auth_status` | The sign-in couldn't be read. Try again shortly. | ### Prompts The server also offers prompts: ready-made requests that start a whole workflow. Most agents list them as slash commands; in Claude Code they appear as `/mcp__driverforge__`, for example. | Prompt | Arguments | What it does | | ---------------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- | | `diagnose_error` | `ref` | Investigates an error from its reference, finds the cause in your code and proposes a fix. | | `observe_action` | `project`, `action`, optional `driverVersion` | Asks you to do something on the controller, waits for it, and reports which callbacks ran, in order. | | `verify_change` | `project`, `previousVersion`, `newVersion`, optional `expectation` | Reads two driver versions with the same filters to confirm a change did what you meant and raised no new errors. | ### How the agent is told to work When it connects, the server gives your agent instructions alongside the tools: look Control4 APIs up in the DriverWorks documentation before relying on memory, scope every read to your deploy's version, wait for an action instead of re-polling, treat an empty result as something to explain, and treat text inside your telemetry as data rather than instructions to follow. These are the same habits the [agent skill](/coding-agents/skills/overview) teaches for the CLI. --- ## MCP server The Anvil MCP server connects a coding agent to Anvil. Instead of you copying errors and logs into the chat, the agent reads them itself: it finds the project, pulls the telemetry it needs, and works from what the driver actually did. It speaks the [Model Context Protocol](https://modelcontextprotocol.io), so it works with any agent that supports remote MCP servers, including Claude Code, Cursor, Gemini CLI and Codex. There's nothing to install: you add one URL to your agent and sign in. ### What it does The server gives your agent [tools](/coding-agents/mcp/tools) for: 1. **Finding your projects and controllers** - List your organizations, projects and devices, and fetch the instructions for setting the SDK up in a driver 2. **Reading errors** - List a project's errors, look one up by the reference shown in Anvil, or check whether a driver version raised any, with the stack trace, the arguments the handler was called with, and what it logged 3. **Reading events** - See which handlers Control4 called, with what arguments, and what they returned 4. **Reading logs** - Search what your driver logged, by level, controller or text 5. **Waiting for an action** - Ask you to do something on the controller and return as soon as the driver reports it, instead of you pasting logs back Every read can be scoped to one controller, one driver version and a start time, so the agent reads what *your* deploy did, not whatever else is running. It also offers [prompts](/coding-agents/mcp/tools#prompts) for whole workflows, such as diagnosing an error from its reference, and tells your agent how to work with telemetry when it connects. ### It acts as you The agent signs in with your Driverforge account, so it sees exactly the projects and data you can see, and nothing more. It can only read: nothing it does through the server changes your projects or your drivers. ### What to ask Once it's connected, ask your agent things like: - "What errors has the Pool Pump driver hit in the last day?" - "Look into POOLPUMP-4F2A9C1B and fix it." - "I've just pressed Play on the touch screen. Did `ReceivedFromProxy` run, and what did it log?" ### When you'll want the CLI too The MCP server reads telemetry; it doesn't build or deploy. To let an agent ship a fix and confirm it worked, give it the `driverforge` CLI as well. See [Agent skills](/coding-agents/skills/overview). ### Next steps - [Set up the MCP server](/coding-agents/mcp/setup) in your agent - Browse the [tools](/coding-agents/mcp/tools) it offers --- ## Set up the MCP server The Anvil MCP server lets a coding agent read your Anvil data directly: the projects you belong to, and the errors, events and logs your drivers report. It speaks the [Model Context Protocol](https://modelcontextprotocol.io), so it works with any agent that supports remote MCP servers. The server lives at: ```text https://mcp.driverforge.com/mcp ``` It uses the Streamable HTTP transport. The agent acts as you, so it sees exactly the projects and data your Driverforge account can see, and nothing more. ### Connect your agent #### Claude Code ```bash claude mcp add --transport http driverforge https://mcp.driverforge.com/mcp ``` Add `--scope user` to make it available in every project rather than only the current one. #### Codex ```bash codex mcp add driverforge --url https://mcp.driverforge.com/mcp ``` Or add it to `~/.codex/config.toml` yourself: ```toml [mcp_servers.driverforge] url = "https://mcp.driverforge.com/mcp" ``` Then sign in with `codex mcp login driverforge`. #### Gemini CLI ```bash gemini mcp add --transport http driverforge https://mcp.driverforge.com/mcp ``` This adds it to the current project's `.gemini/settings.json`. Add `--scope user` to make it available in every project. To edit the settings file yourself, use `httpUrl`, not `url`, which Gemini CLI reserves for SSE servers: ```json { "mcpServers": { "driverforge": { "httpUrl": "https://mcp.driverforge.com/mcp" } } } ``` In a session, run `/mcp auth driverforge` to sign in. #### Cursor Add the server to `.cursor/mcp.json` in your project, or to `~/.cursor/mcp.json` to make it available in every project: ```json { "mcpServers": { "driverforge": { "url": "https://mcp.driverforge.com/mcp" } } } ``` #### VS Code (GitHub Copilot) Add the server to `.vscode/mcp.json` in your workspace. VS Code uses a `servers` key and needs the `type`: ```json { "servers": { "driverforge": { "type": "http", "url": "https://mcp.driverforge.com/mcp" } } } ``` To add it to your user profile instead, so it's available in every workspace: ```bash code --add-mcp '{"name":"driverforge","type":"http","url":"https://mcp.driverforge.com/mcp"}' ``` #### Other agents Most agents take a JSON entry in their MCP configuration file. Point it at the server URL: ```json { "mcpServers": { "driverforge": { "url": "https://mcp.driverforge.com/mcp" } } } ``` Where the file lives, and whether the agent needs a `type` or `transport` field alongside `url`, depends on the agent. Check its documentation for adding a remote, HTTP-based MCP server. ### Sign in The server needs to know who you are before it returns any data. There are two ways to sign in, and which one you use depends on your agent. #### In the browser, when the agent connects Agents that support MCP authorization, among them Claude Code, Codex, Gemini CLI and Cursor, find the server's sign-in endpoints themselves. The first time the agent connects, it opens your browser at the Driverforge sign-in page. Sign in, approve access, and the browser hands control back to the agent. In Claude Code, run `/mcp`, choose **driverforge** and select **Authenticate** if the browser doesn't open on its own. #### With the `authenticate` tool Any agent can sign in by asking the server, which works even where the agent has no built-in support for MCP sign-in. Ask your agent to "authenticate with Anvil". It calls the [`authenticate`](/coding-agents/mcp/tools#authenticate) tool, which returns a link and a code: 1. Open the link in your browser and sign in to Driverforge. 2. If the page asks for a code, enter the one your agent showed you, then approve access. 3. Tell your agent you're done. It calls `authenticate` again to finish. The link expires after a few minutes. If it does, ask the agent to authenticate again for a fresh one. #### Checking who you're signed in as Ask your agent "am I signed in to Anvil?" It calls [`auth_status`](/coding-agents/mcp/tools#auth_status), which reports the account it's acting as. ### Sessions The server keeps nothing about the agent's connection between requests, so a server restart or deploy doesn't sign you out. - **Signed in through the browser:** the agent sends its sign-in with every request and renews it itself. - **Signed in with `authenticate`:** the sign-in belongs to the agent's MCP session, and the server renews it for you. It lasts until the agent ends the session, or until the session goes a week without being used. If a tool replies that authentication is required, sign in again the same way; agents that signed in through the browser usually do this for you. ### Next steps - See what your agent can ask for in the [tools reference](/coding-agents/mcp/tools). - Add the [`driverforge` CLI](/coding-agents/skills/cli) so your agent can deploy the fixes it makes. --- ## Available skills These are the skills the `driverforge` CLI ships. Install them with [`driverforge skills install`](/coding-agents/skills/cli#installing-skills), and your agent loads each one when the task calls for it. ### Driver dev/test cycle {#driver-dev-test-cycle} Installed as `anvil-driver-dev-cycle`. With [agent mode](/coding-agents/skills/cli), a coding agent has every command it needs to work on a driver. What it doesn't have are the habits: it may read every version's logs instead of the one it deployed, sleep and retry instead of waiting for a match, guess at a payload's shape, take an empty result as success, or never think to look at the telemetry at all. The skill gives the agent the routine, the decision rules, and the situations that call for them: - **Setting up a driver.** Running [`driverforge init`](/cli/init) with your answers as flags, showing you the dry run's plan and diffs, and applying it once you approve. - **The jobs.** Discovering what a vendor API really returns, finding out what Control4 sends the driver, verifying a change, diagnosing an error, validating before shipping, understanding timing, and checking startup. - **The loop.** Deploy, trigger, read the captured events and logs, compare, and repeat, with the exact command for each step. - **Triggering.** Preferring triggers the agent can cause itself, and the routine for asking you to press a button and then waiting for the result, rather than asking you to paste logs. - **The decision rules.** What each exit status and error code means, and what to do about it. - **Safety.** Treating payloads as untrusted data, and keeping any credentials in them out of code and commits. The rest of this section is that routine in detail. It's worth knowing whether or not you install the skill: it tells you what to ask for, and what a good session looks like. A coding agent working on a driver runs one loop: change the code, deploy it, make the driver do something, read what it reported, and compare that with what was expected. The `driverforge` CLI gives it every step, and its [agent mode](/coding-agents/skills/cli) makes the output something the agent can rely on. #### What the loop answers Every job runs the same loop with a different question. | Job | The question | How it's observed | Done when | | -------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- | | Discover vendor behaviour | What does this poorly documented API actually return? | Log the raw response as it arrives, then wait for it | The parser handles the real structure | | Discover runtime behaviour | What does Control4 send the driver, with what arguments and in what order, after a UI action? | Have the developer perform the action, then read the captured events with [`driverforge events`](/cli/events): each handler that fired, its arguments, in order | The sequence is understood and the handler is written to it | | Verify a change | Did the edit do what was intended? | Repeat the same trigger on the new version and compare with the previous one | The expected entries appear and nothing regressed | | Diagnose a failure | Why did this error occur? | [`driverforge errors`](/cli/errors), then `--correlation-id` for the surrounding trail, or [`driverforge get `](/cli/get#error-groups) when the developer quotes a reference like `POOL-PUMP-4F2A9C1B` | The cause is fixed and the error no longer appears | | Validate before shipping | Does the driver behave across its scenarios with no new errors? | Scripted checks on entries and exit statuses | The checks pass locally and in [CI](/cicd/overview) | | Understand timing | What happens in what order, and how long does it take? | Event timestamps, durations and correlation IDs across a sequence | Order and latency are known | | Verify startup | What does the driver do when it loads? | Deploy, then read the `OnDriverInit` and `OnDriverLateInit` events and what they logged | Startup does what's intended and raises no errors | #### The loop 1. **Decide what to observe.** State the question first. The SDK already [captures every handler call](/sdk/automatic-capture) Control4 makes, with its arguments and result, so what the runtime sends the driver needs no extra code. Add [SDK logging](/sdk/manual-capture) only for what an event doesn't show, such as a vendor's raw response before it's parsed. 2. **Deploy.** Run [`driverforge deploy`](/cli/deploy) and keep the `version` it returns. Every read in the loop passes it as `--version `. Another developer can deploy to the same controller, so read your version by number rather than whatever is running. In a script, take it from the deploy's output: ```bash V=$(driverforge deploy | jq -r .version) # under an agent or with DRIVERFORGE_OUTPUT=json driverforge logs --version "$V" --until-match '' --timeout 30s ``` 3. **Trigger the action.** See [Triggering](#triggering) below. A deploy reloads the driver, so anything it does at startup needs no separate trigger. 4. **Read.** Wait for the expected entry, then check for errors: ```bash driverforge events --version --name ExecuteCommand --min-events 1 --timeout 30s driverforge logs --version --until-match '' --timeout 30s driverforge errors --version ``` For an event, what the handler received and returned is in `entries[].payload` as `{"args": …, "result": …}`. For a log, the text is in `entries[].message`, exactly as the driver logged it. 5. **Compare.** Set what happened against what was expected: the real payload against the parser's assumptions (an undocumented outer `data` wrapper, say), the callbacks that fired against the ones the code handles, or this version's entries against the previous version's. 6. **Adjust and repeat.** Edit, redeploy (which makes a new version), read again. Stop when the question is answered, then remove or lower any debug logging you added. #### Triggering The loop only works if something makes the driver act. Prefer a trigger the agent can cause on its own. | Trigger | Examples | What the agent does | | ----------------------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | | Driver-initiated | The reload on deploy (`OnDriverInit`, `OnDriverLateInit`), timers, polling | Deploys and reads. No one else is needed | | Controller or UI action | A button in the Control4 UI, a programming event, a room or device command | Only a person can do it. The agent tells you exactly what to do, then waits for it | | Vendor-initiated | The device or its cloud pushes an update | Causes it from the vendor side if it can, otherwise asks you | How a driver is usually exercised varies from driver to driver. A good agent looks for it in the driver's README or notes first, asks you once if it isn't written down, and suggests you record it so it doesn't have to ask again. ##### When you're the trigger When only a person can perform the action, the agent should: 1. Note the time before asking. 2. Tell you exactly what to do, and that it's waiting. It should never ask you to paste logs afterwards. 3. Wait once, for a bounded time, reading only what arrived after the time it noted: ```bash driverforge events --version --since