Linear: [CODAGT-1101](https://linear.app/codercom/issue/CODAGT-1101/agent-plugins-read-only-support-behind-the-agent-plugins-experiment) **tl;dr:** Adds the `agent-plugins` experiment and the Agent API v2.17 messages that carry Agent Plugins data from the agent to coderd. First of eight stacked PRs adding read-only [Agent Plugins](https://agent-plugins.org/) v1.0.0 support. A plugin is a directory with a `plugin.json` manifest, skills under `skills/`, and an optional `mcp.json`. Across the stack, the agent discovers plugins in `plugins/` and `.agents/plugins/` under its scan roots (for example `~/.coder/plugins/<name>`), chatd lists their skills with plugin attribution, the agent runs the MCP servers of plugins in the workspace working directory, and the Agents page shows plugin attribution in the chat context. Hooks, commands, agents, install flows, and org-managed plugins are out of scope. Background: [research/agent-plugins-standard.md](https://github.com/coder/scott-misc/blob/main/research/agent-plugins-standard.md) (internal). This PR adds `codersdk.ExperimentAgentPlugins` and a `PluginBody` oneof variant on `ContextResource` (tag 18) that carries the validated manifest fields and nests the plugin's skills and MCP servers. `Manifest` gains `agent_plugins_enabled` (field 23), which coderd sets when the experiment is enabled; the agent discovers plugins only then. coderd stores each nested resource as its own row with the plugin's name in a new `plugin_name` column (migration 000642), which the hydrate, MCP sync, and re-pin queries copy. With the experiment off, `PushContextState` drops plugin resources and everything nested in them. Otherwise it rejects pushes with plugin names that fail `workspacesdk.ValidatePluginName` (the spec's name grammar, shared by agent and coderd), OK plugins without a name or with a duplicate name, a non-OK plugin that nests resources, nested entries of the wrong kind, plugin skill sources outside `<plugin source>/skills/`, and plugin MCP servers with an empty `server_name` or a source other than `<plugin name>/<server_name>`. Nested resources count toward the 1000-resource cap. Agents now dial v2.17, so a new agent needs a coderd that supports it, as with every Agent API minor. Turning the experiment off does not remove plugin data already pinned to existing chats. <!-- pr-map:start --> <details><summary>PR map</summary> `main..4b0cfc9657` | Category | Files | + | - | |---|---:|---:|---:| | prod (backend) | 15 | 342 | 78 | | test (backend) | 9 | 534 | 3 | | migrations | 2 | 14 | 0 | | generated (backend) | 7 | 1216 | 1027 | | generated (frontend) | 1 | 2 | 0 | | **Total** | 34 | 2108 | 1108 | 1. `coderd/agentapi/context.go` (+211/-51, API): drops plugin resources when the experiment is off; otherwise validates plugin names and nesting, and stores each nested skill and MCP server as its own row with the plugin's name. 2. `agent/proto/agent.proto` (+39/-9, API): `PluginBody` with nested `skills` and `mcp_servers`, and `Manifest.agent_plugins_enabled`. 3. `codersdk/workspacesdk/frontmatter.go` (+31/-0): `ValidatePluginName` and `MaxPluginNameLength` (manifest name grammar). 4. `coderd/database/queries/chats.sql`, `workspaceagentcontext.sql`, migration 000642 (+28/-7, DB): the `plugin_name` column on both context resource tables, copied by the hydrate, MCP sync, and re-pin queries. 5. `codersdk/agentsdk/agentsdk.go`, `agent/agent.go` (+18/-4, API): `Manifest.AgentPluginsEnabled` and `ConnectRPC217WithRole`; the agent dials v2.17. 6. `coderd/agentapi/api.go`, `manifest.go` (+4): the manifest flag follows the experiment. 7. `tailnet/proto/version.go` (+8/-1, API): Agent API v2.17. 8. `codersdk/deployment.go` (+4, API): the `agent-plugins` experiment. </details> <!-- pr-map:end --> --- This PR was generated by Coder Agents on behalf of @jscottmiller. Co-authored-by: Garrett Delfosse <delfossegarrett@gmail.com>
130 lines
5.0 KiB
Go
130 lines
5.0 KiB
Go
package proto
|
|
|
|
import (
|
|
"github.com/coder/coder/v2/apiversion"
|
|
)
|
|
|
|
// Version history:
|
|
//
|
|
// API v1:
|
|
// - retroactively applied name for the HTTP Rest APIs for the Agent and the
|
|
// JSON over websocket coordination and DERP Map APIs for Tailnet
|
|
//
|
|
// API v2.0:
|
|
// - Shipped in Coder v2.8.0
|
|
// - first dRPC over yamux over websocket APIs for tailnet and agent
|
|
//
|
|
// API v2.1:
|
|
// - Shipped in Coder v2.12.0
|
|
// - Added support for multiple banners via the GetAnnouncementBanners RPC on
|
|
// the Agent API.
|
|
// - No changes to the Tailnet API.
|
|
//
|
|
// API v2.2:
|
|
// - Shipped in Coder v2.13.0
|
|
// - Added support for network telemetry via the PostTelemetry RPC on the
|
|
// Tailnet API.
|
|
// - No changes to the Agent API.
|
|
//
|
|
// API v2.3:
|
|
// - Shipped in Coder v2.18.0
|
|
// - Added support for client Resume Tokens on the Tailnet API via the
|
|
// RefreshResumeToken RPC. (This actually shipped in Coder v2.15.0, but we
|
|
// forgot to increment the API version. If you dial for API v2.2, you MAY
|
|
// be connected to a server that supports RefreshResumeToken, but be
|
|
// prepared to process "unsupported" errors.)
|
|
// - Added support for WorkspaceUpdates RPC on the Tailnet API.
|
|
// - Added support for ScriptCompleted RPC on the Agent API. (This actually
|
|
// shipped in Coder v2.16.0, but we forgot to increment the API version. If
|
|
// you dial for API v2.2, you MAY be connected to a server that supports
|
|
// ScriptCompleted, but be prepared to process "unsupported" errors.)
|
|
//
|
|
// API v2.4:
|
|
// - Shipped in Coder v2.20.0
|
|
// - Added support for GetResourcesMonitoringConfiguration and
|
|
// PushResourcesMonitoringUsage RPCs on the Agent API.
|
|
// - Added support for reporting connection events for auditing via the
|
|
// ReportConnection RPC on the Agent API.
|
|
//
|
|
// API v2.5:
|
|
// - Shipped in Coder v2.23.0
|
|
// - Added `ParentId` to the agent manifest.
|
|
//
|
|
// API v2.6:
|
|
// - Shipped in Coder v2.24.0
|
|
// - Added support for CreateSubAgent RPC on the Agent API.
|
|
// - Added support for DeleteSubAgent RPC on the Agent API.
|
|
// - Added support for ListSubAgents RPC on the Agent API.
|
|
// - Add ORGANIZATION SharingLevel
|
|
//
|
|
// API v2.7:
|
|
// - Added support for ReportBoundaryLogs RPC on the Agent API for forwarding
|
|
// boundary audit logs to coderd.
|
|
//
|
|
// API v2.8:
|
|
// - Added support for pre-created sub agents on the Agent API.
|
|
// - Added support for UpdateAppStatus on the Agent API.
|
|
//
|
|
// API v2.9:
|
|
// - Added session_id and confined_process fields to
|
|
// ReportBoundaryLogsRequest on the Agent API.
|
|
// - Added sequence_number field to BoundaryLog on the Agent API.
|
|
//
|
|
// API v2.10:
|
|
// - Added PushContextState RPC on the Agent API for pushing
|
|
// resolved workspace context snapshots (instruction files,
|
|
// skills, MCP configs, MCP server tool lists) from the
|
|
// agent to coderd. Adds ContextResource, PushContextStateRequest,
|
|
// and PushContextStateResponse messages. The coderd handler
|
|
// ships as a stub returning Unimplemented; the agent push
|
|
// loop shuts down cleanly on that response so older coderd
|
|
// deployments remain interoperable. Real persistence,
|
|
// KindMCPServer provider, and chatd hydration land in
|
|
// CODAGT-569.
|
|
//
|
|
// API v2.11:
|
|
// - Added the session_counts map to Stats on the Agent API, deprecating
|
|
// the fixed session_count_* fields.
|
|
//
|
|
// API v2.12:
|
|
// - Added the client_session_id to TelemetryEvent.
|
|
// - Added client_session_id to Connection on the agent API, for logging the
|
|
// client's session ID in the connections table.
|
|
//
|
|
// API v2.13:
|
|
// - Added app_name and connection_method to Connection on the Agent API.
|
|
// Agents no longer send type.
|
|
//
|
|
// API v2.14:
|
|
// - Added resource_address (field 11) and dependencies (field 12) to
|
|
// WorkspaceAgentScript on the Agent API, with the
|
|
// WorkspaceAgentScriptDependency message. They carry each script's
|
|
// Terraform address and its resolved coder_script_order prerequisites
|
|
// in the manifest. Both are empty for unordered scripts.
|
|
// - A v2.14 agent runs start and stop scripts in dependency order.
|
|
// - Added rx_bytes and tx_bytes to Connection on the agent API.
|
|
//
|
|
// API v2.15:
|
|
// - Added SKIPPED and CANCELED to Timing.Status on the Agent API, for a
|
|
// lifecycle script that never ran because of a prerequisite and one the
|
|
// agent shut down before it finished.
|
|
// - A v2.15 agent reports skipped and canceled startup scripts.
|
|
//
|
|
// API v2.16:
|
|
// - Added template_id and template_name to Manifest on the Agent API.
|
|
// - A v2.16 agent exports them as CODER_WORKSPACE_TEMPLATE_ID and
|
|
// CODER_WORKSPACE_TEMPLATE_NAME.
|
|
//
|
|
// API v2.17:
|
|
// - Added the PluginBody variant to ContextResource on the Agent API, for
|
|
// Agent Plugins (agent-plugins.org). PluginBody carries the plugin's
|
|
// skills and MCP servers as nested ContextResources.
|
|
// - Added agent_plugins_enabled to Manifest on the Agent API. coderd sets
|
|
// it when the agent-plugins experiment is enabled.
|
|
const (
|
|
CurrentMajor = 2
|
|
CurrentMinor = 17
|
|
)
|
|
|
|
var CurrentVersion = apiversion.New(CurrentMajor, CurrentMinor)
|