Skip to content

feat: Library writes through the object-storage tools, and Connect leads with the decocms-studio skill - #7885

Merged
viktormarinho merged 8 commits into
mainfrom
viktor/connect-agent-skill
Oct 13, 2026
Merged

viktormarinho merged 8 commits into
mainfrom
viktor/connect-agent-skill

Conversation

@viktormarinho

@viktormarinho viktormarinho commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What is this contribution about?

An agent connected through "Connect your agent to Studio" wrote an HTML page to the Library with PUT_PRESIGNED_URL (key _fs/home/pages/x.html). The bytes reached the bucket, but the file never appeared in the Library. The Library lists from the org_fs_entry index, and only OrgFs.write() maintains it, so a presigned upload that goes straight to S3 is invisible. A raw DELETE_OBJECT on an _fs/ key does the reverse and leaves an index row with no bytes. Separately, the Connect page only offered MCP, and nothing pointed people at the decocms-studio skill and CLI.

This PR includes #7883's commit (it introduced the _fs/ key check and the first skill fixes) and replaces its rejection with working behavior. #7883 is closed in favor of this one.

Object-storage tools now write the Library correctly

  • PUT_PRESIGNED_URL on an _fs/<volume>/<path> key returns a Studio URL instead of an S3 one: PUT /api/<org>/fs/<volume>/upload/<token>. The token is a signed grant for one file, one org and the member who asked, and lasts at most an hour. The route writes through OrgFs.write(), so the file is indexed, quota-checked and announced to mounts like any other fs write. Clients don't change: they still PUT the bytes to the URL they got.
  • The upload route needs no session; the grant is its authentication, the same model as the Jira attachment download grant. resolveOrgFromPath lets it through like the public-share read and unlock routes. It returns 404 for a forged, expired or mismatched grant (other org, other volume).
  • DELETE_OBJECT / DELETE_OBJECTS on _fs/ keys delete through OrgFs.delete(), which removes the index row, or the whole folder for a directory. A key with bytes but no index row (what a raw write used to leave) has its bytes deleted.
  • Both paths apply the fs routes' write rules through one guard (file-storage/org-fs-write-guard.ts): public volumes and repo-synced volumes are read-only, home/users/<id>/ is owner-only, and the volume root is not writable. The upload route checks them again at upload time, since a volume can become a sync mirror after the grant was minted.
  • The HMAC code from jira/attachment-token.ts moved to core/signed-grant.ts so both grant types share it. Upload grants carry purpose: "org-fs-upload" and are validated with a schema, so another grant type signed with the same key is refused.

Connect page

  • "Connect your agent" switches between two tabs, CLI + skill (opens first, marked Recommended) and MCP. Both tabs use the same Claude / Cursor / Codex / Other picker, and the selection carries over between them.
  • CLI + skill, step 1, installs the skill. Claude: claude plugin marketplace add decocms/studio + claude plugin install decocms-studio@decocms. Cursor and Codex: npx skills add decocms/studio --skill decocms-studio -g -a cursor|codex. Other: the same command without -a, so the installer asks.
  • Step 2 is bunx decocms@latest auth login. --target <origin> is added only when the page isn't served from studio.decocms.com (self-hosted or local). "Needs Bun." links to bun.com: the CLI needs the Bun runtime even under npx.
  • The MCP tab keeps the client snippets and the OAuth / API key picker. It notes that sharing Library files and messaging agents still need the CLI.

Skill (decocms-studio 1.0.3)

  • When bunx is missing, the agent asks before installing Bun.
  • When the CLI says Not logged in or Could not refresh session, the agent hands the user the login command. It does not work around a missing session with API keys, MCP tokens or presigned URLs.
  • A Library write counts only once fs/<vol>/stat returns the entry. The agent then gives the Studio link (/<slug>/library?path=…&preview=…) and the direct fs/<vol>/read link.
  • rest.md documents sharing (private / public / password): the agent shares only when asked, and hands back the link and the password together. It also says what the object-storage tools now do with _fs/ keys.

