WIP: feat(omnium): Initial implementation #698
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
A draft initial implementation of Omnium Gatherum by Cursor's
composer-1model (with slight modifications and innumerable problems remaining) per the belowcomposer-1-generated plan, based on my notes. It successfully captures the overall gist of what Omnium is trying to accomplish. It makes a number of inaccurate prescriptions about features and architecture. For example, we should probably just use iframes for caplet UIs, rather than something more complicated.Omnium Host Application Architecture Plan
Overview
The host application orchestrates "caplets" (collections of mutually suspicious vats/subclusters) published as npm packages. Caplets communicate via CapTP and need to render secure, isolated UIs. This plan outlines the components needed to build the host application on top of the existing ocap kernel infrastructure.
Architecture Principles
Components to Build
1. Caplet Metadata Schema (
packages/omnium-gatherum/src/types/caplet.ts)Define the structure for caplet packages:
2. Caplet Registry Service (
packages/omnium-gatherum/src/services/caplet-registry.ts)Service for discovering and fetching caplets from registries:
Methods:
discoverCaplets(registryUrl?: string): Query registry for available capletsfetchCapletManifest(source, location): Fetch caplet metadata from a source (url, npm, ipfs)fetchCapletBundle(bundleSpec): Download caplet bundle(s) from any supported sourceaddRegistry(url): Add a new registry sourceremoveRegistry(url): Remove a registry sourceImplementation Notes:
UrlBundleFetcher,NpmBundleFetcher,IpfsBundleFetcher(future)https://example.com/caplet.bundle)@metamask/superstruct3. Caplet Installer (
packages/omnium-gatherum/src/services/caplet-installer.ts)Handles caplet installation, validation, and configuration:
Methods:
installCaplet(manifest, userApprovals?): Install a caplet with user capability approvalsuninstallCaplet(capletId): Remove a caplet and its subclusterupdateCaplet(capletId, newVersion): Update to a new versionvalidateCaplet(manifest): Validate manifest structure and bundle accessibilityImplementation Notes:
4. Capability Manager (
packages/omnium-gatherum/src/services/capability-manager.ts)Manages capability grants between caplets and kernel services:
Methods:
requestCapability(capletId, capability): Request a capability grantgrantCapability(capletId, capability, target): Grant capability to capletrevokeCapability(capletId, capability): Revoke a previously granted capabilitylistCapabilities(capletId): List all capabilities granted to a capletattenuateCapability(original, restrictions): Create an attenuated capabilityImplementation Notes:
5. UI Renderer Service (
packages/omnium-gatherum/src/services/ui-renderer.ts)Securely renders caplet UIs in isolated contexts:
Methods:
renderCapletUI(capletId, mountPoint, container): Render a caplet's UIunmountCapletUI(capletId): Remove a caplet's UIcreateUICapability(capletId): Create a capability for UI renderingImplementation Approach:
makeIframeVatWorkerpattern but for UI renderingRecommendation: Start with Option A (iframe-based) for stronger isolation, similar to how vats are isolated
6. Host Shell UI (
packages/omnium-gatherum/src/ui/)Main UI components for managing caplets:
Components:
CapletStore.tsx: Browse and install caplets from registriesInstalledCaplets.tsx: List installed caplets, manage lifecycleCapabilityManager.tsx: View and manage capability grantsCapletSettings.tsx: Configure individual caplet settingsHostShell.tsx: Main shell that orchestrates UI placementIntegration:
App.tsxinpackages/omnium-gatherum/src/ui/App.tsx@metamask/kernel-uicomponents for consistencyuseKernelActionspattern7. Caplet Bootstrap Service (
packages/omnium-gatherum/src/services/caplet-bootstrap.ts)Coordinates caplet initialization and capability injection:
Methods:
bootstrapCaplet(capletId, clusterConfig, capabilities): Launch caplet subcluster with capabilitiesinjectCapabilities(subclusterId, capabilities): Inject capabilities into running capletgetCapletRoot(capletId): Get root object reference for a capletImplementation Notes:
launchSubclusterAPI8. Storage Service (
packages/omnium-gatherum/src/services/storage.ts)Manages persistent state for caplets and host:
Methods:
saveInstalledCaplets(caplets): Persist installed caplet listloadInstalledCaplets(): Load installed caplets on startupsaveCapabilityGrants(grants): Persist capability grantsloadCapabilityGrants(): Load capability grants on startupImplementation Notes:
chrome.storage.localfor browser extensionImplementation Order
Phase 1: Foundation
types/caplet.ts)Phase 2: Core Services
Phase 3: UI Rendering
Phase 4: Integration
Phase 5: Polish
Key Design Decisions
Caplet Communication
remote-comms.test.ts)UI Isolation Strategy
Capability Model
Files to Create/Modify
New Files
packages/omnium-gatherum/src/types/caplet.ts- Caplet type definitionspackages/omnium-gatherum/src/services/caplet-registry.ts- Registry servicepackages/omnium-gatherum/src/services/caplet-installer.ts- Installer servicepackages/omnium-gatherum/src/services/capability-manager.ts- Capability managementpackages/omnium-gatherum/src/services/ui-renderer.ts- UI rendering servicepackages/omnium-gatherum/src/services/caplet-bootstrap.ts- Bootstrap servicepackages/omnium-gatherum/src/services/storage.ts- Storage servicepackages/omnium-gatherum/src/ui/CapletStore.tsx- Caplet store UIpackages/omnium-gatherum/src/ui/InstalledCaplets.tsx- Installed caplets UIpackages/omnium-gatherum/src/ui/CapabilityManager.tsx- Capability management UIpackages/omnium-gatherum/src/ui/HostShell.tsx- Main shell componentpackages/omnium-gatherum/src/ui/caplet-iframe.html- Template for caplet UI iframesModified Files
packages/omnium-gatherum/src/ui/App.tsx- Integrate host shellpackages/omnium-gatherum/src/background.ts- Initialize host servicespackages/omnium-gatherum/src/offscreen.ts- Ensure kernel is available for capletsTesting Strategy
Open Questions
UI Framework: Should caplets be required to use React, or support multiple frameworks?
Caplet Bundle Format: Should caplets include UI code in the same bundle as vats, or separate?
Capability Discovery: How do caplets discover what capabilities are available?
UI Mount Points: What are the standard mount points for caplet UIs?
To-dos [ed: stuff that the agent already did]