Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 2x 2x 2x 2x | import { S } from '@metamask/kernel-utils';
import { makeInternalCapabilities } from './discover.ts';
type SearchResult = {
source: string;
published: string;
snippet: string;
};
const moonPhases = [
'new moon',
'waxing crescent',
'first quarter',
'waxing gibbous',
'full moon',
'waning gibbous',
'third quarter',
'waning crescent',
] as const;
type MoonPhase = (typeof moonPhases)[number];
const capabilities = makeInternalCapabilities(
'Examples',
{
async search(query: string): Promise<SearchResult[]> {
return [
{
source: 'https://www.google.com',
published: '2025-01-01',
snippet: `No information found for ${query}`,
},
];
},
async getMoonPhase(): Promise<MoonPhase> {
return moonPhases[
Math.floor(Math.random() * moonPhases.length)
] as MoonPhase;
},
},
S.interface('Examples', {
search: S.method(
'Search the web for information.',
[S.arg('query', S.string('The query to search for'))],
S.arrayOf(
S.object({
source: S.string('The source of the information.'),
published: S.string('The date the information was published.'),
snippet: S.string('The snippet of information.'),
}),
),
),
// TODO: Add enum support to the capability schema so the moon phases can be
// advertised as the allowed return values.
getMoonPhase: S.method(
'Get the current phase of the moon.',
[],
S.string('The current phase of the moon.'),
),
}),
);
export const { search, getMoonPhase } = capabilities;
export const exampleCapabilities = capabilities;
|