How did you verify your code works?

  • bun run test: 10581 pass, 0 fail. bun run check: every workspace exits 0. The first verify run had 3 timing-based failures (circuit breaker, a web chat store test, the hosted-harness heartbeat) while a dev server and a Postgres were also running. All three pass alone, and the full suite passed on the rerun.
  • New unit tests:
    • upload-grant.test.ts: round trip, expiry, an edited payload, a Jira grant signed with the same key, garbage tokens.
    • put-presigned-url.test.ts: the URL and grant for an _fs/ key, the 1h cap, and refusals for another member's folder, a synced volume, a public volume and the volume root.
    • delete-object.test.ts: indexed delete, deleting stray bytes, a personal-folder refusal, per-key errors in a batch.
    • parseOrgFsKey key spellings. skill-install.test.ts: install command per client, login command with and without --target.
  • New route tests in org-fs.integration.test.ts, run against a migrated throwaway Postgres: an upload without a session is written and indexed; expired, other-org, other-volume and edited grants get 404; another member's folder gets 403. The rest of that file and file-storage/org-fs.integration.test.ts pass too, except the S3 backfill test, which needs an S3 endpoint this machine doesn't have (ECONNREFUSED). CI's storage-integration job covers it.
  • End to end against a local studio, with the CLI from this branch:
    • PUT_PRESIGNED_URL on _fs/home/pages/… returned the Studio URL, an unauthenticated curl -X PUT wrote the file, and stat found it. A tampered token and a URL pointing at another volume got 404. Another member's folder got 403. DELETE_OBJECT removed the file and stat then returned 404.
    • The skill's documented flow: PUT fs/home/file + stat, the Library link opened the file in preview, and anonymous read returned 401 private, the password form in password mode, and 200 public.
  • Both install commands, run against a throwaway config / HOME, copied SKILL.md and rest.md.
  • Not run: the E2E suite, and a login against studio.decocms.com from a fresh machine.

Screenshots/Demonstration

Settings › Connect on a local studio:

CLI + skill, Claude (default)CLI + skill, Cursor
CLI + skill tab with Claude selected CLI + skill tab with Cursor selected
MCP
MCP tab with client tabs and install method

How to Test

  1. Over MCP or decocms tools call, call PUT_PRESIGNED_URL with {"key":"_fs/home/test/a.html"}. Expected: a URL ending in /fs/home/upload/<token>.
  2. curl -X PUT -H "Content-Type: text/html" --data-binary @a.html <url>. Expected: {entry}, and the file is in the Library under test/.
  3. DELETE_OBJECT with the same key. Expected: {success:true} and the file is gone from the Library.
  4. PUT_PRESIGNED_URL with _fs/home/users/<another member's id>/x.md. Expected: 403.
  5. Open Settings › Connect. CLI + skill is selected, and switching clients changes the install command. Run the Claude commands and the login, then ask the agent to put an HTML page in the Library and share it with a password. Expected: it confirms with stat, then returns the Library link, the share link and the password.

Migration Notes

None. Plugin installs pick up 1.0.3 on their next marketplace update. Files written raw under _fs/ before this change stay unindexed. Re-uploading them, or deleting them with DELETE_OBJECT, clears that up.

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working
  • Documentation is updated (skill docs)
  • No breaking changes (non-_fs/ keys behave as before)

@viktormarinho viktormarinho changed the title feat(web): point Connect at the decocms-studio skill and CLI login feat: Library writes through the object-storage tools, and Connect leads with the decocms-studio skill Oct 13, 2026
@viktormarinho
viktormarinho changed the base branch from fix/org-fs-manifest-bypass to main October 13, 2026 16:40
vibegui and others added 7 commits October 13, 2026 13:46
PUT_PRESIGNED_URL, DELETE_OBJECT and DELETE_OBJECTS accept any key, including
`_fs/<volume>/...`, where org filesystem bytes live. The Library lists files
from the `org_fs_entry` index, which only the /api/:org/fs routes write, so an
agent that uploads to `_fs/home/pages/x.html` through a presigned URL gets
bytes in the bucket and nothing in the Library; a raw delete leaves an index
row with no bytes behind.

