Skip to content

Commit bd1d749

Browse files
rekmarksclaude
andcommitted
feat(omnium): Expose caplet manifests in background console
Add omnium.manifests.echo so users can install caplets from the console: await omnium.caplet.install(omnium.manifests.echo) Changes: - Create src/manifests.ts with echo caplet manifest using chrome.runtime.getURL - Add echo-caplet.bundle to vite static copy targets - Expose manifests in background.ts via omnium.manifests - Update global.d.ts with manifests type and missing getCapletRoot Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 2855c73 commit bd1d749

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

packages/omnium-gatherum/src/background.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
makeChromeStorageAdapter,
2121
} from './controllers/index.ts';
2222
import type { CapletManifest, LaunchResult } from './controllers/index.ts';
23+
import { manifests } from './manifests.ts';
2324

2425
defineGlobals();
2526

@@ -154,6 +155,9 @@ async function main(): Promise<void> {
154155
getKernel: {
155156
value: getKernel,
156157
},
158+
manifests: {
159+
value: manifests,
160+
},
157161
caplet: {
158162
value: harden({
159163
install: async (manifest: CapletManifest, bundle?: unknown) =>

packages/omnium-gatherum/src/global.d.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ declare global {
4040
*/
4141
getKernel: () => Promise<KernelFacade>;
4242

43+
/**
44+
* Pre-defined caplet manifests for convenience.
45+
*
46+
* @example
47+
* ```typescript
48+
* await omnium.caplet.install(omnium.manifests.echo);
49+
* ```
50+
*/
51+
manifests: {
52+
echo: CapletManifest;
53+
};
54+
4355
/**
4456
* Caplet management API.
4557
*/
@@ -98,6 +110,19 @@ declare global {
98110
getByService: (
99111
serviceName: string,
100112
) => Promise<InstalledCaplet | undefined>;
113+
114+
/**
115+
* Get the root object presence for a caplet.
116+
*
117+
* @param capletId - The caplet ID.
118+
* @returns A promise for the caplet's root object (as a CapTP presence).
119+
* @example
120+
* ```typescript
121+
* const root = await omnium.caplet.getCapletRoot('com.example.echo');
122+
* const result = await E(root).echo('Hello!');
123+
* ```
124+
*/
125+
getCapletRoot: (capletId: string) => Promise<unknown>;
101126
};
102127
};
103128
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { CapletManifest } from './controllers/caplet/types.ts';
2+
3+
/**
4+
* Get the extension URL for a bundle file.
5+
*
6+
* @param bundleName - Name of the bundle file (e.g., 'echo-caplet.bundle')
7+
* @returns chrome-extension:// URL string
8+
*/
9+
function getBundleUrl(bundleName: string): string {
10+
return chrome.runtime.getURL(bundleName);
11+
}
12+
13+
/**
14+
* Manifest for the echo-caplet.
15+
*
16+
* This Caplet provides a simple "echo" service that returns
17+
* the input message with an "Echo: " prefix.
18+
*
19+
* Usage:
20+
* - Provides: "echo" service
21+
* - Requests: No services (standalone)
22+
*/
23+
export const echoCapletManifest: CapletManifest = harden({
24+
id: 'com.example.echo',
25+
name: 'Echo Service',
26+
version: '1.0.0',
27+
bundleSpec: getBundleUrl('echo-caplet.bundle'),
28+
requestedServices: [],
29+
providedServices: ['echo'],
30+
});
31+
32+
/**
33+
* All available caplet manifests for use in the console.
34+
*/
35+
export const manifests = harden({
36+
echo: echoCapletManifest,
37+
});

packages/omnium-gatherum/vite.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ const staticCopyTargets: readonly (string | Target)[] = [
3838
'packages/omnium-gatherum/src/manifest.json',
3939
// Trusted prelude-related
4040
'packages/kernel-shims/dist/endoify.js',
41+
// Caplet bundles
42+
'packages/omnium-gatherum/src/vats/echo-caplet.bundle',
4143
];
4244

4345
const endoifyImportStatement = `import './endoify.js';`;

0 commit comments

Comments
 (0)