{"id":21332390,"url":"https://github.com/binlabs/window-ai-manager","last_synced_at":"2026-01-06T08:05:02.873Z","repository":{"id":242293200,"uuid":"809179024","full_name":"binlabs/window-ai-manager","owner":"binlabs","description":"A library for managing AI text sessions in the browser using the window.ai API. Currently, this library is only compatible with the Chrome browser.","archived":false,"fork":false,"pushed_at":"2024-06-03T00:19:43.000Z","size":482,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T00:58:48.679Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-01T23:41:03.000Z","updated_at":"2024-06-03T00:19:46.000Z","dependencies_parsed_at":"2024-06-02T01:36:13.180Z","dependency_job_id":"f098e750-f7f3-4017-8843-9ab4f845a142","html_url":"https://github.com/binlabs/window-ai-manager","commit_stats":null,"previous_names":["binlabs/window-ai-manager"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binlabs%2Fwindow-ai-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binlabs%2Fwindow-ai-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binlabs%2Fwindow-ai-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binlabs%2Fwindow-ai-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binlabs","download_url":"https://codeload.github.com/binlabs/window-ai-manager/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245718786,"owners_count":20661161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T22:47:47.884Z","updated_at":"2026-01-06T08:05:02.794Z","avatar_url":"https://github.com/binlabs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WindowAIManager\n\nA library for managing AI text sessions in the browser using the `window.ai` API.\n\n## Description\n\n`WindowAIManager` is a JavaScript library (written in Typescript) designed to facilitate interactions with AI text sessions in the browser. It leverages the `window.ai` API, which is available in desktop versions of Chrome starting from version 127.0.6512.0. This library includes functionalities for creating, managing, and destroying AI text sessions, as well as rendering markdown to HTML using the `marked` library internally.\n\n## Installation\n\nTo install the library, use npm:\n\n```bash\nnpm install window-ai-manager\n```\n\n## Usage\n\n### Basic Usage\n\n```js\nconst WindowAIManager = require('window-ai-manager')\nconst aiManager = new WindowAIManager()\n\nasync function main() {\n    // Check if a text session can be created\n    const canCreate = await aiManager.canCreateSession()\n    console.log('Can create session:', canCreate)\n\n    // Create a new session\n    if (canCreate !== 'no') {\n        await aiManager.createSession('session1')\n        console.log('Session created')\n\n        // Send a prompt and get the response\n        const response = await aiManager.prompt('session1', 'Write me a poem')\n        console.log('AI Response:', response)\n\n        // Send a streaming prompt\n        await aiManager.promptStreaming('session1', 'Write me an extra-long poem', (chunk) =\u003e {\n            console.log('Streaming chunk:', chunk)\n        })\n\n        // Destroy the session\n        await aiManager.destroySession('session1')\n        console.log('Session destroyed')\n    }\n}\n\nmain().catch(console.error)\n```\n\n### Markdown Rendering\n\n```javascript\nconst WindowAIManager = require('window-ai-manager')\nconst aiManager = new WindowAIManager()\n\nconst markdown = '# Hello, world!'\nconst html = aiManager.renderMarkdown(markdown)\nconsole.log('Rendered HTML:', html)\n```\n\n### Destroying All Sessions\n\n```javascript\nconst WindowAIManager = require('window-ai-manager')\nconst aiManager = new WindowAIManager()\n\nasync function main() {\n    await aiManager.createSession('session1')\n    await aiManager.createSession('session2')\n\n    // Destroy all sessions\n    await aiManager.destroyAllSessions()\n    console.log('All sessions destroyed')\n}\n\nmain().catch(console.error)\n```\n\n## Requirements\n\nThis library only works in desktop versions of Chrome starting from version 127.0.6512.0. It uses the window.ai API, which is currently available only in development channel releases of Chrome.\n\n## API\n\n`canCreateSession(): Promise\u003c'readily' | 'after-download' | 'no'\u003e`\nChecks if a text session can be created.\n\n`createSession(sessionId: string): Promise\u003cvoid\u003e`\nCreates a new text session with the given session ID.\n\n`prompt(sessionId: string, text: string): Promise\u003cstring\u003e`\nSends a prompt to the specified session and returns the response.\n\n`promptStreaming(sessionId: string, text: string, onChunkReceived: (chunk: string) =\u003e void): Promise\u003cstring\u003e`\nSends a streaming prompt to the specified session and processes the chunks received.\n\n`destroySession(sessionId: string): Promise\u003cvoid\u003e`\nDestroys the specified session and removes it from the map.\n\n`destroyAllSessions(): Promise\u003cvoid\u003e`\nDestroys all active sessions and clears the map.\n\n`renderMarkdown(markdown: string): string`\nRenders markdown text to HTML.\n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinlabs%2Fwindow-ai-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinlabs%2Fwindow-ai-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinlabs%2Fwindow-ai-manager/lists"}