mirror of
https://github.com/coder/coder.git
synced 2026-11-25 14:28:37 +08:00
0ea3f16dd3ff82cfcd7da2fdca7d1ea683e22357
3099
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
fa7cd62c8b |
feat: send RFC 8707 resource parameter on MCP server OAuth2 flows (#30651)
Coder's MCP OAuth2 client never sent the RFC 8707 `resource` parameter, which the MCP authorization spec requires on authorization and token requests. Authorization servers that enforce it cannot be connected: with Dagster+, discovery and dynamic client registration succeed, then the authorize request fails with "MCP OAuth requests must include resource". MCP server configs get an `oauth2_resource` field (migration 000618, admin-only in API responses, audited). Coder sends it on the authorize redirect, the authorization-code exchange, and token refresh. Refresh now goes through `clientcredentials` with `grant_type=refresh_token`, because `oauth2.Config` cannot add parameters to refresh requests; it keeps the same auth-style detection and error types, and adds no dependency. Auto-discovery fills the field with the most specific Protected Resource Metadata `resource` that covers the server URL, stored as advertised. As in the MCP SDKs, a resource covers URLs on its origin at or under its path, so `/mcp` covers `/mcp/` but `/mcp/` does not cover `/mcp`. URLs compare in RFC 3986 normal form (default ports, percent-encodings, dot segments, and an empty path as `/`), ports ignore leading zeros, IPv6 literals compare by address, and `%2F` stays inside its segment. Unlike the SDKs, a resource with a query, even an empty one, only covers a server URL with the same query. When none covers it, Coder uses the server URL with the scheme and host lowercased and user information and fragment removed, or sends no resource when that is not a valid resource indicator. An explicit value in the create request wins. Manual configurations send no `resource` unless an admin sets one, because some providers reject it (Microsoft Entra ID v2 fails with AADSTS901002). Values must be absolute RFC 3986 URIs without a fragment, user information, or an IPv6 zone identifier. The resource binds grants like the other OAuth settings: changing it deletes stored user tokens, and a callback whose config resource changed after the user started connecting returns 409 before the code is redeemed. The connect step records the resource in a callback-scoped cookie for that check. Discovery only runs when a configuration is created, so existing auto-discovered configurations, including the Dagster+ one that prompted this, keep an empty resource until an admin sets the new "Resource URL" field or re-creates the server.  ## Testing - Go: discovery (most specific match, path and trailing-slash boundaries, query matching including empty queries, equivalent ports, IPv6 literals, escapes, and dot segments including escaped ones, the normalized fallback and an invalid one, explicit override), validation (URI characters, brackets, IP literals, user information, trimming), grant deletion on change, clearing on an auth type change, redaction for members, refresh with and without a resource, the 409 when the resource changes mid-flow (the authorization server never receives the code), and a connect and callback flow against an authorization server that rejects requests without the resource. Each new test was checked to fail when the behavior it covers is broken, except two malformed IP literal hosts that Go's URL parser already rejects. - Vitest: the form round-trips the stored value, and clearing the field sends `""` on update. - Remote UAT through Coder Agents ([chat](https://dogfood.cdr.dev/agents/58695d5b-2112-400b-88f7-ab64c678f756)) on a test deployment with loopback MCP and authorization server mocks: - Round 1 on |
||
|
|
adcce66826 |
feat: load organization skills in chats (#30613)
## Stack Closes [CODAGT-1341](https://linear.app/codercom/issue/CODAGT-1341/support-organization-level-skills-in-coder-agents). This stack adds organization skills to Coder Agents: admins publish a skill once per organization, share it with groups or members, and chats in that organization load it next to personal and workspace skills. It replaces the 21-PR draft stack #30584 to #30604 with five PRs, bottom to top: 1. #30609 data model: one migration, queries, RBAC and dbauthz 2. #30610 organization skill API routes and the scope-neutral SDK 3. #30611 sharing ACL routes 4. #30612 settings UI: shared skills table, admin page, member section 5. **#30613** chats: chatd loading, `/` menu, docs (this PR) ## What changes This PR makes chats use organization skills: chatd adds the skills shared with the chat owner in the chat's organization to the skill index, `read_skill` loads them, the `/` menu offers them, and the docs describe the feature. **chatd** (`coderd/x/skills`, `coderd/x/chatd`): - New source `skills.SourceOrganization` (`"org"`). `MergeSkills(personal, organization, workspace)` sorts by name, then source. A name in one source keeps its bare alias; a name in more than one source gets a qualified alias in every source that has it (`personal/<name>`, `org/<name>`, `workspace/<name>`), so no source overrides another. `Lookup` returns `ErrSkillAmbiguous` for a bare name that matches several sources. - **Authorization (please review closely):** each turn, chatd reads organization skill metadata and bodies as the chat owner's real RBAC subject with their roles and groups (`chatOwnerSubject`), never as the chatd system actor, so per-skill ACLs apply. Disabled skills are skipped. A skill that is deleted, disabled, or no longer shared by the time `read_skill` runs is reported as not found. If the owner subject or the metadata can't be loaded, turn preparation fails with the error, as main now does for personal skills (#30492), instead of running the turn without organization skills. - `read_skill` loads personal and organization bodies through one `LoadStoredSkillBody` callback. An index description longer than 1,024 runes, the Agent Skills specification limit (`maxSkillIndexDescriptionRunes`), is cut to 1,023 runes plus an ellipsis so it stays within the limit; `read_skill` still returns the full skill. - Parse and lookup errors keep `%w` last on purpose: with `xerrors`, a `%w` that isn't last repeats the cause, so main's detail read "skill is too large: got N bytes, maximum is 65536 bytes: skill is too large". This stack returns the cause once (ThomasK33 asked about the order in review). **`/` menu** (`site/src/pages/AgentsPage`): the chat page fetches the chat organization's enabled skills (`organizationSkills(...)` from #30612's queries) next to personal ones. `utils/skillAliases.ts` (`resolveSkillTriggers`) follows `MergeSkills`: a personal or organization trigger is bare unless its name is in more than one source, then it becomes `/personal/<name>` or `/org/<name>`. While any list is unknown every trigger is qualified, because a qualified alias always resolves; workspace triggers are always qualified. Built-in `/clear` and `/compact` stay pending until every skill list is known, and a list with no data counts as unknown even after an error, so a failed fetch can't make a built-in run in place of a same-named skill. Disabled skills never shadow a built-in. **Docs:** `docs/ai-coder/agents/extending-agents.md` gains two sections, Organization skills (manage them, control who can use one, find the ones you can use) and How chats load stored skills (turning a skill on or off, skills with the same name). The admin page's organization picker shows only for a user who can view more than one organization's skills. The member "From your organizations" section shows one organization at a time with its own picker, starts on the default organization, and has Export all for the selected organization. The Enabled column is a switch for editors and a check or X otherwise. The settings table in `platform-controls/organizations.md` gains rows for organization and personal skills. ## Commits The first commit reproduces the reviewed chatd code from the old stack; the site and docs commits reapply the old layers on #30612's queries, and the rest are labeled trims or fixes. - `aa634eec94a` feat(coderd/x): load organization skills in chats. Reproduction of the old skill sources and chatd layers (old head `a1047f4986`). - `97945db4e86` test(coderd/x/skills): make `TestMergeSkills` (6 cases) and `TestLookup` (8 cases) table-driven; coverage is 100% before and after, with the same blocks. - `dde61cc5fe2` test(coderd/x/chatd): drop skill tests duplicated by the organization skills integration test `TestOrganizationSkillsFollowChatOwnerAccess`; the covered block set of the touched code is identical (348 of 506 blocks). - `aad14b2dd05` feat(site/src/pages/AgentsPage): show organization skills in the slash menu. The old alias helper and slash menu layers, applied cleanly on #30612's queries. - `712e272e140` test(site/src/pages/AgentsPage): trim duplicated slash menu tests and stories. Deletes `AgentChatPage.test.tsx` (177 lines; its assertions live in `submitChatTurn.test.ts` and `ChatMessageInput.test.tsx`), two duplicate `ChatMessageInput` cases, six of 17 `SkillsTriggerMenu` stories, and one disabled-skill fixture row from a `ChatMessageInput` story. - `232535e1011` docs(docs/ai-coder/agents): document organization skills. From the old docs layer, with the View line updated for #30612's read-only dialog and Download. - `62dbbd2dfd3` refactor(site/src/pages/AgentsPage): address frontend review on the slash menu. - `7349eac4389` Merge the updated settings-ui layer into chats. Brings in the #30610 and #30612 fixes; the merge has no changes of its own. - `0f84a30ec69` Merge the updated settings-ui layer into chats again, for #30612's read-only View fix; no changes of its own. - `fb37822f985` fix(coderd/x/chatd/chattool): keep truncated skill index descriptions within 1,024 runes. The cut now happens at 1,023 runes so the ellipsis fits; the existing `skill_test.go` assertion now expects 1,023 runes plus the ellipsis. - `1543666b584` docs(docs/ai-coder/agents): state the 1,023-character cut before the skill index ellipsis. - `96f1da47c9a` and `13f03d095ff` merge the updated settings-ui layer for #30612's cache and Skills link fixes; no changes of their own. - `b03c14c86de` and `41cc078b85a` merge the updated settings-ui layer; `b03c14c86de` moves the `AgentChatPage.tsx` and `ChatMessageInput.tsx` call sites, and their tests and stories, to #30612's split `organizationSkills(...)` query. - `1a32d05c9bc` test(site/src/pages/AgentsPage/components/ChatMessageInput): restore per-source loading stories for the slash menu. - `830b0466982` fix(coderd/x/chatd): fail turn preparation when organization skills cannot load. Main now returns database errors from turn preparation (#30492); organization skills still logged and dropped the failure, so a failed read silently hid them from the model. The new `TestFetchOrganizationSkillMetadataListFailure` covers the returned error. - `84c135f8801` and `a6f8f63ad13` merge the updated settings-ui layer, which brings in main; they resolve `generation_preparer.go` against main's turn preparation error handling. - `19b7880840f` merges #30612's member page test change; no changes of its own. - `c74d597f3c5` merges #30612's read-only status change; no changes of its own. - `f89c232c081` merges #30612's skills test changes; no changes of its own. - `17d5b9bfbc5` docs(docs/ai-coder/agents): describe the member skills organization picker and read-only Enabled status. - `f97b1710f71` merges the updated settings-ui layer (main at `e7b76872098`); no changes of its own. ## Size Production +558/-213 (docs +116/-6), tests +895/-262; total +1453/-475. This is above the 500-line reviewer-friendly limit on purpose: Mike asked for 4 to 5 PRs instead of the 21 small ones this stack replaces. ## Replaces #30593 (skill sources), #30594 (chatd), #30601 (alias helper), #30602 (slash menu), #30604 (docs). ## Validation - Go: all 21 packages under `coderd/x/skills` and `coderd/x/chatd` pass on `62dbbd2dfd3`, plus the coverage comparisons above; `coderd/x/chatd/chattool` passes again on `13f03d095ff` after the truncation fix. - Site: `pnpm run lint` and Biome clean; Vitest 102 tests; Storybook Vitest 49 + 4 tests. `pnpm run lint` reran clean on `13f03d095ff`. - On `a6f8f63ad13`, this PR's head before the test-only `19b7880840f` merge: `go test` passes for `coderd/x/skills`, `coderd/x/chatd/chattool`, and the `coderd/x/chatd` skill tests (`-run 'OrganizationSkill|Skill'`); 38 Vitest files covering skills and the slash menu pass, 542 tests with 2 skipped. - Docs: markdownlint 0 findings, Vale 0 findings. - On `17d5b9bfbc5`: Vale clean, markdownlint and `make pre-commit` pass. On `f97b1710f71`: `go build`, the `coderd/x/skills` and `chattool` tests, `pnpm check` and `tsc` pass. - Remote UAT round 7 through Coder Agents: PASS ([chat](https://dogfood.cdr.dev/agents/3426d4d3-2139-4ae1-8e0c-72ddeff413a8)). - Full run on `62dbbd2dfd3`, including an in-place upgrade from main `50c785cc6d7`: personal skills kept their IDs, names, content hashes and timestamps, came up enabled, and worked in chats (`read_skill`) and the `/` menu; create, edit, download and delete worked after the upgrade. The admin page, sharing, the Enabled toggle, the member section, the `/` menu, chats reading organization skills as the owner, limits, audit, authorization and scoped keys, and the docs all passed. - Delta run on `7349eac4389`: an update-only key gets 404 on PATCH with no content in the response; saving permissions refreshes Updated without a reload; smoke of the admin page, auditor View and Download, the `/` menu and `read_skill`. - Delta run on `0f84a30ec69` for `aaa356f0fd5`: read-only View, as an org auditor and as a member, shows no Name hint, focuses no field and starts on Close, and Escape or Close returns focus to the row menu button; Add skill and Edit still show the hint and focus the import field, and a saved edit persisted; smoke of the admin page, the `/` menu organization group and `read_skill`. Screen-reader behavior was not tested. - Delta run on `13f03d095ff` for `698dd83946d`, `f82573cd1c2`, `0e55137de7b` and `fb37822f985`: for an organization admin of org B who is a plain member of org A, the sidebar Skills link drops `?org=` for org A on seven AI settings pages and opens org B's skills, keeps `?org=` for org B, and a typed `/ai/settings/skills?org=` for org A still shows the permission error. A skill deleted and recreated with the same name loads a fresh sharing list showing only Everyone, with no stale grant. A 1,500-character description appears in the chat's skill index as 1,023 characters plus an ellipsis, while `read_skill` returns all of it. Smoke of the admin toggle, the member section, the `/` menu organization group and `read_skill`. - Low findings: the read-only View hint and field focus, fixed in `aaa356f0fd5` and verified by the delta run above. The member section's always-on disabled Enabled switch (also in the old stack) is replaced by a read-only status icon in #30612's `63bb42754e3`, which has no UAT run. Not fixed: `/` shows the `/personal/` prefix while organization skills fail to load (the unknown-list rule above); the shared Switch component's disabled styling (unchanged from main). A user who can read skills in only one organization sees no organization name on the Skills page, because the picker is hidden for a single organization, as on the MCP servers page on main. - Not tested: the workspace skills group (no running agent on the test deployment), the 100-per-user personal cap, and behavior without a Premium license. - Remote UAT round 8 through Coder Agents: PASS on `b03c14c86de` (same chat). The remote grader marked the unknown `read_skill` item FAIL only because the prompt asked for the literal phrase "skill not found"; the result names the skill once and says "not found" once, the same format as main, so the runner graded it PASS on intent. - Member page: starts on the default organization, shows one organization's table with the read-only note once, Export all downloads only the selected organization's skills, the picker is hidden with one organization, and an organization without enabled skills isn't listed. - Personal and admin tables: create, edit, toggle and delete each refetch the list; reopening the editor shows the new content even with the detail request delayed; a toggle changes state once, with no flicker. A skill deleted and recreated with the same name shows only Everyone in sharing. - The sidebar Skills link keeps `?org=` only for an organization whose skills the user can read. A create over 64 KiB returns 400 with the detail "got 70000 bytes, maximum is 65536 bytes: skill is too large", the cause once. The `/` menu shows Commands, Personal skills and Organization skills, and invoking an organization skill loads its body through `read_skill`. - New low findings, not fixed: the member page picker's listbox is labeled "Suggestions" (likely from the shared `OrganizationAutocomplete`); a typed body over 64 KiB shows only the size counter and a disabled Create until Import; `/ai/settings?org=` redirects to the models page without `?org=`. The first and third were not checked against main. - `9002dc60382`, `1a32d05c9bc`, `830b0466982`, `ac3e62c83b7`, `63bb42754e3`, `82b2487ad17`, `17d5b9bfbc5` and the main merges came after `b03c14c86de`; they have tests but no UAT run. - Every UAT round ran the migration as `000615_skills`. The heads ship the same up and down SQL as `000621_skills`, so the upgrade path from main's 000620 to 000621 has no UAT run. > Xum opened this PR on behalf of @ibetitsmike. |
||
|
|
2c432a12a3 |
feat: add organization skill sharing ACL routes (#30611)
## Stack Part of [CODAGT-1341](https://linear.app/codercom/issue/CODAGT-1341/support-organization-level-skills-in-coder-agents). This stack adds organization skills to Coder Agents: admins publish a skill once per organization, share it with groups or members, and chats in that organization load it next to personal and workspace skills. It replaces the 21-PR draft stack #30584 to #30604 with five PRs, bottom to top: 1. #30609 data model: one migration, queries, RBAC and dbauthz 2. #30610 organization skill API routes and the scope-neutral SDK 3. **#30611** sharing ACL routes (this PR) 4. #30612 settings UI: shared skills table, admin page, member section 5. #30613 chats: chatd loading, `/` menu, docs ## What changes This PR adds the routes that let admins choose who can read an organization skill. It reuses the MCP server ACL machinery rather than adding a second implementation. Routes under `/api/experimental/organizations/{organization}/skills/{skillName}`, all behind `httpmw.ExtractOrganizationSkillParam` with `share`, so a caller without share gets 404: - `GET /acl` returns the resolved user and group grants. - `GET /acl/available` returns the organization's users and groups that can be granted, with the same `q`, `after_id`, `limit` and `offset` paging as the MCP endpoint. - `PATCH /acl` takes a sparse `UpdateOrganizationSkillACLRequest`: only the listed principals change, `read` grants and `""` removes. It returns 204 and writes a `write` audit entry with the old and new ACL. **Concurrency (please review closely):** the PATCH transaction first locks the granted users' `organization_members` rows `FOR KEY SHARE` (new query `LockOrganizationMembersByUserIDsForShare`, run as system), then locks the skill row `FOR UPDATE`, then validates the update on the transaction handle. Member removal takes the same locks in the same order (its membership row, then the skill rows through the #30609 trigger), so the two can't deadlock, and a removal can't miss a grant written by a concurrent PATCH. A skill deleted between the middleware read and the row lock stays a 404. Grants are users and groups, the same as MCP server configs (Mike's decision, for parity). Only the `read` role exists; any other role is a validation error, as are users or groups outside the organization. Supporting changes: - `coderd/mcp_acl.go`: the MCP ACL handlers' resolution, candidate listing and validation move into generic helpers (`writeOrganizationACLAvailable`, `validateOrganizationACLUpdate`, `resolveACLUsers`, `resolveACLGroups`) shared by both resources; `acl.Validate` accepts a named `acl.Role` constraint that now includes `codersdk.OrganizationSkillRole`. - `codersdk/skills.go`: `OrganizationSkillRole`, `OrganizationSkillACL` with its user and group entries, `UpdateOrganizationSkillACLRequest`, and client methods. - New sqlc query `UpdateOrganizationSkillACLByID` with its dbauthz wrapper (requires `share`). ## Commits The first commit reproduces the reviewed code from the old stack; each later commit is a labeled trim or fix. - `b1c85560b69` feat: add organization skill sharing ACL routes. Reproduction: every file this commit changes equals the reviewed old `acl-routes` head `80c1c3594e6`; the rest of the tree differs only by #30609's migration merge and main. - `b5d2ee265c8` test(coderd): merge duplicate organization skill ACL route tests (+49/-111). The removed cases repeated `TestMCPServerConfigACL`, `TestMCPServerConfigACLAvailable` or `TestRolePermissions`; with the MCP tests included, the covered block set of `organizationskills_acl.go`, `mcp_acl.go` and `rbac/acl/updatevalidator.go` is identical before and after. Kept: `TestOrganizationSkillACL` (`OrgAdminManagesACL`, `ReadersGetNotFound`, `SparseUpdateChangesReaders` with the audit diff, `RejectsUnsupportedRole`, `ScopedAPIKeys`), `TestOrganizationSkillACLConcurrentDelete`, and the lock order tests `TestOrganizationSkillACLMemberRemoval` (`RemovalBeforeGrant`, `RemovalAfterGrant`). `OrgAdminManagesACL` now also checks that users from another organization are not candidates (mutation checked). Sharing the param extractor with MCP was skipped: it would save about 10 lines of security-sensitive code. - `e09c4dba66b` Merge the updated org-api layer into sharing. Brings in #30610's `ad0a7a37504`; the merge has no changes of its own. - `1d3817dc639` and `c8c88f84d18` merge the updated #30610 layer, including main; no changes of their own. - `c4d22c47990` merges the updated #30610 layer (main at `e7b76872098`); no changes of its own. ## Size Production +431/-102, tests +377/-0, generated +918/-0; total +1726/-102. This is above the 500-line reviewer-friendly limit on purpose: Mike asked for 4 to 5 PRs instead of the 21 small ones this stack replaces. ## Replaces #30591 (ACL queries), #30592 (ACL routes). ## Validation - `go build` and `go vet` passed; `make gen` exited 0 with no diff. - `go test` passed for `coderd` (skill, MCP and ACL tests), `coderd/database`, `dbauthz`, `migrations`, `gentest`, `coderd/rbac/...`, `coderd/httpmw`, `coderd/x/skills/...`, `coderd/x/chatd/...`, and the audit and skill tests in `enterprise/audit` and `enterprise/coderd`. - The covered block comparison above, before and after the test merge. - On `c4d22c47990`: the same checks as #30610's head, plus `go test ./coderd/ -run 'Skill|MCP|ACL'`, pass. - Remote UAT round 7 through Coder Agents passed on the whole stack; see #30613's Validation for scope and findings. > Xum opened this PR on behalf of @ibetitsmike. |
||
|
|
db7f5a7703 |
feat: add organization skill API routes (#30610)
## Stack Part of [CODAGT-1341](https://linear.app/codercom/issue/CODAGT-1341/support-organization-level-skills-in-coder-agents). This stack adds organization skills to Coder Agents: admins publish a skill once per organization, share it with groups or members, and chats in that organization load it next to personal and workspace skills. It replaces the 21-PR draft stack #30584 to #30604 with five PRs, bottom to top: 1. #30609 data model: one migration, queries, RBAC and dbauthz 2. **#30610** organization skill API routes and the scope-neutral SDK (this PR) 3. #30611 sharing ACL routes 4. #30612 settings UI: shared skills table, admin page, member section 5. #30613 chats: chatd loading, `/` menu, docs ## What changes This PR adds the organization skill CRUD routes and makes the skill SDK types owner-neutral so personal and organization skills share them. **API contract change (experimental API, personal and organization skills):** skill list and get responses gain `enabled`, and `PATCH .../skills/{skillName}` now takes `{content?, enabled?}`, so `content` is optional and a toggle doesn't resend it. A PATCH with neither field returns 400; `content`, when present, is validated as before. In the SDK, `UserSkill`, `UserSkillMetadata`, `CreateUserSkillRequest` and `UpdateUserSkillRequest` become `Skill`, `SkillMetadata`, `CreateSkillRequest` and `UpdateSkillRequest` (`codersdk/userskills.go` moves to `codersdk/skills.go`), and `UpdateSkillRequest.Content` is now `*string`. The personal client method names are unchanged. The site changes are the handwritten edits that rename forces (`api.ts`, `queries/userSkills.ts`, `testHelpers/skills.ts` and three call sites), with no UI change. Organization routes under `/api/experimental/organizations/{organization}/skills`, not gated by an experiment or license, like the personal ones: - `GET` lists with the caller's own permissions, so admins, the site owner and org auditors see every skill and members see only skills shared with them. `GET /{skillName}` goes through the new `httpmw.ExtractOrganizationSkillParam` and admits only read, so a missing skill and a denied one both return 404. - `POST` checks `create` on the organization before reading the body, then seeds `group_acl` with the Everyone group (whose ID is the organization ID) so a new skill reaches every member until an admin narrows it. The 100-skill cap and a duplicate name return 409. - `PATCH` admits only callers who can read the skill, because its response includes the content; `DELETE` admits callers who can read or delete it. A reader who can't change the skill gets a write-specific 403 from the database wrapper, and everyone else gets 404. PATCH locks the row as system, updates as the caller in the same transaction, and audits the locked row only after the transaction commits. - Audit: `database.AuditableOrganizationSkill` records resource type `organization_skill` with the organization ID; personal skills keep `user_skill`. Personal and organization handlers share one create and update path in `coderd/userskills.go` (`createSkill`, `updateSkill`, and a `skillWriteErrors` table per owner and action). ## Commits The first commit reproduces the reviewed code from the old stack; each later commit is a labeled trim or fix. - `49cb2c84276` feat: add organization skill API routes. Reproduction: every file this commit changes, including the SDK layer's site edits, equals the reviewed old `write-routes` head `aa597100f28`; the rest of the tree differs only by #30609's migration merge and main. - `dc893bc60d6` refactor(coderd): share the skill create and update path across owners (production +164/-188). It keeps the organization create check before the body read, the lock as system then update as caller order, and audit assignment after the transaction. No swagger, `codersdk` or `typesGenerated.ts` change; `make gen` is clean. - `f94925425ef` test(coderd): merge duplicate personal and organization skill tests. `TestSkillsCRUD`, `TestSkillValidationAndConflicts` and `TestSkillAudit` are table-driven over Personal, OrgAdmin and SiteOwner, alongside `TestOrganizationSkillAuditsDeniedWrites` and one `ScopedAPIKeys` subtest; `TestPatchUserSkill` is deleted because none of its blocks were unique. Coverage of `userskills.go`, `organizationskills.go` and `httpmw/organizationskillparam.go` is 101 of 117 blocks before and after, the same block set. - `ad0a7a37504` fix(coderd): require read access to patch an organization skill. The organization PATCH route now admits only `read`, because its response carries the skill's content: a key scoped to `organization_skill:update` without read gets 404, like GET, instead of 200 with the content. Readers without update still get 403, and DELETE is unchanged. `TestOrganizationSkillAccess/ScopedAPIKeys` asserts the 404, that the response has no content, and that the skill is unchanged; against the old route it fails with 200. - `69d00ded0b6` and `f67b79343ec` merge the updated #30609 layer, including main; `69d00ded0b6` resolves a conflict in the personal skills page with main. No other changes of their own. - `18373ffd59e` merges the updated #30609 layer (main at `e7b76872098`) and reapplies the `AuditableOrganizationSkill` entry in `enterprise/audit/table.go` alongside main's new `AuditableChatProjectInstructions` entries. ## Size Production +838/-308, tests +733/-322, generated +801/-274; total +2372/-904. This is above the 500-line reviewer-friendly limit on purpose: Mike asked for 4 to 5 PRs instead of the 21 small ones this stack replaces. ## Replaces #30587 (scope-neutral SDK and personal enabled state), #30588 (read routes), #30589 (write routes and audit). ## Validation - The coverage comparison above, before and after the test merge. - `make gen` leaves no diff after the shared create and update refactor. - On `18373ffd59e`: `make gen` is clean; build, vet, the `coderd` and `enterprise/coderd` skill tests, `rbac`, `httpmw`, `dbauthz` and `enterprise/audit` pass; `pnpm check`, `pnpm lint` and `make pre-commit` pass. - Remote UAT round 7 through Coder Agents passed on the whole stack; see #30613's Validation for scope and findings. > Xum opened this PR on behalf of @ibetitsmike. |
||
|
|
b67587c875 |
feat: add the organization skills data model (#30609)
## Stack Part of [CODAGT-1341](https://linear.app/codercom/issue/CODAGT-1341/support-organization-level-skills-in-coder-agents). This stack adds organization skills to Coder Agents: admins publish a skill once per organization, share it with groups or members, and chats in that organization load it next to personal and workspace skills. It replaces the 21-PR draft stack #30584 to #30604 with five PRs, bottom to top: 1. **#30609** data model: one migration, queries, RBAC and dbauthz (this PR) 2. #30610 organization skill API routes and the scope-neutral SDK 3. #30611 sharing ACL routes 4. #30612 settings UI: shared skills table, admin page, member section 5. #30613 chats: chatd loading, `/` menu, docs ## What changes This PR adds the data model and authorization for organization skills. Personal skills keep working unchanged: `git diff origin/main -- codersdk site` shows only generated RBAC and API key scope additions (`apikey_scopes_gen.go`, `rbacresources_gen.go`, `rbacresourcesGenerated.ts`, the RBAC and scope unions in `typesGenerated.ts`) and `codersdk.ResourceTypeOrganizationSkill` with its friendly string. No personal route, SDK type or site component changes, and `coderd/userskills_test.go` changes only by mechanical constant renames. **One migration, `000621_skills`** (please review it closely): - renames `user_skills` to `skills` with its constraints, index and triggers, and recreates the cap function and `delete_deleted_user_resources`, whose PL/pgSQL bodies name the table; - adds `organization_id` and `project_id` (`ON DELETE CASCADE`), `enabled` (default true), and `group_acl` / `user_acl` (`jsonb`, default `{}`), with CHECKs for exactly one owner, ACLs that are JSON objects, and ACLs that stay empty unless an organization owns the row, plus partial unique name indexes per owner kind; - replaces the cap trigger with `enforce_skills_per_owner_limit()`: 100 rows per owner, disabled rows included, locking the owner row `FOR NO KEY UPDATE` so unrelated foreign key checks are not blocked; - adds a `BEFORE DELETE` trigger on `organization_members` that removes a departing member from `user_acl` on that organization's skills, so rejoining doesn't restore a direct grant; - adds the `organization_skill` `resource_type` and `api_key_scope` enum values last; nothing in the migration uses them. The down migration undoes the three old migrations in reverse order: it drops organization and project rows and restores `user_skills`, its names, the cap function and `user_id NOT NULL`. Authorization: a new RBAC resource `organization_skill` (create, read, update, delete, share). Owner and org admin get it; site and org auditors get read; members read only through the skill's ACL, which applies only to members of its organization. `Skill.RBACObject()` returns the organization object with both ACLs; project rows stay denied to everyone. New sqlc queries cover organization insert, get, list (SQL-filtered through `GetAuthorizedOrganizationSkillMetadata` and a `regosql` converter), update and delete, with dbauthz wrappers and the audit table entries. No routes yet. ## Commits The first commit reproduces the reviewed code from the old stack; each later commit is a labeled trim or fix. - `baa3150e3b7` feat: add the organization skills data model. Reproduction: every non-site file this commit changes equals the reviewed old `authz` head `1e16b3004c4`, except that the old stack's migrations 000615, 000616 and 000617 are merged into one migration (then `000615_skills`, now `000621_skills`) with one fixture (`testdata/fixtures/000621_skills.up.sql`) and one migration test (now `testMigration000621Skills`). At that commit, `dump.sql` was byte-identical to the old head's. - `1b84e83463a` test(coderd/database): keep only the SQL paths of the org skill matrix. `TestOrganizationSkillAuthorization` becomes `TestOrganizationSkillQueries` instead of being deleted, because coverage showed it is this PR's only run of the `GetAuthorizedOrganizationSkillMetadata` row scan (80% to 65% without it) and of the organization update and delete queries (100% to 0%). Swapping `group_acl` and `user_acl` in the converter makes `GrantedMember` fail. The removed cases are decided by `TestRolePermissions`, `TestSkillRBACObjectOrganizationACL` and the dbauthz method suite. - `e2931b412e9` test(coderd/database): fold the skill cap cases into existing coverage. The user case is covered by `TestUserSkillLimit` and `TestUserSkillLimitConcurrentCreates`; the organization case folds into `ConcurrentOrganizationInsertsHonorCap`, which now also checks that disabled rows count and another organization is unaffected (mutation checked); the project case stays. - `be62aea9021` test(coderd/rbac): drop `TestOrganizationSkillReadScope`, covered by `TestExternalScopeNames` and the generated scope file. - `0c275ba37de` merges main at `454a2fcc697`, which took 000615 to 000618: it renumbers the migration to 000619 and resolves `dump.sql`, `check_constraint.go` and the generated API docs. `8f2b4b87ee2` merges main at `ad85646164e`, which took 000619: it renumbers the migration to 000620. - `5248d56b64f` merges main at `e7b76872098`, which took 000620 (`000620_audit_chat_project_instructions_resource_type`): it renumbers the migration, fixture and migration test to `000621_skills` (step `Migration000621Skills`, version 621), and resolves `enterprise/audit/table.go` (keeping main's `AuditableChatProjectInstructions` entries and the `Skill` entry), `dump.sql` and `models.go` (the `resource_type` enum gets `chat_project_instructions`, then `organization_skill`) and the regenerated `schemas.md`. The up and down SQL are unchanged by every renumbering. ## Size Production +549/-67, tests +728/-33, generated +881/-314; total +2158/-414. This is above the 500-line reviewer-friendly limit on purpose: Mike asked for 4 to 5 PRs instead of the 21 small ones this stack replaces. ## Replaces #30584 (rename `user_skills` to `skills`), #30585 (skill owners), #30586 (organization skill authorization). ## Validation - Migration test: up keeps the existing personal row and its ID; down restores the `user_skills` names, cap function and `NOT NULL`, and drops organization rows; soft-deleting a user removes their skills after up, after down, and after re-up. - `go test` passed on `be62aea9021`, before the main merges, for `coderd` (skill tests), `coderd/database`, `dbauthz`, `migrations`, `gentest`, `coderd/rbac/...`, `coderd/x/chatd`, `coderd/x/skills`, `enterprise/audit` and `enterprise/coderd`; `make lint/check-scopes` passed; the four personal skills Vitest files pass unchanged. - On `5248d56b64f`: build, vet, `TestMigrate`, `TestMigrationChain`, the `migrations`, `database`, `dbauthz`, `gentest`, `rbac` and `enterprise/audit` packages pass; `make gen` run twice is clean, and `make pre-commit` passes. - Remote UAT round 7 through Coder Agents passed on the whole stack; see #30613's Validation for scope and findings. > Xum opened this PR on behalf of @ibetitsmike. |
||
|
|
97c5260adb |
feat: add chat project instructions API (#30368)
Adds the experimental API for chat project instructions: `GET`, `PUT`,
and `DELETE
/api/experimental/organizations/{organization}/chats/projects/{project}/instructions`,
behind the `chat-projects` experiment.
- `GET` returns 200 with empty instructions and null
`updated_by`/`updated_at` when nothing is set, so clients don't need a
404 path.
- `PUT` requires update access only (the read-back runs under a system
context, so a custom role with update but not read can save). It
sanitizes the text with `SanitizePromptText`. It rejects blank text with
400, pointing the caller to `DELETE`, and rejects text over the chat
prompt byte limit. It records the caller as `updated_by`. The upsert and
the read-back that returns the editor's profile run in one transaction.
- `DELETE` returns 204, including when nothing is set.
- Users without access to the project get 404, like the other project
routes.
- `PUT` and `DELETE` are audited as a new `chat_project_instructions`
resource (`write` and `delete`), with the project as the resource ID and
its name as the target. The diff tracks only the instruction text.
Saving unchanged text and deleting unset instructions are not audited. A
per-project advisory lock serializes reading the previous value with the
write, so concurrent edits produce accurate diffs. Migration `000615`
adds the enum value.
The codersdk client gains `ChatProjectInstructions`,
`UpdateChatProjectInstructions`, and `DeleteChatProjectInstructions`.
**What to scrutinize:** writes are last-writer-wins with no version
precondition, matching the deployment, user, and organization prompt
settings.
**Generated:** `coderd/apidoc/docs.go`, `coderd/apidoc/swagger.json`,
and `docs/reference/api/schemas.md` come from the Swagger annotations;
`site/src/api/typesGenerated.ts` comes from `codersdk`;
`docs/admin/security/audit-logs.md`, `coderd/database/dump.sql`, and
`coderd/database/models.go` come from the audit table and migration.
Together they are about 400 of this PR's lines.
**Validation:** `make gen` leaves no diff. `go test ./coderd -run
TestChatProject` and `go test ./enterprise/coderd -run
TestChatProjectInstructions` pass. `TestChatProjectInstructionsAudit`
checks the audit entries for create, update, and delete, and that no-op
saves and deletes are not audited. It covers unset GET, create, update,
blank and oversized PUT, delete, access denial, and cascade on project
delete.
---
Stack (merge top to bottom). #30377 through #29583 are f0ssel's split of
the original #29583, and this stack sits on #29583:
- #30377 data layer and project dialog (f0ssel)
- #30378 new-chat form locked to a project (f0ssel)
- #30379 project page route (f0ssel)
- #29583 sidebar folders (f0ssel), the base of this stack
- #30291 composer frame
- #30292 project chat list caches
- #30293 project page header
- #30294 project chats list
- #30367 instructions storage and prompt injection
- #30368 instructions API 👈
- #30369 instructions editor dialog
- #30370 instructions Details panel
---------
Co-authored-by: Garrett Delfosse <delfossegarrett@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
||
|
|
dae7967bd1 |
feat: persist script resource addresses and dependencies (#30625)
feat(coderd): persist workspace agent script dependencies Persist Terraform resource addresses and script dependencies supplied by the provisioner (#30451, #30491), and expose them through the SDK and REST API. - Add migration 000618 with `resource_address` and `dependencies` columns, empty defaults, and a JSON-array constraint. API responses always include the address and omit empty dependency lists. - Preserve `success` and `completion` requirements, including scripts on devcontainer subagents. Legacy scripts and older provisioners remain compatible through empty defaults. - Reject empty prerequisite addresses and unsupported requirements, rolling back the entire job. Invalid stored dependencies return HTTP 500 rather than silently dropping ordering. - Add persistence, validation, rollback, devcontainer, API, and migration coverage; regenerate API docs and TypeScript types. Unordered templates retain their existing execution behavior. Dependency lists remain empty until #30556. Agent manifest wiring and the agent API version bump are deferred to a follow-up. Refs PLAT-548. |
||
|
|
2f2169ed19 |
fix: deduplicate template insights family metrics (#30497)
coderd_insights_applications_usage_seconds summed each family's per-app minutes, so a user with VS Code and Cursor open in the same minute was counted as two VS Code minutes. GetTemplateInsightsByTemplate now takes the registry's app-to-family mapping as jsonb, groups the raw agent stats by family, and counts each minute once per user and family. - Keep the metric's four built-in series (Visual Studio Code, JetBrains, Web Terminal, SSH) and their labels; only their values change. The HELP text now says built-in apps are grouped by family. - Add AppFamilyName.DisplayName() and remove the duplicate TemplateBuiltinAppDisplayName* constants from codersdk. The template insights handler returns the same display names. - Pin how the migration 000596 rollback approximates family minutes from per-app rows. Family values can drop wherever the old per-app sum double-counted overlapping apps. No migration or storage changes. |
||
|
|
41f5caafec | fix: fold web searches, answer reasoning, and OpenAI narration into working blocks (#30529) | ||
|
|
8a063ef0d5 |
docs: add Claude Desktop as a supported client (#30653)
Closes [DOCS-1198](https://linear.app/codercom/issue/DOCS-1198/document-claude-desktop-as-a-supported-coder-client) Adds Claude Desktop alongside the other supported clients and IDEs. Once the Coder CLI is installed and logged in, running workspaces appear in Claude Desktop. ## Changes - New page `docs/user-guides/workspace-access/claude-desktop.md`: prerequisites, setup, troubleshooting. - New `## Claude Desktop` section in `workspace-access/index.md`. - Registered the page in `docs/manifest.json`. - Added Claude Desktop to the IDE list in the glossary. ## Notes - Setup steps checked against `docs/reference/cli/` and the existing SSH docs. - `make fmt/markdown`, `lint/markdown`, `lint/docs-manifest`, `lint/emdash`, `lint/docs-html` pass. > 🤖 This PR was created with the help of Coder Agents, and needs a human review. 🧑💻 |
||
|
|
f2ddf215dc |
docs(docs/user-guides/workspace-access): fix broken vscode-coder demo GIF links (#30655)
Closes [DOCS-1201](https://linear.app/codercom/issue/DOCS-1201/fix-broken-vscode-coder-demo-gif-links-in-workspace-access-docs) ## Summary coder/vscode-coder#1134 moved `demo.gif` from the repo root into `media/`, so the VS Code demo GIF embed now returns a 404. Linkspector flagged it on #30653 ([thread](https://github.com/coder/coder/pull/30653#discussion_r4249822055)). ## Changes - Point the demo GIF embed at `media/demo.gif` in `docs/user-guides/workspace-access/index.md` and `vscode.md`. ## Testing - `curl -sIL`: new URL returns 200, old URL returns 404. - `make lint/markdown` and `make fmt/markdown` pass. > 🤖 This PR was created with the help of Coder Agents, and needs a human review. 🧑💻 |
||
|
|
8674e8529e |
docs: note coder_agent dir un-deprecation in 2.29-2.34 ESR upgrade guide (#30533)
## Summary Follow-up to [coder/terraform-provider-coder#549](https://github.com/coder/terraform-provider-coder/pull/549), which un-deprecated `coder_agent.dir`. The 2.29-2.34 ESR upgrade guide still says `dir` is deprecated, warns, and breaks Coder Desktop file sync, and tells admins to set it to `$HOME`. As planned in #549, this keeps the original row as history and appends an **Update** to the New State and Action cells: - Coder Terraform provider 2.20.0 removed the deprecation and warning. - Coder Desktop file sync works with any `dir` on macOS [v0.8.4](https://github.com/coder/coder-desktop-macos/releases/tag/v0.8.4) and Windows [v0.8.5](https://github.com/coder/coder-desktop-windows/releases/tag/v0.8.5) (Mutagen v0.18.5, [coder/mutagen#10](https://github.com/coder/mutagen/pull/10)). The rest of the diff is `markdown-table-formatter` re-padding the table. `markdownlint-cli2` passes. ## Merge timing Opened as a draft. #549 is only in `v2.20.0-pre0` so far; mark ready and merge once provider 2.20.0 is published to the registry. If the release number changes, update the version in the row. Review requested from @aqandrew. --- Opened by Superblink on behalf of @matifali. Co-authored-by: coder[bot] <137810501+coder[bot]@users.noreply.github.com> Co-authored-by: Atif Ali <atif@coder.com> |
||
|
|
d7bf081e57 |
docs: point the 2.29 ESR row at v2.29.21 (#30538)
Updates the latest-patch link for the 2.29 Extended Support Release in the release calendar to [v2.29.21](https://github.com/coder/coder/releases/tag/v2.29.21), released 2026-10-09. One-line change; no other rows touched. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
5b060beeb1 |
feat: separate connection log methods from app names (#30466)
Connection logs now record how a connection was made (`connection_method`) separately from which app made it (`app_name`). Storage, the HTTP API, search filters, and the UI move to the new fields. Legacy agent reports and the deprecated `type` field keep working. - Add `connection_method` (`ssh`, `reconnecting_pty`, `workspace_app`, `port_forwarding`, `tunnel`) and optional `app_name` and `app_display_name` to `GET /api/v2/connectionlog`. Deprecate `type` and make it a plain string in the API and the Go SDK. - Add `method:` and repeatable `app:` search filters. `type:` keeps its old results but can't be combined with the new filters. - Replace the Type menu with a Method menu, show the app next to the method in each row, and warn when a filter uses `type:`. - Change the Active SSH connections preset to `method:ssh`, so it also includes SSH sessions from VS Code and JetBrains apps. - Generate `codersdk.ConnectionLogMethod` from the database enum with `typegen dbenums`. - Migration 000617 rewrites `connection_logs` under an ACCESS EXCLUSIVE lock, which takes about 50 seconds for 10 million rows. `vscode` and `jetbrains` rows become `ssh` rows with that app. Rolling back folds apps into the old types and loses per-app names. - Document the new filters and how to replace each `type:` value. Closes #27412 |
||
|
|
f923f4a525 |
chore!: remove the chat automations experiment (#30412)
Removes the experimental Chat Automations feature (`chat-automations` experiment) from main. This reverts the 16-PR stack that added it and adds two forward migrations that undo its schema and credential changes.
> [!WARNING]
> **Upgrade consequences**
>
> - **Automation data is deleted.** Migration 000615 drops the `chat_automations` table and deletes every queued message an automation delivered. Chats, their messages and ordinary queued messages stay. Messages lose their automation provenance (`automation_id`, `input_id`).
> - **Automation-only credentials are revoked.** Migration 000616 deletes API keys, OAuth2 codes and OAuth2 tokens whose only scopes (or allow-list entries) were `chat_automation:*`. Mixed credentials keep their other scopes. Custom roles lose their `chat_automation` permissions. OAuth2 apps that allowed only `chat_automation` scopes get the whitespace allowlist that grants nothing, as in 000595.
> - **A coordinated restart is required.** Stop all old replicas before the new version runs the migrations. Old replicas read the dropped table and columns, so a rolling deploy is not supported.
> - **Remove `--chat-max-automations-per-owner` before upgrading.** The flag, the YAML key `chat.maxAutomationsPerOwner` and the env var `CODER_CHAT_MAX_AUTOMATIONS_PER_OWNER` are removed. A deployment that still sets the flag or the YAML key will not start (`unknown flag` / `unknown option`). The env var is ignored. This includes dogfood. No release or tag contains the flag.
> - **Down migrations restore the schema only.** 000616 down and 000615 down recreate the 000611 schema with empty tables. They do not restore deleted automations, webhook secrets, provenance, queued deliveries, revoked credentials, stripped permissions or the deleted experiment rule.
## What is removed
- The `chat-automations` experiment and its stored runtime rule (`experiment_rule:chat-automations`).
- The `--chat-max-automations-per-owner` deployment option.
- The `chat_automation` RBAC resource, its member and chatd grants, and the `chat_automation:*` API key scopes.
- The automation sqlc queries, dbauthz wrappers and audit table entries.
- The management routes under `/api/experimental/organizations/{organization}/chat-automations`, and the webhook route `POST /api/experimental/chat-automations/{automation}/events` with its rate limiter.
- The chatd management service, webhook publish, schedule loop, the `manage_automations` tool, and the chatstate admission seam and queue promotion guard that only automations used.
- The Agents Automations page, editor, nav entry, chat labels, the Manage automations toggle and the API client.
- The `archived:any` chat search value that the automations "View chats" dialog added.
- `docs/ai-coder/agents/automations.md`, its manifest entry, the glossary entry and the related rows.
Reverted PRs: #30085, #30096, #30112, #30117, #30127, #30134, #30160, #30166, #30167, #30171, #30187, #30207, #30214, #30217, #30219, #30220.
## What stays, and why
- Migrations 000609, 000610 and 000611, their fixture, and the #30297 lock fix with `migration000609_test.go` stay unchanged. Deployments such as dogfood already ran them.
- New migration **000615** reverses the schema changes of 000609 and 000611 against the current schema. It uses the same short-wait lock-and-retry block as 000609, and it rebuilds `chats_expanded` from main's current definition minus the two automation columns. New migration **000616** follows the 000595 Tasks removal for credentials and recreates `api_key_scope` without the five `chat_automation:*` values. It keeps the `chat_project_memory:*` values from 000612.
- The `chat_automation` value stays in the `resource_type` enum, and `codersdk.ResourceTypeChatAutomation` stays. Old audit log rows stay readable, as with `task` after the Tasks removal.
- The 000615 delete fires the existing queue-version trigger, so `queue_version` moves to `snapshot_version` for each affected chat. `snapshot_version` is not bumped: the coordinated restart restarts every stream loop from an empty state, and the site does not read the version fields.
- `coderd/x/chatd/ARCHITECTURE.md` drops the sections the stack added and gets back its pre-stack wording, merged with the later main edits to the same file.
## Notes for reviewers
- #30379 (chat project page) merged while this PR was in progress. It passed `manageAutomationsEnabled` in `AgentCreatePage.test.tsx` and listed an `automations` route in `AgentsPageLayout.test.tsx`. Later main commits also added automation props in `ConversationTimeline.test.tsx` and `ConversationTimelineWorkingBlocks.stories.tsx`. This PR removes all of them.
- Remaining `automation` matches under `coderd`, `codersdk`, `enterprise`, `site/src` and `docs` are intended:
- migrations 000609 to 000611, their fixture and `migration000609_test.go`;
- the new 000615 and 000616 migrations and `migration000615_test.go`;
- the `chat_automation` resource type in `dump.sql`, `models.go`, `codersdk/audit.go`, the generated API docs, `swagger.json` and `typesGenerated.ts`;
- unrelated uses of the word "automation" (docs, `chatlabels_test.go`, `ratelimit.go`, `autostop.go`, `subagent_catalog.go`, `WorkspaceSharingSection.tsx`, `AgentChatPage.stories.tsx`).
Remote UAT on an isolated dev deployment passed. It upgraded a populated pre-removal database, then checked chats, queued messages, tokens, the 404 routes, the removed page and nav entry, and the experiments list.
---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_

|
||
|
|
dfa72df9aa |
docs: remove references to unsupported SAML authentication (#30507)
## Summary Coder doesn't support SAML, but a few docs pages implied it did. This PR removes those mentions. Resolves [DOCS-1194](https://linear.app/codercom/issue/DOCS-1194/remove-saml-mentions-from-docs-coder-doesnt-support-saml). ## Changes - `docs/install/index.md` and `docs/install/prepare/index.md`: "OIDC or SAML application" is now "OIDC application". - `docs/.style/style-guide/audience-and-scope.md`: the example snippets no longer mention SAML or link to a `./saml.md` page that doesn't exist. The hub-page example now lists headless authentication instead, and the persona "Coder surface" lines say "OIDC" in place of "OIDC/SAML". <details> <summary>Evidence that Coder doesn't support SAML</summary> Checked against `main`: - No SAML library in `go.mod`, `go.sum`, or `site/package.json`. - The `login_type` enum in `coderd/database/dump.sql` and `codersdk.LoginType` only cover `password`, `github`, `oidc`, `token`, `none`, and `oauth2_provider_app`. - No SAML handlers, endpoints, or deployment options in `coderd/` or `enterprise/`. - The only code mention is a comment in `coderd/userauth.go` about SAML-to-OIDC bridges sending `email_verified` as a string. </details> ## Testing - `pnpm run lint-docs`: 0 errors. - The pre-commit hook passed. - `git grep -i saml -- docs` returns nothing. --- *Generated by Coder Agents on behalf of @nickvigilante.* --------- Co-authored-by: Ben Potter <me@bpmct.net> Co-authored-by: Ben Potter <ben@coder.com> |
||
|
|
86ebc72236 | chore: remove unused autofill-parameters endpoint and experiment (#30525) | ||
|
|
f8e053e385 | docs: document VS Code SSH keepalive and reconnection settings (#30501) | ||
|
|
782fb30f09 |
feat: load whole chat turns per history page (#30524)
Closes [CODAGT-1372](https://linear.app/codercom/issue/CODAGT-1372/load-whole-turns-per-history-page-so-collapsed-working-blocks-fill-in). With collapsed working blocks, a long agent turn renders as one row, but chat history pages hold a fixed 50 messages. A 400-step turn took about eight sequential page loads to fill, and its block showed partial labels ("at least", "or more") until then. `GET /api/v2/chats/{chat}/messages` now returns `turn_start_id` on newest-first pages: the ID of the user prompt that starts the turn containing the page's oldest message. It comes from a new `GetChatTurnStartID` query on the existing `idx_chat_messages_user_prompts` index, so there is no migration. Soft-deleted prompts and model-only user rows never start a turn. The history query then fills each page back to that prompt with requests of up to 200 messages, capped at 1000 messages per page, so a page holds whole turns and a complete block renders without partial labels. Past the cap, or when a fill request fails or returns no messages, the page keeps what loaded and ends mid-turn, and the next page continues it, as before. Because the fill runs inside the page fetch, a chat now waits for its fill requests (one to five) before it first renders: with an injected 500 ms per-request delay, a chat whose newest turn hits the cap appeared after 3.8 s instead of 1.1 s. ## Screenshots From the dogfood UAT, the same 200-step turn with its next history request held, so each label shows only what loaded before it: **Before**, on the base commit `29e876df4da`, after two 50-message pages: "Worked for at least 1m 35s (48 steps or more)", partly hidden by the loading indicator.  **After**, on `186a9b053a0`, after the first page: "Worked for 6m 39s (200 steps)".  A 750-step turn, larger than one 1000-message page, is exact once the next page loads:  A malformed fill response keeps the loaded messages and the partial label instead of showing "Failed to load chat", as `ecdfb27ec29` did:  ## Testing - Go: `TestGetChatMessages_TurnStartID` (pages spanning turns, deleted prompts, model-only user rows, polling and empty pages) and the dbauthz suite entry. - Vitest: fill request parameters, the 1000-message cap, failed, malformed, and empty fill responses, and servers without `turn_start_id`. - Dogfood UAT through Coder Agents: PASS on `186a9b053a0` (round 4): whole-turn first pages, the 1000-message cap and its continuation, fill failures, a live turn, and API checks for deleted prompts and model-only user rows. Round 3 on `ecdfb27ec29` failed: a malformed fill failed the chat load, and an empty fill reporting `has_more` repeated forever. `7266f468290` fixes both, with regression tests. ## Review record - Test audit with mutation checks: the Go test now covers a page spanning two turns, which catches a lookup keyed on the newest message. A re-audit of later test changes changed nothing; the one surviving mutation drops the `!older.has_more` stop, costing one extra request when the prompt is deleted mid-fill. - Frontend review (8 roles, 5 rounds): fixed doc, naming, loose-type, and test findings. Its suggestions to catch only the fill request (DF5) and drop the empty-page stop (SD4) caused the round 3 failures and are reverted. Kept: SD1 (`MAX_MESSAGES_PER_REQUEST` is used once, named like `MESSAGES_PAGE_SIZE`) and round 5 SD4 (`!older.has_more` is the endpoint's pagination signal). Declined DF6: the `queued_messages` refetch race predates this change, and a failed refetch fill only unloads older history that reloads on scroll. - Codex: no findings on `186a9b053a0`. - Known: a hung fill delays the first render (no client timeout); fills are not cancelled when the user leaves; the top of history costs one extra empty request; injected malformed fill rows break the page as they do on the first page. > Xum opened this PR on behalf of @ibetitsmike. |
||
|
|
6bae268487 |
fix: move organization instructions to the Instructions page (#30428)
Moves organization instructions (#30272) from the Coder Agents page to **AI Settings** > **Coder Agents** > **Instructions**, so every Coder Agents instruction is managed on one page. The API and stored data are unchanged. - **Deployment admins** see a "Deployment instructions" section with the existing system prompt and plan mode form, then an "Organization instructions" section. The organization section has an organization picker when there is more than one organization. - **Organization admins and auditors** who can read an organization's chat model configuration get an Instructions entry in the AI settings sidebar and see only the organization section. Auditors get it read-only. - The selected organization is kept in `?org=`, and the sidebar link carries it over from the other AI settings pages. - The Coder Agents page goes back to its layout from before #30272. Its sections and the new page's sections share new `SettingsSection` and `OrganizationSettingsSection` components. - Three docs pages point to the new location. Other behavior changes: - The deployment section shows a loader while loading and an error alert when loading or refreshing fails. Before, the page rendered nothing until both settings loaded. - The deployment forms no longer have their own accessible names, because each section is named by its heading. ## Testing - Vitest for the Instructions page and sidebar link, and stories for the new states. Breaking each of the 9 main code paths, or removing the instructions field's accessible name, fails its test. - The branch merges `main` for #30402, which made the organization picker a combobox. - CI passes on `a0cc6a98660`. - Remote dogfood UAT, [evidence chat](https://dogfood.cdr.dev/agents/1cbf9da4-9671-4890-ade1-c151a1a69cd7): **PASS** on `a0d9c3fca46`, 14 scenarios across every role, `?org=` handling, injected load failures, keyboard use, and a 390 px layout. The remote agent's FAIL (a double-click on Save sends 2 PUTs) also happens on the merge base, so it predates this PR. Delta round on `a0cc6a98660`: **PASS**. When the permission re-check fails, the owner and an organization admin see the alert above the organization section, and the unsaved draft stays and saves. - UAT notes left as is: the fallback for an unreadable `?org=` is read-only, as on the Coder Agents page; `?org=` matching is case-sensitive, as on the Models and Spend pages; the old `/agents/settings/instructions` redirect drops `?org=`; the permission alert shows the server's error message without saying which check failed, as on the Models pages. ## Screenshots From UAT on a test deployment. | Organization admin | Owner, after a failed refresh (unsaved edit kept) | |---|---| |  |  | | **Coder Agents page, no instructions card** | **Unavailable `?org=`: warning and read-only fallback** | |  |  | ## Review record 1. `coder-frontend-review` (8 reviewer agents) on `3dd65e828f9`: fixed in `a0d9c3fca46` (deployment refetch errors were dropped, plus naming, prop types, test waits, and a single-organization story). Declined: `SettingsHeader` in `SettingsSection` and merging the sidebar groups (both change existing layout), and restructuring the moved card (git would stop detecting the move). 2. `frontend-review` (FE1 to FE10) on `a0d9c3fca46`: every rule passes, no changes. 3. Codex, [review](https://github.com/coder/coder/pull/30428#pullrequestreview-5431118231) on `a0d9c3fca46`: 1 P2, a docs sentence wrote "more than 1" where the numbers guide spells out "one". Fixed in `0e71b8f16b9`. 4. Codex, [review](https://github.com/coder/coder/pull/30428#pullrequestreview-5431285875) on `0e71b8f16b9`: 2 findings, each confirmed by a failing test and fixed in `a0cc6a98660`. A failed background re-check of organization permissions showed no alert, unlike the old Coder Agents page and the Models pages (P2). The page tests found the instructions field by its value, so removing its accessible name went unnoticed (P1). 5. `coder-frontend-review` (8 reviewer agents) and `frontend-review` (FE1 to FE10) on `a0cc6a98660`: everything passes, no changes. The round 1 `findByDisplayValue` suggestion is reversed, because FE10 asks for role and name queries. 6. Codex on `a0cc6a98660`: [no major issues](https://github.com/coder/coder/pull/30428#issuecomment-6020794170). > Xum, an AI coding agent, implemented, tested, and opened this PR on behalf of @ibetitsmike. |
||
|
|
befda9b29f |
docs: mention chat reasoning_tokens is part of output_tokens (#30500)
Document that reasoning_tokens is included in the output_tokens on ChatMssageUsage, which is the case for all known providers. Refs CODAGT-1350 |
||
|
|
261269aff0 |
fix: support path-aware OAuth discovery for remote MCP (#30168)
## Problem VS Code discovers Coder's MCP endpoint as a path-qualified OAuth resource, but Coder advertises the deployment root. Accepting MCP-bound tokens also requires keeping REST-backed tool calls within the originating MCP resource rather than granting those tokens direct REST access. ## Fix - Publish path-aware protected resource metadata and authentication challenges; keep authorization-server metadata at the root. - Validate the MCP audience and delegate tool requests through a private in-process transport that retains identity, scopes, expiry, revocation, and streaming cancellation. - Reject unsupported MCP path aliases and validate SDK path components before URL resolution. - Add discovery, audience, authorization, endpoint-isolation, and transport lifecycle regression tests and update integration docs. ## Validation VS Code completed OAuth and returned the authenticated user through a real MCP tool. Official MCP SDK 1.30.1 completed discovery, registration, PKCE, tool execution, and refresh. These live checks preceded the final path hardening; the hardened paths are covered by automated regressions. Affected Go package tests, targeted race tests, backend/SDK lint, and targeted documentation checks passed during self-review. The exact PR commit was also checked separately from the uncommitted consent-scope fix. > [!NOTE] > Tokens are MCP-audience-bound, but grants still include `coder:all`; least-privilege scopes remain a separate requirement ([PLAT-639](https://linear.app/codercom/issue/PLAT-639)). Preview: https://coder.com/docs/@fix/mcp-internal-delegation/ai-coder/mcp-server <details> <summary>Implementation decisions and review context</summary> 1. Treat `/api/experimental/mcp/http` and its single-trailing-slash form as supported MCP resource paths; reject other aliases and descendants before route authentication. 2. Preserve deployment-root discovery and authorization-server metadata for existing REST integrations. 3. Bind private delegation to the authenticated API-key ID. Revalidate the original credential and enforce normal RBAC/scopes on every internal REST request; do not derive delegation from HTTP headers. 4. Keep internal HTTP, streaming, and WebSocket traffic in-process with no network fallback. Close the transport on outer-request cancellation and normal completion. 5. Validate workspace owner/name path segments before SDK URL construction, including tool-level tests that malformed arguments cannot select a different REST endpoint. 6. Keep compatibility and delegated tool execution together: discovery-only changes would allow authentication while leaving real MCP tool calls broken. </details> > 🤖 This PR was created with the help of Coder Agents, and needs a human review. 🧑💻 |
||
|
|
a8303a8f2b |
feat!: add output formats to coder schedule start, stop, and extend (#30136)
`coder schedule start`, `stop`, and `extend` printed the updated schedule as a fixed table with no `-o` or `-c`, while `coder schedule show` has both. All four commands now share one formatter with the same row type, default columns, `-o table|json`, and `-c`, so the output of a change and of `show` is interchangeable. **Behavior change:** Adds `-o` and `-c` to the three commands. The default table output changes slightly: the WORKSPACE column no longer includes the favorite-star prefix, matching `schedule show`. Other columns are unchanged. <details> <summary>Decisions</summary> - Previously these commands rendered `WorkspaceListRow`, which prefixes the workspace name with a favorite icon. Using `scheduleListRow` for consistency with `schedule show` drops that prefix. </details> Closes [CLI-15](https://linear.app/codercom/issue/CLI-15) _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
98bcc3afb7 |
fix!: remove the unused --yes flag from coder autoupdate (#30149)
`coder autoupdate` has registered `-y/--yes` since #10438 but never prompts, so the flag did nothing. This PR removes it. **Breaking change:** `coder autoupdate` no longer accepts `-y/--yes`. Scripts that pass it now fail with `unknown shorthand flag: 'y'`. To fix them, drop the flag; it never had an effect. <details> <summary>Decisions</summary> - The first version kept `-y` as a hidden no-op so existing scripts wouldn't break. - Reviewers preferred removing it outright as a breaking change, since a deprecation period would end in the same removal and the hidden flag is cruft. - The title uses `fix!:` and the PR carries `release/breaking`, so the release tooling lists it under breaking changes. - `cliui.HiddenSkipPromptOption()` landed on `main` through the organizations create PR and stays there for that command; this PR no longer touches it. - The test now pins the new behavior: passing `-y` returns an unknown flag error. </details> Closes [CLI-33](https://linear.app/codercom/issue/CLI-33) _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
c11d60ad8d |
docs: note the pubsub cluster port between HA replicas (#30290)
HA replicas connect to each other's embedded NATS pubsub on TCP 6222. The port is hardcoded ([`coderd/x/nats/pubsub.go`](https://github.com/coder/coder/blob/7f3d35353eddcd8a9e573094e5e2531bd2d73659/coderd/x/nats/pubsub.go#L62)) with no flag or environment variable, and since #29283 NATS pubsub is on by default. The HA page explains `CODER_CLUSTER_HOST` but doesn't name the port, so a firewall or default-deny NetworkPolicy between `coderd` nodes blocks it. This adds the port, and what happens without it, next to `CODER_CLUSTER_HOST`. Measured on v2.37.3 (`CODER_EXPERIMENTS=nats_pubsub`, the default on main) with two replicas on GKE under a default-deny NetworkPolicy, port 8080 open between the replicas in both runs. Through a port-forward to replica B, `PUT /api/v2/workspaces/{id}/extend` publishes a workspace update in the request path. A watcher on `/api/v2/workspaces/{id}/watch` through replica A counts the events. The control sends the same request through A. 6222 blocked: ```text label=blocked A=coder-699ccb59f8-695bj B=coder-699ccb59f8-w8glp baseline_data_events=1 control: extend via A -> HTTP 409; data events on A: 1 (expect 1) test: 5x extend via B -> HTTP 409 409 409 409 409; data events on A: 0 coder-699ccb59f8-695bj :6222 established: 0 coder-699ccb59f8-w8glp :6222 established: 0 ``` 6222 allowed between the replicas (same pods, no restart): ```text label=allowed A=coder-699ccb59f8-695bj B=coder-699ccb59f8-w8glp baseline_data_events=1 control: extend via A -> HTTP 409; data events on A: 1 (expect 1) test: 5x extend via B -> HTTP 409 409 409 409 409; data events on A: 5 coder-699ccb59f8-695bj :6222 established: 4 coder-699ccb59f8-w8glp :6222 established: 4 ``` The 409s are expected because the workspace is stopped; the handler publishes the update before it returns ([`coderd/workspaces.go`](https://github.com/coder/coder/blob/3a248167f6e58462a8a8cddba3b49a8ff72a9f80/coderd/workspaces.go#L1711) at v2.37.3). Would it also make sense for the chart to declare 6222 as a container port, or for the port to be configurable? I left both out of this change. AI involvement: I used an AI assistant to draft this change, and verified it with the runs above against a two-replica deployment. |
||
|
|
020b437ec9 |
docs: document dropping capabilities for restricted Pod Security (#30271)
Following the suggestion in #22543 to have `coder.securityContext.capabilities` in `values.yaml` without a default, this adds it as a commented example, the same way `values.yaml` shows `env` and `initContainers`, and adds one line to the Kubernetes Security Reference. Existing deployments don't change on upgrade. The chart's default security context passes every Pod Security Standards `restricted` check except capabilities, so a namespace that enforces `restricted` rejects the pod. Because the example is commented out, the rendered chart is unchanged: ```console $ diff main.yaml branch.yaml && echo "renders identical ($(wc -l < branch.yaml) lines)" renders identical (208 lines) ``` Server-side dry runs of this branch's chart into a namespace labeled `pod-security.kubernetes.io/enforce=restricted` (GKE, Kubernetes 1.35), using the pod spec from the rendered Deployment, as is and with the example uncommented: ```console $ kubectl create --dry-run=server -n coder -f pod-branch.json Error from server (Forbidden): error when creating "pod-branch.json": pods "pss-main-branch" is forbidden: violates PodSecurity "restricted:latest": unrestricted capabilities (container "coder" must set securityContext.capabilities.drop=["ALL"]) $ kubectl create --dry-run=server -n coder -f pod-branch-drop.json pod/pss-main-branch-drop created (server dry run) ``` A v2.37.3 deployment with the value set runs in a `restricted` namespace, ready with no restarts. AI involvement: I used an AI assistant to draft this change, and verified it with the commands above against a running cluster. |
||
|
|
b4d51012da |
feat: allow template version selection for workspace builds (#30199)
Add named template version selection to `coder start` and `coder stop`, and independent stop/start selection to `coder update` with `--stop-template-version` and `--template-version`. Stop still defaults to the workspace's current version, and update starts with the active version by default. Explicit selections use the selected version for parameter preparation and builds, keep server permissions authoritative, and never silently fall back to the active version. Classic stop builds retain previous parameter values omitted by the selected stop version, so a later start can reuse them across separate commands or an interrupted update. Declared parameters still follow normal validation, and start builds still discard removed parameters. Update now returns an error and retry guidance when a start apply fails after stopping, including unflagged updates that previously returned success. Closes #29100 [PLAT-616](https://linear.app/codercom/issue/PLAT-616/cli-allow-specifying-a-template-version-for-stopstart-builds-and-both) --------- Co-authored-by: Nick Vigilante <nickvigilante@users.noreply.github.com> |
||
|
|
b4fb7901e6 |
docs: clarify that disable-password-auth also applies to owners (#30362)
The `--disable-password-auth` help text says owners can still sign in with a password "to avoid potential lock out", and a comment in `coderd/userauth.go` says the same. Neither is true. #6193 removed the owner bypass on purpose, so the flag blocks password login for everyone. The recovery advice was also wrong. It named a command that doesn't exist (`create-admin`), and any admin that `create-admin-user` creates while the flag is on still can't sign in. This PR changes docs and comments only: - Rewrites the flag description to say it applies to owners too and how to recover access. Regenerated the CLI and config reference docs and the golden files. - Fixes the misleading comment in `coderd/userauth.go`. - Adds the same warning and recovery steps to `docs/admin/users/password-auth.md`. > [!NOTE] > Generated by Coder Agents on behalf of @jdomeracki-coder. |
||
|
|
c9680e4f36 |
docs: correct the CODER_AGENT_BLOCK_FILE_TRANSFER block list (#29705)
## Problem The FAQ entry _"How can I restrict inbound/outbound file transfers from Coder workspaces?"_ documents the wrong block list for `CODER_AGENT_BLOCK_FILE_TRANSFER`. It currently says the list includes `scp`, `rsync`, `ftp`, and `nc`. The actual list in [`agent/agentssh/agentssh.go`](https://github.com/coder/coder/blob/main/agent/agentssh/agentssh.go) is: ```go // BlockedFileTransferCommands contains a list of restricted file transfer commands. var BlockedFileTransferCommands = []string{"nc", "rsync", "scp", "sftp"} ``` So the docs have two errors: - **`ftp` is documented but is not blocked.** An admin reading this page could reasonably believe `ftp` is covered when it is not. - **`sftp` is blocked but is not documented.** This matters operationally, because SFTP is blanket-blocked at the subsystem level (`if session.Subsystem() == "sftp"`), which disables anything built on it. ## Changes 1. Correct the block list to match the source, in the same order as the slice so the two are easy to diff by eye in future: ```diff -block list, which includes `scp`, `rsync`, `ftp`, and `nc`. +block list, which includes `nc`, `rsync`, `scp`, and `sftp`. ``` 2. Per review feedback, add a note to **Important Notice** covering what enabling this actually breaks: SFTP-based tooling, and [Coder Desktop file sync](https://coder.com/docs/user-guides/desktop/desktop-connect-sync). Desktop file sync breaks via `scp` rather than `sftp`. It runs Mutagen over SSH, and Mutagen's SSH transport installs its remote agent binary by shelling out to `scp` ([`pkg/agent/transport/ssh/transport.go`](https://github.com/coder/mutagen/blob/v0.18.3/pkg/agent/transport/ssh/transport.go)), which is on the block list. The note keeps that distinction because an admin debugging it will see an `scp` failure, not an SFTP one. ## Correction An earlier revision of this description claimed `coder cp` is also blocked. **That was wrong — there is no `coder cp` command.** No `cli/cp.go`, no `docs/reference/cli/cp.md`, no `cp` entry in the CLI index. I've removed the claim rather than document a command that doesn't exist. Discussed in the thread below. ## Not included Linking the FAQ to [Agent Firewall](https://coder.com/docs/ai-coder/agent-firewall) from the "For more advanced security needs" line, which currently only says "consider adopting an endpoint security solution." Happy to add if wanted, but it felt out of scope for a correctness fix. Also note I only verified the macOS Desktop client. `coder-desktop-windows` and `coder-desktop-linux` are very likely the same Mutagen setup, but I didn't read them, so the note makes no per-platform claim. Created on behalf of @bartekgatzcoder. --------- Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com> |
||
|
|
d56cc3a6c3 |
docs(docs/support): clarify VS Code support bundle requirements and limits (#30430)
Refs VSC-25, #30118 |
||
|
|
fc01bee831 |
fix: keep new API keys within the caller's scopes and allow list (#30256)
A scoped key holding api_key:create could mint a broader key, e.g. a token scoped to [api_key:create user:read] could mint coder:all.
- New keys must be covered by the caller's scopes and allow list, and inherit them when none are requested
- Requests beyond the caller return 403
- New key expiry is capped at the caller's
- Covers POST /users/{user}/keys/tokens, POST /users/{user}/keys, app auth-redirect, and /oauth2/authorize (invalid_scope on excess grants or a restricted session allow list)
- coder:all sessions, including browser logins, behave as before
- Not addressed: workspace start still mints a coder:all key for the owner
|
||
|
|
e4682343e6 |
feat: match PR number prefixes in chat search (#30404)
Chat search now matches PR numbers by prefix, so typing `3028` already finds the chat for PR `30281` instead of showing zero results mid-typing. The free-text `search:` branch in `GetChats` switches from `pr_number = @search::bigint` to `pr_number::text LIKE @search || '%'`, still guarded by a digits-only regex so the value can never carry LIKE wildcards. The lookup stays a correlated per-chat EXISTS on the `chat_diff_statuses` primary key, which leads with `chat_id`, so the cost is the same as before and no new index is needed. The explicit `pr:` filter stays exact, and ordering is unchanged (no exact-match ranking) so cursor pagination is unaffected. Behavior note: values with leading zeros (`030281`) no longer match PR `30281`, since the old bigint cast normalized them. PR numbers never have leading zeros, so this seemed fine. Closes CODAGT-1342 ## Testing - `TestGetChatsSearch` gains prefix (`4` -> PR 42), no-infix (`2` -> none), and LIKE-wildcard (`4%` -> none) cases; the prefix case fails on the old predicate. - Dogfood UAT through Coder Agents on the branch: searching `3`, `302`, `3028`, `30281` all surface the PR-linked chat; `0281` and `302810` do not; `pr:3028` stays exact. > [!NOTE] > This PR was created by Xum acting on behalf of @ibetitsmike. |
||
|
|
21c1abe9ad |
docs(docs/install): reformat to one sentence per line (#30438)
Reformats every Markdown page under `docs/install` to the [one-sentence-per-line convention](https://github.com/coder/coder/blob/main/docs/.style/style-guide/formatting.md#one-sentence-per-line). Addresses DOCS-668. This is a source-layout change only: 28 of the 36 pages change, and rendered HTML is identical for all of them except three wording fixes. Three pre-existing em dashes sat on reflowed lines, which `lint/emdash` flags as new, so they're rewritten with commas or a sentence break (`operate/upgrade/esr-2.24-2.29-upgrade.md`, `operate/upgrade/best-practices.md`). Front matter, fenced code, tables, HTML blocks, and headings are untouched. `Coder.OneSentencePerLine` is not enabled for `docs/install` in `.vale.ini`: the 39 remaining findings are all table rows or code, which the guide puts out of scope, and enabling the rule would break the zero-baseline doctrine. <details> <summary>Implementation and verification notes</summary> **Approach.** A throwaway script reflowed each paragraph. Bullet items, numbered entries, and blockquote lines (including `> [!NOTE]` callouts) are each their own paragraph; extra sentences in a list item continue on indented lines, matching `docs/.style/content-guidelines.md`. Sentence breaks are never inserted inside inline code, link text, URLs, or HTML tags, and abbreviations such as `e.g.` and `etc.` don't count as sentence ends. Images that started their own source line stay on their own line. The script is idempotent: a second pass produces no changes. **Merge with main.** `main` restructured `docs/install` into plan, prepare, server, validate, and operate sections after this branch was cut. The merge takes `main`'s tree and re-runs the reflow over every page now under `docs/install`, so the branch diff against `main` is reflow only. `releases/index.md` and `releases/feature-stages.md` moved out of `docs/install` on `main` and are no longer in scope. **Verification.** - Rendered every page with `marked` from `main` and from this branch and compared normalized HTML: identical except the three em-dash rewrites. - Vale with `Coder.OneSentencePerLine` forced on for `docs/install`: 277 findings on `main`, 39 on this branch, all in table rows or fenced code. - A broader sweep for mid-line sentence boundaries and for false splits (lines starting lowercase, lines ending in an abbreviation) found no prose hits. - `markdownlint-cli2`, `markdown-table-formatter --check`, `make lint/emdash`, and `make pre-commit-light` pass. </details> --- *Generated by Coder Agents on behalf of @ianjevans.* |
||
|
|
44af8a1b56 |
docs: shorten the add-a-language install script copy and note apt reinstalls (#30376)
The "Add a programming language" guide embedded a full copy of the install script that had drifted from the shipped Template Builder base (it used `grep -q` partial matching, not `has_language`). The Final code tab now shows an abbreviated excerpt (helpers plus the new Ruby branch) so it can't drift again, and Step 4 and the "How does Coder install the language you pick?" section use `has_language ruby`. Also adds a short note in Step 4 that `apt-get` installs Ruby into the ephemeral container, so it reinstalls on every start, while home-directory installs persist. The persistent `~/.local` approach from the ticket is not taught because it never landed on `main` (#28485 was closed unmerged). The `has_language` helper is present in the Template Builder base on `main`. The older example template gets it in #30373. Refs DOCS-713. Generated by Coder Agents on behalf of @nickvigilante. |
||
|
|
237616a87d |
fix!: make --yes skip the rename confirmation prompt (#30151)
`coder rename` registers `-y/--yes`, but its confirmation asks you to type the workspace name, and `cliui.Prompt` only honors `-y` for yes/no prompts. So `coder rename ws new -y` still blocked on input. With `-y`, the type-the-name prompt is now skipped. The data-loss warning is still printed. **Behavior change:** With `-y`, the rename happens without reading stdin. Without `-y`, the prompt is unchanged. Closes [CLI-35](https://linear.app/codercom/issue/CLI-35) _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
cc76b62009 |
refactor!: drop edit_files search/replace wire compat (#29221)
Remove the deprecated `search`/`replace` keys from the `edit_files` wire type. `FileEdit` now encodes and decodes `old_text`/`new_text` only; the shims that carried the old keys through the rename (#28467) are gone. **Breaking change:** chat lifecycle hook consumers must use `old_text` and `new_text` for `edit_files`. A `pre_tool_use` `input_override` that still sends `search`/`replace` fails with `old_text must not be empty`. Fixes CODAGT-483 |
||
|
|
02a12fefa8 |
chore: remove the Coder Agents chat board prototype (#30394)
Prototypes shouldn't be on main, so this removes the Coder Agents chat board. It removes the board added in #29425 and extended in #29472, #30094, #30103, #30231 and #30332, plus the hidden `chat-board` experiment from #30084. With them go the route, the sidebar entry and grouping, the settings toggle, the sidebar row trailing slot, and the `chatId` prop on `AgentChatPage`. The abort signal on `getChats` stays, because #30079 uses it outside the board. The board continues in the experimental PR #30395, which is not for merging. |
||
|
|
f0e2fce326 |
fix: let scoped tokens list and mark inbox notifications read (#30176)
`inbox_notification:read` and `inbox_notification:update` existed but weren't in the public scope catalog, so only `coder:all` tokens could use the inbox. The inbox endpoints also returned 500s or a clean socket close when a scope was missing, instead of a 403. - Add `inbox_notification:read` and `inbox_notification:update` to the public scope catalog. `create` stays internal, so there is no `inbox_notification:*`. No migration is needed. - Every inbox endpoint checks scopes up front and returns 403 naming the missing scope. The watch endpoint checks before the websocket upgrade. - `read-status` requires both `read` and `update`. It returns 404 unless the notification belongs to the caller, so an owner can no longer mark another user's notification read. |
||
|
|
7993c73c87 |
feat: add organization-scoped Coder Agents instructions (#30272)
Adds organization-scoped Coder Agents instructions. Organization admins
set them in **Admin settings** > **AI** > **Coder Agents** >
**Organization settings**, or with `GET`/`PUT
/api/v2/organizations/{organization}/chats/config/system-prompt`.
Implements [CODAGT-984](https://linear.app/codercom/issue/CODAGT-984).
The instructions add to the deployment system prompt and never replace
it. When a chat is created, chatd stores the organization prompt as its
own system row right after the deployment row, only for chats in that
organization. Subagents resolve their parent organization's current
prompt when they spawn, and existing chats keep their stored rows.
Access reuses the organization `chat_model_config` permission: owners
and organization admins edit, auditors read, members get 404 on read and
403 on write. Writes reuse the deployment prompt's sanitization, size
limit (128 KiB by default), and audit behavior, with a new
`chat_organization_system_prompt` audit resource type. Migration
`000613` (the next number after `000612` on `main`) adds the
`chat_organization_system_prompts` table.
## Testing
- Go: enterprise authorization (including an update-only custom role),
validation, and audit tests; chatd row order and subagent tests.
- Frontend: Vitest interaction tests and stories for the card (loading,
load error, refetch error over the cached value, save error, read-only).
- Remote dogfood UAT, [evidence
chat](https://dogfood.cdr.dev/agents/b595a709-0709-44e6-9535-96a922974d61):
round 1 **PASS** on `b027cb5ca67` (permission matrix, validation, UI,
row order, cross-organization isolation, audit, subagents, regression).
Round 2 **PASS** on `618bff67c75` (loading and load-error states,
refetch error over the cached value with unsaved edits kept, update-only
custom role saves over the API, row order, the documented size limit,
rapid organization switching, double-click save).
- CI: rebased onto `main` (`98332c739b0`) as `3850fbaa922`; other commit
SHAs in this description are from before the rebase. Every check passed
on `3850fbaa922`, with `test-go-pg` green on the first attempt. After
the review fixes in item 7, `main` was merged in as `006c4951749` to
resolve new conflicts in generated files and renumber the migration to
`000613`. Every check passes on `006c4951749`. Before the rebase, every
check passed on `b4e76543df2`. `test-go-pg (ubuntu-latest)` passed on
its fourth attempt; the first three failed only the `cli` package
goroutine leak check, with every test passing. Two of those leaked a
coderd instance, which also happens intermittently on `main`:
`TestServer/Logging` cancels `coder server` during startup, and an early
return in `cli/server.go` skips closing coderd. That fix is in #30280.
The first attempt leaked an idle HTTP connection instead (not
investigated).
## Screenshots
From remote UAT on a test deployment (test data only).
| Organization admin saves instructions (`b027cb5ca67`) | Auditor sees
read-only instructions, no save actions (`b027cb5ca67`) |
|---|---|
| 
| 
|
| **Loading state while the first fetch is pending (`618bff67c75`)** |
**Refetch error shown above the field; the unsaved edit is kept and Save
stays enabled (`618bff67c75`)** |
| 
| 
|
## Review record
1. Codex,
[review](https://github.com/coder/coder/pull/30272#pullrequestreview-5387245297)
on `c42b5f9e05c`: 6 findings. Fixed the missing loading state, refetch
failures hiding cached instructions, and two docs style issues
(`58eab5603a4`, `cc73b714630`). Two were first declined in error, then
corrected: the read-only test now checks that typing leaves the value
unchanged (`cc73b714630`), and update-only custom roles no longer get a
500 on save (`618bff67c75`).
2. Independent security review by a clean-context agent,
[comment](https://github.com/coder/coder/pull/30272#issuecomment-5943505041)
on `c42b5f9e05c`: no P0 to P2 findings. A stale P3 comment was fixed in
`34c17aadb7f`; returning `err.Error()` in 500 details was kept to match
the deployment prompt handlers.
3. Codex,
[review](https://github.com/coder/coder/pull/30272#pullrequestreview-5387323380)
on `58eab5603a4`: 2 findings (refetch errors not surfaced, docs line
breaks), both fixed in `cc73b714630`.
4. Codex, blockers only,
[review](https://github.com/coder/coder/pull/30272#pullrequestreview-5387462070)
on `618bff67c75`: 1 P2 (a failed refresh right after a successful save
shows the previous value). Not a blocker, deferred.
5. Final fresh advisory by a clean-context agent,
[comment](https://github.com/coder/coder/pull/30272#issuecomment-5944285083)
on `618bff67c75`: **READY**, no blockers and nothing to cut. It
independently checked authorization, audit, the migration, chatd row
insertion and subagent inheritance, the tests, and soft-deleted
organization handling, and agreed with every deferral. No code changes
followed: the snapshot behavior it suggested documenting is already
documented, and its docs wording note joins the deferred docs item.
6. Codex,
[comment](https://github.com/coder/coder/pull/30272#issuecomment-5952100918)
on `b4e76543df2` (the docs-only follow-up below): no major issues. Mike
asked for a passing Codex review loop after item 5, so this review goes
past the planned stop at the final advisory. No code changes followed.
7. ethanndickson,
[review](https://github.com/coder/coder/pull/30272#pullrequestreview-5409332502)
on `3850fbaa922`: approved with 4 comments. Fixed 3: the audit target is
now empty (`91e77d3fa8c`), the docs no longer re-explain audit logs
(`a0fb6891af5`), and the organization instructions stories went from 9
to 5 (`e836097f93f`). Not fixed: the organization prompt read fails open
on a database error, like the deployment prompt, and ethanndickson is
changing both after merge
([thread](https://github.com/coder/coder/pull/30272#discussion_r4180191267)).
UAT did not rerun for these changes.
Not counted as reviews: the pre-PR frontend self-review, simplify pass,
and test audit (`de8377e94e1`), and a second test audit of
`de8377e94e1..cc73b714630` (pass with nits; the update-only test case
was added after it).
Docs-only follow-up after the advisory, requested by Mike: `b4e76543df2`
adds audit log guidance for prompt changes to the platform controls page
and an update-only custom role note to the organizations page. Codex
reviewed it (item 6). No UAT covers it, and the code is unchanged since
`618bff67c75`. The deferred claim that the Instructions page path is
outdated was wrong, so it's dropped. Item 7 removed the audit log
guidance again; the custom role note stays.
## Soft-deleted organizations
UAT found that a soft-deleted organization's prompt stays readable and
writable by UUID. This is inherited behavior, not new exposure:
`ExtractOrganizationParam` resolves UUIDs without a deleted filter, so
the sibling organization chat routes (MCP servers, model overrides,
models) behave the same. The same `chat_model_config` RBAC still
applies, nobody gains access to another organization, and writes are
audited.
## Deferred (owner: Mike)
- A failed refresh right after a successful save shows the previous
value with an error alert, so a further edit from that view starts from
the old text (Codex round 4, UAT round 2). Trigger: reports of stale
values after saving on unreliable networks.
- Update-only custom roles can save over the API, but the card stays
hidden without read access. Trigger: a customer uses such a role.
- Soft-deleted organization access by UUID, above. Trigger: the platform
starts rejecting deleted organizations in `ExtractOrganizationParam` or
purging their configuration.
- A contrived "code word" instruction was refused as possible prompt
injection; neutral instructions work. Trigger: reports of ignored
organization instructions.
- UX polish: there is no retry action after a failed first load, the
save toast can cover Cancel, there is no unsaved-changes guard, the
oversize error omits the limit, and whitespace-only text clears the
prompt without notice. Trigger: the next settings UX pass.
- Docs: the 413 response and organization name paths are undocumented.
Trigger: the next Coder Agents docs pass.
- Test audit nits: a redundant `waitFor` and an optional read-only plus
refetch story. Trigger: the next change to these tests.
> Xum, an AI coding agent, implemented, tested, and opened this PR on
behalf of @ibetitsmike.
|
||
|
|
49b1a2cf5d |
feat: expose per-ref diff statuses (#29082)
Part 2 of 6. Depends on #29081. The API now exposes every ref a chat tracks. All API changes are additive. - `Chat.diff_statuses` lists every ref on the chat GET and in chat lists (including child chats). The order is stable: refs are listed by first report, so the list does not change order when a ref gets a new git report. - `Chat.diff_status` is the primary: the ref with the most recent git report. It is the same rule as before. Use it to find the primary, not the list position. - `ChatDiffStatus` gains `remote_origin` and `git_branch`. - `diff_status_change` watch events carry `changed_diff_status` (`{ref, status}`) naming the ref that changed. If that ref's row is gone, `status` contains only `chat_id`. - `GET /chats/{chat}/diff` accepts optional `origin` and `branch` query parameters. Set both or omit both (otherwise 400). A selector that matches no stored ref returns 404. Without a selector the endpoint returns the primary, as before. The Go SDK adds `WithChatDiffStatusRef` for this. - A git report without a chat ID (for example, from a terminal or an agent older than v2.32) now refreshes only the chats that already track that ref. It does not add the ref to other chats. Such a report can no longer give a chat its first ref. Generated by Coder Agents. |
||
|
|
28cf704f27 |
chore: update references to the relocated install docs paths (#30380)
The Install docs moved into the five-phase spine in #29304, but several references outside `docs/` still point at the pre-move URLs. `docs/redirects.json` is empty, so those URLs 404 rather than forwarding. The release note generators are the user-visible ones: every generated release note links `coder.com/docs/install/releases` and `coder.com/docs/install/upgrade`. | Reference | Was | Now | |---|---|---| | Release schedule links in release notes | `/docs/install/releases` | `/docs/reference/releases` | | Upgrade link in release notes | `/docs/install/upgrade` | `/docs/install/operate/upgrade` | | README sizing link | `/docs/admin/infrastructure/validated-architectures` | `/docs/install/plan/sizing` | | Provisioner tag table comments | `docs/admin/provisioners/index.md` | `docs/install/operate/provisioners/index.md` | | FAQ provenance comment | `docs/admin/licensing/index.md` | `docs/install/prepare/licensing.md` | | ESR 2.24-2.29 upgrade table | `/docs/admin/provisioners` | `/docs/install/operate/provisioners` | | Helm provisioner README, `NOTES.txt`, and `values.yaml` | `/docs/admin/provisioners` | `/docs/install/operate/provisioners` | | Helm Coder chart README | `/docs/install/kubernetes` | `/docs/install/server/kubernetes` | | `workspace-tags` example README | `/docs/admin/provisioners#external-provisioners` | `/docs/install/operate/provisioners#types-of-provisioners` | | `kubernetes-envbox` example README | `/docs/admin/infrastructure/architecture#agents` | `/docs/install/plan/architecture#agents` | `scripts/releaser/docs.go` was already updated in #29304; this covers what that pass missed. Two notes on anchors: - The `#external-provisioners` anchor was already dead before #29304, so it now points at `#types-of-provisioners`, the section covering external, organization-scoped, and user-scoped provisioners. - Every other anchor was verified to still exist on its new page. One link left alone: `provisionerd/provisionerd.go` references `docs/admin/provisioners.md` through a pinned-commit GitHub permalink, which still resolves and shouldn't be rewritten. ## Verification - `go test ./scripts/release/...` passes, including the release note golden strings. - `go build ./scripts/releaser/` succeeds. - `make pre-commit` passes. - Markdown table padding reflowed with `markdown-table-formatter`; `markdownlint` reports no new findings. <sub>Opened by Coder Agents on behalf of @nickvigilante.</sub> |
||
|
|
a08ba6a70c |
feat: add shared project memory API for chats in a project (#29301)
- Experiment, stacked on #29242. UI is in #29583. - Adds **project memory**: `chat_project_memories` rows with a name (lowercase slug, unique per project), a one-line description (150 characters) and a body (8KB). Up to 200 per project, shared by every root chat in the project. Chats outside a project and subagents have no memory. - Memories are immutable: they are created and deleted, never edited. Agent tools are `read_memory`, `save_memory`, `delete_memory` and `consolidate_memory`. Saving an existing name fails and points the agent at `consolidate_memory` to replace it. - **Consolidation is agent-driven, in the turn**, modeled on how Claude Code compacts its memory index when warned it is near its limit. From 160 memories (80%), save results ask the agent to get under 140 (70%) with `consolidate_memory`, choosing what to merge and drop. That tool deletes and saves memories in one transaction under the per-project advisory lock, and rolls back entirely if a delete is missing, a name is taken, or the result exceeds 200. There is no background extraction or consolidation. - **The memory index reaches the model as model-only conversation messages**, not in a tool description or the system prompt. At turn start the chat gets a full `<project-memory-index>` snapshot when its prompt has none (first turn, or after compaction), otherwise a `<project-memory-index-update>` listing only what changed. Tool definitions and the system prompt carry no memory state, so memory writes never invalidate the provider's cached prompt prefix. Writes by other chats, or by this chat mid-turn, reach the model at its next turn. - REST API (create, list, get, delete) under `/api/experimental/organizations/{organization}/chats/projects/{project}/memories`. Memory permissions follow projects onto the `agents-access` role. - **Every memory change is audited** as `ChatProjectMemory` create or delete. REST changes are attributed to the caller. Tool changes (`save_memory`, `delete_memory`, `consolidate_memory`) are attributed to the chat owner, carry the `chat_id`, and record one entry per memory after the change commits, so a rolled-back consolidation records nothing. ### Examples **What the model sees.** The system prompt gets a fixed guidance block with no memory state: ```text <memory> Memory is durable context shared by every chat in the project "platform". Save facts that will matter in future chats: … The memory index is in the conversation: a <project-memory-index> message lists every saved memory, and <project-memory-index-update> messages at the start of later turns list what changed. Changes made during a turn, including your own, appear in the next turn's update. … Memories cannot be edited: replace one that no longer holds with consolidate_memory, or delete it. </memory> ``` On the first turn, after the user's message, the chat gets a model-only row with the full index (hidden in the UI): ```text <project-memory-index> - deploy-day: Deploys happen on Tuesdays - release-owner: Alice owns releases; ping her before tagging </project-memory-index> ``` On a later turn where memories changed, it gets only the difference: ```text <project-memory-index-update> Added or changed: - deploy-day: Deploys happen on Wednesdays (changed 2026-09-30) - staging-url: Staging lives at staging.example.com Removed: - old-ci-notes </project-memory-index-update> ``` Resulting request layout, with the provider's cached prefix unchanged by memory writes: ```text [tools: fixed] [system: fixed <memory> guidance] [turn 1 user] [index snapshot] [assistant/tools …] [turn 2 user] [index update] [assistant …] ``` **Tool calls and results** (produced by the tools in this PR): ```text save_memory {"name":"staging-url","description":"Staging lives at staging.example.com","body":"Staging is https://staging.example.com; deploys from main."} → {"count":3,"saved":"staging-url"} save_memory {"name":"deploy-day", …} // name already exists → error: a memory named "deploy-day" already exists; read it, then replace it with consolidate_memory by deleting "deploy-day" and saving the new version in one call consolidate_memory {"delete":["deploy-day"],"save":[{"name":"deploy-day","description":"Deploys happen on Wednesdays (changed 2026-09-30)","body":"The team deploys every Wednesday since 2026-09-30."}]} → {"count":3,"deleted":["deploy-day"],"saved":["deploy-day"]} read_memory {"name":"deploy-day"} → {"name":"deploy-day","description":"…","body":"…","created_at":"2026-09-30T15:04:05Z","created_by":"alice"} ``` Near and at the cap: ```text save_memory … → {"count":160,"saved":"one-more","warning":"memory is 160/200, approaching the limit. Consolidate it to under 140 memories now with consolidate_memory: merge overlapping memories into one, and drop stale, wrong, or superseded ones."} save_memory … → error: memory is full (200/200); use consolidate_memory to merge overlapping memories and drop stale ones, and include this memory in its save list ``` **REST memory object** (`GET .../chats/projects/{project}/memories`): ```json { "id": "59500000-0000-4000-8000-000000000001", "project_id": "7c0e4a3e-5b1f-4f7d-9a51-2f3c8f6d2b10", "organization_id": "bb640d07-ca8a-4869-b6bc-ae61ebb2fda1", "name": "deploy-day", "description": "Deploys happen on Wednesdays (changed 2026-09-30)", "body": "The team deploys every Wednesday since 2026-09-30.", "created_by": "0ed9befc-4911-4ccf-a8e2-559bf72daa94", "created_by_username": "alice", "created_at": "2026-09-30T15:04:05Z" } ``` Create takes `{"name", "description", "body"}` and answers 409 on a duplicate name or at the cap. <details> <summary>Screenshots (predate the immutable-memory rework; tool output shape has since changed)</summary>    </details> --- Generated with Coder Agents on behalf of @f0ssel. --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
3f444d9528 |
fix: accept 128-character template descriptions on creation (#30348)
> 🤖 This PR was modified by Coder Agents on behalf of Jake Howell.
Template creation rejected descriptions of exactly 128 characters even
though the forms allow them and the database supports them. Change both
the standard and template-builder creation request validators to accept
up to 128 Unicode code points, and regenerate the API schema and
reference.
<details>
<summary>Investigation and scope</summary>
The validator counts Unicode code points, not bytes; the SDK comment is
corrected accordingly. The existing forms remain unchanged: their UTF-16
length checks are conservative for supplementary characters such as
emoji. This fixes the creation off-by-one without broadening frontend
character-count behavior.
</details>
|
||
|
|
3f408825b5 |
docs: add playback controls and descriptions to autoplaying videos (#30263)
## Summary Four docs pages embed autoplaying, looping screencasts with no controls, so readers cannot pause them (WCAG 2.2.2, Level A). This adds `controls` and `muted` to each `<video>` and a one-sentence text description after each video. The renderer-side companion for the beta docs is coder/docs-engine#203. ## Changes - Add `controls` and `muted` to the `<video autoplay playsinline loop>` tag in `external-auth.md`, `open-in-coder.md`, `ai-coder/agents/index.md`, and `compute-engine.md`. `autoplay`, `playsinline`, and `loop` stay. - Add a one-sentence description of each screencast directly below it. - `extending-templates/external-auth.md` is not in `docs/manifest.json`, so it is unpublished. It is fixed for consistency. ## Testing - `pnpm lint-docs` (markdownlint-cli2): 0 errors across 519 files. - `make lint/emdash`, `go run ./scripts/docshtmlcheck`, `go run ./scripts/styleclaims`: pass. - The repo pre-commit hook passed. - Not run: rendering the pages in a browser. The descriptions are inferred from the surrounding prose and file names, not from watching the videos. Linear: [DOCS-1050](https://linear.app/codercom/issue/DOCS-1050) _Generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
bb9f31d94b |
fix: apply Anthropic prompt caching through OpenRouter and OpenAI-compatible gateways (#29563)
Anthropic models configured through an `openrouter` provider (and, by
the same code path, `vercel` and generic `openai-compat` providers)
never got prompt caching. Two independent gaps: chatd only emitted
`cache_control` breakpoints when the fantasy client was `anthropic`, and
even when a client sent them, the AI Gateway chat-completions
interceptor rebuilt the upstream body from typed
`openai.ChatCompletionNewParams` and silently dropped the unknown key.
Dogfood UAT on main @
|
||
|
|
98332c739b |
feat: align MCP workspace tools with Coder Agents and add execute tools (#30275)
The control-plane MCP server's workspace tools now share their
arguments, behavior, and result formats with the Coder Agents tools. The
MCP server also exposes the Coder Agents execute and process tools.
The shared logic lives in a new `codersdk/toolsdk/workspacetools`
package that both `coderd/x/chatd/chattool` and `codersdk/toolsdk` call.
The Coder Agents tool schemas, descriptions, and JSON responses are
unchanged and the existing chattool tests pass unmodified. The one
exception is the missing-shell guidance, which now reads "Workspace
commands run with `sh -c`" instead of naming Coder Agents. Golden files
in `coderd/mcp/testdata/workspace_tools` hold the shared contract for
each tool, and a test checks both the Coder Agents and MCP tools against
them, so contract changes show up in review. The test also fails if MCP
text names a tool that only exists in Coder Agents.
The MCP versions differ from Coder Agents in four ways:
- Each tool takes a `workspace` argument.
- Invalid arguments and agent API errors come back as MCP tool errors.
- A single call waits at most 5 minutes, matching the agent's maximum
blocking wait. Longer timeouts are rejected with a pointer to
`run_in_background`.
- There is no `model_intent` argument.
**Breaking changes to `/api/experimental/mcp/http` and `coder exp
mcp`:**
| Before | After |
|---|---|
| `coder_workspace_read_file`: byte offset/limit, base64 `content` +
`mimeType`, binary-safe | Line-based `offset`/`limit`, text only,
returns `{content, file_size, lines_read, total_lines}` |
| `coder_workspace_write_file`: base64 `content`, binary-safe |
Plain-text `content`, returns `{ok: true}` |
| `coder_workspace_edit_file` + `coder_workspace_edit_files` |
`coder_workspace_edit_files` only, returns `{files: [{path, diff}], ok}`
|
| `coder_workspace_bash` over SSH: `timeout_ms` (default 60s, 5m cap),
kills the command on timeout (exit 124), trims output |
`coder_workspace_execute`: `timeout` (default 10s, 5m cap), `workdir`,
`run_in_background`. On timeout the command keeps running and the result
has `background_process_id`. Output is untrimmed and capped at 32KB. |
| None | `coder_workspace_process_output`,
`coder_workspace_process_list`, `coder_workspace_process_signal` |
`--allowed-tools` lists and templates that name the removed tools will
need updating. A code search found `coder_workspace_bash` in a couple of
demo templates (`coder/demo-env-templates`, partner demos).
<details>
<summary>Decision log</summary>
- **Shared core vs. duplication.** The execute lifecycle has the most
logic that could drift: waiting in the foreground, handing off to the
background on timeout, recovering a snapshot after transport errors, and
truncating output. It's extracted rather than copied, along with
edit-file validation, read-file handling, and result types. Each surface
keeps its own protocol handling: fantasy and MCP response envelopes,
plan-turn restrictions, `model_intent`, and workspace resolution and
authorization. Struct-tag descriptions must be literals, so the
golden-file test is what keeps them in sync with the shared constants.
Shared result structs keep their fields in alphabetical order so the
JSON matches what Coder Agents produced from maps before.
- **Replace instead of add alongside.** Keeping `coder_workspace_bash`
next to `coder_workspace_execute` would give models two overlapping ways
to run commands. The read and write contracts change anyway, so keeping
the old names wouldn't preserve compatibility. The endpoint and CLI
command are both experimental.
- **5-minute cap on MCP calls.** Each stateless MCP request has to
return before the client gives up. Otherwise the `background_process_id`
needed to follow up is lost and the command keeps running with no ID the
model knows about. Coder Agents has no cap, so its behavior is
unchanged.
- **No SSH fallback.** `execute` doesn't fall back to SSH on older
agents, because SSH can't support the process management contract. The
agent process API and line-based reads shipped in February 2026.
- **Process scoping.** The agent scopes processes by chat ID, which
coderd sets only for Coder Agents connections. MCP calls carry no chat
ID, so they can't see or signal Coder Agents chat processes. All MCP
callers share one process namespace per workspace, which means anyone
with SSH access can list and signal processes another MCP user started.
That matches what SSH access already allows. The existing `ActionSSH`
check in `coderd/mcp_http.go` still runs before every agent connection.
Nothing reaps MCP processes; they run until they exit, are signaled, or
the agent stops.
- **Errors.** As in Coder Agents, command failures and timeouts come
back as result JSON (`success: false`, `background_process_id`). Agent
API errors have transport metadata removed, the same way Coder Agents
formats them.
</details>
---
🤖 Generated by Coder Agents on behalf of @kylecarbs.
|
||
|
|
fcbf45c571 |
docs: render audit log resources as one table per resource (#29797)
## Summary The audit logs page now lists each tracked resource in its own section with a simple two-column table, replacing the nested HTML tables that rendered poorly and overflowed on phones. ## Before and after Before, the generated block was a single Markdown table with a malformed `|<b>Resource</b>||` header. Each row held the resource name and its actions in one cell, then split a raw HTML `<table>` of fields across the remaining cells. The result rendered unevenly across renderers, was far wider than the page on mobile, and was hard to navigate with a screen reader. After, each resource gets an `###` heading under **Tracked Events**, which also gives it a linkable anchor. Below the heading, an `Actions:` line lists the audited actions as inline code, followed by a two-column Field and Tracked table with `Yes` or `No` values. Every table uses the same fixed column widths (Field 75%, Tracked 25%), so the Tracked column lines up across all resources. Two narrow columns fit at phone width without horizontal scrolling. Resources with no mapped actions skip the `Actions:` line instead of rendering an empty one. Resource ordering is unchanged. ## Changes - `scripts/auditdocgen/main.go` writes one section per resource. Each fields table is a small HTML table with `width` attributes, because Markdown tables size columns to their content and cannot align across tables. GitHub and the docs site sanitizer both keep `width` but strip inline `style` and `<colgroup>`. - The generator no longer panics when its start marker is the last thing in the file. - New `scripts/auditdocgen/main_test.go` covers section output, marker handling, and idempotent regeneration. - `docs/admin/security/audit-logs.md` is regenerated, and the intro sentence above the block now explains the actions line and the Tracked column. ## How it was regenerated `make docs/admin/security/audit-logs.md`, which builds the generator and runs `markdownlint-cli2 --fix` and `markdown-table-formatter` over the output. Running it a second time produces no diff. ## Testing - `go test ./scripts/auditdocgen/...` passes. - `pnpm exec markdownlint-cli2 docs/admin/security/audit-logs.md` reports 0 errors. Linear: https://linear.app/codercom/issue/DOCS-894 --- 🤖 Built with AI assistance. |
||
|
|
c30b44ad14 |
docs: turn the Quickstart's next steps into goal-based paths (#29800)
## Summary The Quickstart ends with one "customize your template" sentence and a flat "Learn more" list, so a reader who has just launched a workspace has no clear goal for what to do next. This rewrites "What's next?" into three goal-based paths, puts Coder Agents first, and gives readers without a project a small first task. ## Changes - **Hand a task to a coding agent**: what Coder Agents is, that Community deployments can run up to five agents at no cost, the LLM-provider-key prerequisite, and a link to the Coder Agents getting-started guide. Includes a concrete starter prompt idea for readers with no project in mind. - **Make the workspace fit how you work**: the existing Customize your template series, plus dotfiles. - **Bring in your team**: install on a separate machine, create users, and have teammates launch workspaces from the same template. - **Learn more** keeps monitoring and adds the Coder Registry; the workspace-management link moves into the team path. ## Testing - `pnpm exec markdownlint-cli2 docs/get-started/index.md`: 0 errors. - Checked that every relative link target exists on `main`, including the `#create-a-user` anchor. ## Notes - #29304 touches this page (terminology only, in other hunks); the only shared line, `A control plane running locally.`, is already on `main`, so the two should not conflict. - Not a Fumadocs upstream candidate (content only). Linear: https://linear.app/codercom/issue/DOCS-342 --- 🤖 Built with AI assistance. <details> <summary>CI flakes unrelated to this change (rerun)</summary> - `Storybook`: the Pixel upload returned HTTP 500 for many snapshots and the browser context closed mid-run. This PR changes only `docs/get-started/index.md`, so no stories are affected. Failed job rerun. - `Analyze PR for Documentation Updates Needed`: the AI docs check failed before analysis because the bot's Coder account was suspended (`401 User is not active`). Later runs on other PRs pass. Failed job rerun. _Generated by Coder Agents on behalf of @nickvigilante._ </details> --------- Co-authored-by: Ian Evans <5760366+ianjevans@users.noreply.github.com> |
||
|
|
7f3d35353e |
docs: add chat automations documentation (#30220)
Closes CODAGT-1216 Part of CODAGT-1135 Adds an early-access page for chat automations in Coder Agents: `docs/ai-coder/agents/automations.md`. It covers enabling the `chat-automations` experiment and the `off` experiment rule as the operator kill switch, webhooks (endpoint, bearer secret, 256 KiB JSON body, responses, single and multi use, rotation), schedules (cron and time zone, server previews, no catch-up, Run now), **When busy**, the `manage_automations` tool and heartbeats, the per-owner cap and the queue share, and the accepted risks (spend, silent failures, prompt injection). It also adds the manifest entry (early access, after Chat Sharing), a glossary entry, a `manage_automations` row in the built-in tools table, and a link from the experiment-gated features list in Platform Controls. The page documents the code as built on this stack, not the RFC, where they differ. Notable differences: reasoning effort is only offered for new chat targets; schedules accept an occurrence up to 60 seconds late and never replay older ones; the dashboard has no delete control, so delete is documented through the API; `manage_automations` never returns webhook secrets. Dogfood UAT followed the page step by step on a `develop.sh` instance built from this branch (experiment rule on and off, webhook creation and curl deliveries with the documented status codes we could trigger, schedule previews and Run now, the Manage automations switch), and passed. <details> <summary>Where the page's claims come from</summary> | Claim | Source | |---|---| | Experiment name, user-scoped | `codersdk/deployment.go` (`ExperimentChatAutomations`, `ExperimentsUserScoped`) | | Behavior when the experiment is off | `coderd/exp_chat_automations.go` (`requireChatAutomations`, events handler), `coderd/x/chatd/automation_schedules.go` (scan skips owners, keeps cursors) | | Management routes and fields | `coderd/coderd.go`, `codersdk/chatautomations.go`, `coderd/x/chatd/automations.go` (validation) | | Owner-only update, enable, rotate, run | `coderd/x/chatd/automations.go` (`ErrAutomationOwnerOnly`) | | Webhook endpoint, 256 KiB limit, responses | `coderd/exp_chat_automations.go` (events handler, `writeChatAutomationError`), `coderd/exp_chats.go` (`maxChatRequestBodyBytes`) | | Event data wrapping | `coderd/x/chatd/automations_publish.go` (`automationEventText`) | | Rotating a used single-use webhook returns 409 | `coderd/x/chatd/automations.go` (`RotateAutomationSecret`), `AutomationWebhookFields.tsx` (button hidden) | | Events rate limit | `coderd/httpmw/ratelimit.go` (`RateLimitByEndpointKey`), `--api-rate-limit` default 512 | | Cron, time zone, previews | `coderd/schedule/cron/cron.go`, `coderd/exp_chat_automations.go` (`chatAutomationNextRunCount = 5`, schedule preview) | | 30 s scan, 60 s grace, no catch-up | `coderd/x/chatd/automation_schedules.go` (`automationScheduleInterval`, `automationScheduleGrace`) | | When busy, queue share | `coderd/x/chatd/automations_publish.go` (busy check, `max(1, MaxQueuedMessagesPerChat/2)`), `codersdk/chats.go` (default 20) | | manage_automations gating and containment | `coderd/x/chatd/automations_tool.go`, `coderd/exp_chats.go` (`manage_automations_enabled` checks), `AgentChatInput.tsx` | | Per-owner cap | `codersdk/deployment.go` (`--chat-max-automations-per-owner`), `codersdk/chats.go` (default 50) | | Skipped and missed log messages | `coderd/x/chatd/automation_schedules.go` | | Audit fields | `enterprise/audit/table.go` (`prompt` and `webhook_secret_hash` are secret) | Identifiers kept off the page because the reader never types or receives them: `queue_generation`, `schedule_revision`, `schedule_next_run_at`, and the internal error names above. </details> --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_ --------- Signed-off-by: Thomas Kosiewski <tk@coder.com> |
||
|
|
fb0951b850 |
feat: add the manage_automations chat tool switch and read actions (#30214)
Adds the `manage_automations` chat tool with its read and stop actions
(`list`, `get`, `disable`, `delete`), gated by an interim per-chat
switch. Tool sets have not landed, so this ships
`chats.manage_automations_enabled` as the RFC describes for that case;
tool sets later replace it and migrate its values.
Part of CODAGT-1212 (slice 12a of 3). Part of CODAGT-1135.
## What changes
- **Switch.** Migration `000611` adds `chats.manage_automations_enabled`
(default off). It is set through `POST /api/v2/chats` and `PATCH
/api/v2/chats/{chat}`. After creation only the chat owner may send the
field (403 otherwise). Turning it on returns 400 when the
`chat-automations` experiment is off for the chat owner (POST checks the
resolved `owner_id`, not the caller) or when the chat is a sub-agent
chat. Turning it off is always accepted. The audit table tracks it.
- **Offering.** The tool is offered only in root chats, outside plan
mode and explore mode, with the switch on, and with the experiment on
for the chat owner (decided once per turn, like `mcp-tool-search`). It
is not on the plan-mode or explore allowlists, and sub-agent chats are
created with the switch off.
- **Per-call recheck.** Every call reloads the chat and checks all rules
again, with a fresh experiment evaluation, before doing anything.
- **Scoping.** Owner and organization come from the chat, never from
arguments. Reads run as the owner through a new query that filters on
organization and owner. Other members' automations are "not found", even
when the chat owner is an organization admin.
- **Automation-reached turns.** Detected at call time from the full
history (compaction replays user rows without `automation_id`, so the
prompt window is not enough). In such turns only automations that target
the chat or created it (`chats.automation_id`) are visible.
- **Visibility of prompts and deletes.** `list` leaves out prompts (tool
results stay in the chat, which may be shared); `get` returns the prompt
of the automation it names. In a turn an automation reached, `delete`
only removes the triggering automation; the others can still be
disabled.
- **Audit.** `disable` and `delete` go through the management service
and write a background audit entry with `chat_id`, plus the triggering
`automation_id` and `input_id` in reached turns. Results use the API
shape and never contain a secret or secret hash.
`create`, `update`, `enable`, and `run_now` come in the next PR and
return "not available in this version" here.
Follow-up: CODAGT-1270 (bound the history read that reached-turn
detection does on each call).
## Size
About 1,380 hand-written lines: about 460 production, 680 tests, and 240
SQL that has to be there (the `chats_expanded` view rebuilt in both
migrations and the 17 inline column lists). Generated: +649/-280 (sqlc,
dbmock, dbmetrics, dump.sql, apidoc, API and audit docs,
`typesGenerated.ts`).
## Validation
- Unit and DB tests for every rule above (switch 403/400 cases, offering
rules, per-call recheck, owner/org scoping with an org-admin owner,
reached-turn detection including compaction replay, audit fields, secret
scan), plus a separate test audit. Full `make pre-push` passed before
push.
- Remote dogfood UAT passed on this slice: switch API cases, tool absent
with the switch off, in plan mode, in sub-agents and with the experiment
off for the owner (checked in the server's per-step tool lists),
list/get/disable/delete, and a secret scan of all tool output. Audit
entries are verified in Go tests only.
> [!NOTE]
> ARCHITECTURE.md prose was drafted by an agent at the user's request;
the user will review it.
## Stack
Stacked on the Automations for Coder Agents stack (30085 ... 1214b).
Next: slice 12b (write actions), then 12c (composer toggle).
---
_Generated with [`xum`](https://github.com/coder/xum) • Model:
`anthropic:claude-opus-5-5` • Thinking: `high`_
|