| 1 | import os from "os"; |
| 2 | |
| 3 | import { |
| 4 | ContextItem, |
| 5 | ContextProviderDescription, |
| 6 | ContextProviderExtras, |
| 7 | } from "../../index.js"; |
| 8 | import { BaseContextProvider } from "../index.js"; |
| 9 | |
| 10 | class OSContextProvider extends BaseContextProvider { |
| 11 | static description: ContextProviderDescription = { |
| 12 | title: "os", |
| 13 | displayTitle: "Operating System", |
| 14 | description: "Operating system and CPU Information.", |
| 15 | type: "normal", |
| 16 | }; |
| 17 | |
| 18 | async getContextItems( |
| 19 | query: string, |
| 20 | extras: ContextProviderExtras, |
| 21 | ): Promise<ContextItem[]> { |
| 22 | const cpu = os.arch(); |
| 23 | const platform = os.platform(); |
| 24 | return [ |
| 25 | { |
| 26 | description: "Your operating system and CPU", |
| 27 | content: `I am running ${ |
| 28 | platform === "win32" ? "Windows" : platform |
| 29 | } on ${cpu}.`, |
| 30 | name: "Operating System", |
| 31 | }, |
| 32 | ]; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | export default OSContextProvider; |