[PR #5092] [MERGED] feat(capability-packages): contributions.assets — general package asset delivery (Capability API 1.10) #6625

Closed
opened 2026-10-23 04:12:09 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5092
Author: @kolacheee
Created: 8/15/2026
Status: ✅ Merged
Merged: 8/15/2026
Merged by: @kolacheee

Base: staging ← Head: feat/5091-package-asset-paths


📝 Commits (7)

  • b094fda feat(capability-packages): contributions.assets — general package asset delivery (Capability API 1.10, #5091)
  • 30394ab Merge branch 'staging' into feat/5091-package-asset-paths
  • fe0efd4 fix(capability-packages): apply CodeRabbit review to #5092
  • 2a7b9e5 Merge remote-tracking branch 'origin/feat/5091-package-asset-paths' into feat/5091-package-asset-paths
  • 15ee1f2 fix(capability-packages): drop immutable asset caching; hash-verify every served body
  • 8f34188 fix(capability-packages): drop unused stat import left by the verification-cache removal
  • ee41cb5 Merge branch 'staging' into feat/5091-package-asset-paths

📊 Changes

8 files changed (+445 additions, -164 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/development/optional-agent-packages.md (+36 -5)
📝 packages/client/src/components/capabilities/CapabilityElement.tsx (+6 -1)
📝 packages/server/src/routes/capability-packages.routes.ts (+22 -28)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+75 -86)
📝 packages/shared/src/schemas/capability-package.schema.ts (+108 -9)
📝 scripts/regressions/capability-package-cache.regression.ts (+123 -20)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+73 -15)

📄 Description

Closes #5091

Why

An installed Agent package can serve at most two images over HTTP, and only by declaring the home-browser-tab slot — contributions.homeBrowserTab.iconPaths is the only allowlist the asset route consults. A package that needs real art or data files (the driving case: a game-surface Experience shipping a tileset, sprite atlas, and tilemap JSON) cannot ship them at all; the workarounds are inlining art as data: URIs into a bundle that must already be a single file, or abusing unrelated upload routes.

What changed

Capability API 1.10 — contributions.assets (packages/shared/src/schemas/capability-package.schema.ts):

  • A manifest may declare assets.paths — up to 256 relative paths, image extensions (png/webp/gif/jpeg) plus .json for tilemap/atlas metadata. No SVG/HTML/scripts — active documents stay off this same-origin route.
  • Every declared path must be hash-pinned in files[] (superRefine, fails at install with a clear message). The pre-existing icon-paths ⊆ files[] check is hoisted out of the home-browser-tab slot branch so it now applies whenever iconPaths is present — previously a manifest could carry unvalidated icon paths by omitting the slot.
  • contributions.assets is gated on schemaVersion 2 + capabilityApi ≥ 1.10, so authors get the versioned compatibility message instead of a cryptic strict-schema error on older Engines. supportedCapabilityApi bumps to {1, 10}.

Serving (package-manager.service.ts, capability-packages.routes.ts):

  • browserTabAsset is generalized to packageAsset: the allowlist becomes the union of iconPaths and assets.paths; nothing else in the verification chain moves (path containment, files[] membership, content-type allowlist, hash + TOCTOU re-verification on every read). .json joins the content-type map; manifest.json is explicitly refused.
  • Declared-path normalization is throw-safe: a single unsafe declared path is treated as "not servable" instead of turning every asset request for that package into a 500. On-disk integrity failures still throw loudly (the lifecycle regression pins that posture — tampering is never a quiet 404).
  • With #5082's caching, an asset requested with ?v=<installed version> is served public, max-age=31536000, immutable — a shipped tileset costs one download per version.

Forward compatibility (review-found blocker): catalog parsing was all-or-nothing over strict schemas, so the first published package using any future manifest key would have bricked the entire Agents browser (and install/update paths) on every older Engine. New parseCapabilityCatalogWithCompat parses the envelope, validates entries individually, and drops+logs entries this Engine can't understand — pinned by a new lifecycle-regression case. Publishing note: an assets-declaring package should still wait until 1.10 Engines are widely installed, since only Engines with this PR have tolerant catalog parsing.

Install hardening (review-found): duplicate-file detection is now case-folded — on NTFS/APFS, Tiles.PNG + tiles.png extract onto one file and the losing declaration's hash could never verify; such manifests are now rejected at install.

Client (CapabilityElement.tsx): every capability element now receives capabilityProps.packageId and capabilityProps.packageVersion, giving packages a supported way to build the version-pinned URL (previously the documented immutable path was unreachable without re-fetching /installed or scraping import.meta.url).

Docs + release notes: docs/development/optional-agent-packages.md gains the Capability API 1.10 section; CHANGELOG.md gains entries for 1.10 assets and (previously missed) the #5082 caching change.

Regressions: the cache/serving lane now covers declared nested image + JSON serving (content types, ETag, immutable-when-pinned), undeclared/secret files staying 404, manifest.json refusal, dot-segment behavior at both the HTTP layer (framework collapses to the declared path) and the resolver layer (direct unit calls return null), the 1.10 gate (v2-with-old-API and v1 manifests rejected), SVG rejection, and unpinned-path rejection. The lifecycle lane covers the mixed-generation catalog and the 1.10 version pins.

Validation

  • pnpm check
  • pnpm regression:capability-cache
  • capability-package-lifecycle + capability-client-version-refresh regressions
  • pnpm regression:docs
  • pnpm version:check (no version fields touched)
  • Manually verify a home-browser-tab package's icons still render and hierarchical-maps still installs/serves after the schema change.
  • Manually verify a dev-installed package declaring contributions.assets serves its files and shows them cached immutable on a ?v=-pinned request.

Known considerations, deliberately out of scope: the serve path buffers whole files (pre-existing primitive shared with icons; per-file size is already capped by files[].bytes); the installed-registry parse is still all-or-nothing on Engine downgrade (same tolerant-parse pattern could apply later); internal helper names (verifyBrowserTabAsset) keep their old names to keep this diff reviewable.

Docs note: the docs/development/optional-agent-packages.md edit needs a docs-i18n mirror — intended to be batched with the pending round-8 catch-up.

Summary by CodeRabbit

  • New Features
    • Added support for serving package-owned image and JSON assets through Capability API 1.10.
    • Added verified, manifest-declared asset paths with restricted content types and protection against undeclared or unsafe files.
    • Added immutable, version-pinned caching and ETags, including 304 Not Modified responses for unchanged assets.
  • Bug Fixes
    • Catalogs now omit incompatible entries individually instead of rejecting the entire catalog.
  • Documentation
    • Documented package-owned static asset configuration and usage.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/5092 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/15/2026 **Status:** ✅ Merged **Merged:** 8/15/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/5091-package-asset-paths` --- ### 📝 Commits (7) - [`b094fda`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b094fda9de10f2d83e63b059369ba483b19153a5) feat(capability-packages): contributions.assets — general package asset delivery (Capability API 1.10, #5091) - [`30394ab`](https://github.com/Pasta-Devs/Marinara-Engine/commit/30394ab747e1d0f30dbc38901b62b7cd4b50fc9e) Merge branch 'staging' into feat/5091-package-asset-paths - [`fe0efd4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fe0efd4e12306c76cca0c87d4bd96c398195e4d7) fix(capability-packages): apply CodeRabbit review to #5092 - [`2a7b9e5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2a7b9e5833db75f6d395b1bf109e466cc3ebecee) Merge remote-tracking branch 'origin/feat/5091-package-asset-paths' into feat/5091-package-asset-paths - [`15ee1f2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/15ee1f2fd157a9c5206d8f0b1614a169491e2cc7) fix(capability-packages): drop immutable asset caching; hash-verify every served body - [`8f34188`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8f341883656d167fc3179d97dc888118bccef352) fix(capability-packages): drop unused stat import left by the verification-cache removal - [`ee41cb5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ee41cb5e840022a431d2f3493935c2fddbf58ea6) Merge branch 'staging' into feat/5091-package-asset-paths ### 📊 Changes **8 files changed** (+445 additions, -164 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/development/optional-agent-packages.md` (+36 -5) 📝 `packages/client/src/components/capabilities/CapabilityElement.tsx` (+6 -1) 📝 `packages/server/src/routes/capability-packages.routes.ts` (+22 -28) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+75 -86) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+108 -9) 📝 `scripts/regressions/capability-package-cache.regression.ts` (+123 -20) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+73 -15) </details> ### 📄 Description Closes #5091 ## Why An installed Agent package can serve at most **two** images over HTTP, and only by declaring the `home-browser-tab` slot — `contributions.homeBrowserTab.iconPaths` is the only allowlist the asset route consults. A package that needs real art or data files (the driving case: a `game-surface` Experience shipping a tileset, sprite atlas, and tilemap JSON) cannot ship them at all; the workarounds are inlining art as `data:` URIs into a bundle that must already be a single file, or abusing unrelated upload routes. ## What changed **Capability API 1.10 — `contributions.assets`** (`packages/shared/src/schemas/capability-package.schema.ts`): - A manifest may declare `assets.paths` — up to 256 relative paths, image extensions (`png`/`webp`/`gif`/`jpeg`) plus `.json` for tilemap/atlas metadata. **No SVG/HTML/scripts** — active documents stay off this same-origin route. - Every declared path must be hash-pinned in `files[]` (superRefine, fails at install with a clear message). The pre-existing icon-paths ⊆ `files[]` check is hoisted out of the `home-browser-tab` slot branch so it now applies whenever `iconPaths` is present — previously a manifest could carry unvalidated icon paths by omitting the slot. - `contributions.assets` is gated on `schemaVersion 2` + `capabilityApi ≥ 1.10`, so authors get the versioned compatibility message instead of a cryptic strict-schema error on older Engines. `supportedCapabilityApi` bumps to `{1, 10}`. **Serving** (`package-manager.service.ts`, `capability-packages.routes.ts`): - `browserTabAsset` is generalized to `packageAsset`: the allowlist becomes the union of `iconPaths` and `assets.paths`; **nothing else in the verification chain moves** (path containment, `files[]` membership, content-type allowlist, hash + TOCTOU re-verification on every read). `.json` joins the content-type map; `manifest.json` is explicitly refused. - Declared-path normalization is throw-safe: a single unsafe declared path is treated as "not servable" instead of turning every asset request for that package into a 500. On-disk integrity failures still **throw loudly** (the lifecycle regression pins that posture — tampering is never a quiet 404). - With #5082's caching, an asset requested with `?v=<installed version>` is served `public, max-age=31536000, immutable` — a shipped tileset costs one download per version. **Forward compatibility (review-found blocker)**: catalog parsing was all-or-nothing over strict schemas, so the *first* published package using any future manifest key would have bricked the entire Agents browser (and install/update paths) on every older Engine. New `parseCapabilityCatalogWithCompat` parses the envelope, validates entries individually, and drops+logs entries this Engine can't understand — pinned by a new lifecycle-regression case. **Publishing note:** an assets-declaring package should still wait until 1.10 Engines are widely installed, since only Engines with this PR have tolerant catalog parsing. **Install hardening (review-found)**: duplicate-file detection is now case-folded — on NTFS/APFS, `Tiles.PNG` + `tiles.png` extract onto one file and the losing declaration's hash could never verify; such manifests are now rejected at install. **Client** (`CapabilityElement.tsx`): every capability element now receives `capabilityProps.packageId` and `capabilityProps.packageVersion`, giving packages a supported way to build the version-pinned URL (previously the documented immutable path was unreachable without re-fetching `/installed` or scraping `import.meta.url`). **Docs + release notes**: `docs/development/optional-agent-packages.md` gains the Capability API 1.10 section; `CHANGELOG.md` gains entries for 1.10 assets and (previously missed) the #5082 caching change. **Regressions**: the cache/serving lane now covers declared nested image + JSON serving (content types, ETag, immutable-when-pinned), undeclared/secret files staying 404, `manifest.json` refusal, dot-segment behavior at both the HTTP layer (framework collapses to the declared path) and the resolver layer (direct unit calls return null), the 1.10 gate (v2-with-old-API and v1 manifests rejected), SVG rejection, and unpinned-path rejection. The lifecycle lane covers the mixed-generation catalog and the 1.10 version pins. ## Validation - [x] `pnpm check` - [x] `pnpm regression:capability-cache` - [x] capability-package-lifecycle + capability-client-version-refresh regressions - [x] `pnpm regression:docs` - [x] `pnpm version:check` (no version fields touched) - [x] Manually verify a home-browser-tab package's icons still render and hierarchical-maps still installs/serves after the schema change. - [x] Manually verify a dev-installed package declaring `contributions.assets` serves its files and shows them cached `immutable` on a `?v=`-pinned request. Known considerations, deliberately out of scope: the serve path buffers whole files (pre-existing primitive shared with icons; per-file size is already capped by `files[].bytes`); the installed-registry parse is still all-or-nothing on Engine *downgrade* (same tolerant-parse pattern could apply later); internal helper names (`verifyBrowserTabAsset`) keep their old names to keep this diff reviewable. Docs note: the `docs/development/optional-agent-packages.md` edit needs a docs-i18n mirror — intended to be batched with the pending round-8 catch-up. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for serving package-owned image and JSON assets through Capability API 1.10. * Added verified, manifest-declared asset paths with restricted content types and protection against undeclared or unsafe files. * Added immutable, version-pinned caching and ETags, including `304 Not Modified` responses for unchanged assets. * **Bug Fixes** * Catalogs now omit incompatible entries individually instead of rejecting the entire catalog. * **Documentation** * Documented package-owned static asset configuration and usage. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:12:09 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6625
No description provided.