Reject `_fs/` keys in those three tools (normalized like buildS3Key, so
`a/../_fs/x` and encoded spellings count) and point to the fs route. Fix the
decocms-studio skill, whose rest.md told agents to prefer those tools while
the line above it said to write files through `fs`.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The Connect page only offered MCP snippets, and an agent connected that way
has no route to write Library files. Put the skill install and the one-time
`decocms auth login` first, and keep MCP below for clients without a shell.

The skill now tells the agent to hand the user the login command instead of
working around a missing session, to stat a file before saying it is in the
Library, and how to link and share it (public or password).
CLI + skill opens first and carries a Recommended badge; MCP keeps its client
tabs and install method inside its own tab.
The install step gets the same Claude / Cursor / Codex / Other tabs as MCP,
sharing one selection. Cursor and Codex pass -a to the skills CLI; Other lets
it ask.
The CLI needs the Bun runtime even under npx, so the skill now has the agent
offer to install Bun when bunx is missing, and the Connect hint links to it.
…tools

Instead of rejecting _fs/ keys, PUT_PRESIGNED_URL hands out a Studio upload
URL carrying a signed, one-file grant (at most an hour), and the new
PUT /api/:org/fs/:volume/upload/:token route writes it through OrgFs, so the
file lands in the Library index. DELETE_OBJECT(S) delete _fs/ keys through
OrgFs too, and remove bytes a raw write left unindexed.

Both apply the fs routes' rules (public and synced volumes read-only,
personal folders owner-only); the upload route checks them again at upload
time. The HMAC grant code shared with Jira attachment downloads moves to
core/signed-grant.ts, and upload grants carry a purpose field so another
grant type signed with the same key never passes.
Library writes work over MCP now; sharing files and messaging agents remain
REST-only.
@viktormarinho
viktormarinho force-pushed the viktor/connect-agent-skill branch from c06b50b to 6182c7d Compare October 13, 2026 16:46
@viktormarinho
viktormarinho merged commit 974e41e into main Oct 13, 2026
33 of 34 checks passed
@viktormarinho
viktormarinho deleted the viktor/connect-agent-skill branch October 13, 2026 17:10
decocms Bot pushed a commit that referenced this pull request Oct 13, 2026
PR: #7885 feat: Library writes through the object-storage tools, and Connect leads with the decocms-studio skill
Bump type: minor

- decocms (apps/api/package.json): 4.470.0 -> 4.471.0
- @decocms/native (apps/native/package.json): 4.470.0 -> 4.471.0
- @decocms/e2e (packages/e2e/package.json): 1.104.0 -> 1.105.0

Deploy-Scope: both
pedrofrxncx added a commit that referenced this pull request Oct 15, 2026
…home folder (#7976)

GET_PRESIGNED_URL hands back a presigned download URL for any key in the
org's bucket, including `_fs/home/users/<id>/...` — the Library's
object-storage addressing for org-fs bytes. That bypasses the personal-home
carve-out the `/api/:org/fs` routes and PUT_PRESIGNED_URL already enforce
(org-fs.ts's ACL note: every member reads/writes every volume except another
member's `home/users/<id>/` folder), letting any org member read a
teammate's private notes by presigning the raw key instead of going through
the fs read route.

Reject `_fs/` keys whose path falls inside another member's personal home,
mirroring the `requireOrgFsWrite` guard PUT_PRESIGNED_URL already applies on
the write side (see #7885).

Reviewer: run `bun test apps/api/src/tools/object-storage/get-presigned-url.test.ts`.

Verified locally: `bun run fmt`, `tsc --noEmit` in apps/api, the targeted
test file above (3 pass), and `oxlint` on the three changed files (clean).
Full CI validates the rest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants