ai-vault 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +287 -0
  3. package/dist/cli.d.ts +6 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +49 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/providers/_template/index.d.ts +35 -0
  8. package/dist/providers/_template/index.d.ts.map +1 -0
  9. package/dist/providers/_template/index.js +146 -0
  10. package/dist/providers/_template/index.js.map +1 -0
  11. package/dist/providers/base.d.ts +34 -0
  12. package/dist/providers/base.d.ts.map +1 -0
  13. package/dist/providers/base.js +91 -0
  14. package/dist/providers/base.js.map +1 -0
  15. package/dist/providers/grok/index.d.ts +47 -0
  16. package/dist/providers/grok/index.d.ts.map +1 -0
  17. package/dist/providers/grok/index.js +250 -0
  18. package/dist/providers/grok/index.js.map +1 -0
  19. package/dist/providers/index.d.ts +21 -0
  20. package/dist/providers/index.d.ts.map +1 -0
  21. package/dist/providers/index.js +35 -0
  22. package/dist/providers/index.js.map +1 -0
  23. package/dist/types/index.d.ts +141 -0
  24. package/dist/types/index.d.ts.map +1 -0
  25. package/dist/types/index.js +5 -0
  26. package/dist/types/index.js.map +1 -0
  27. package/dist/types/provider.d.ts +85 -0
  28. package/dist/types/provider.d.ts.map +1 -0
  29. package/dist/types/provider.js +25 -0
  30. package/dist/types/provider.js.map +1 -0
  31. package/dist/types/schemas.d.ts +532 -0
  32. package/dist/types/schemas.d.ts.map +1 -0
  33. package/dist/types/schemas.js +106 -0
  34. package/dist/types/schemas.js.map +1 -0
  35. package/dist/utils/api-client.d.ts +54 -0
  36. package/dist/utils/api-client.d.ts.map +1 -0
  37. package/dist/utils/api-client.js +138 -0
  38. package/dist/utils/api-client.js.map +1 -0
  39. package/dist/utils/scraper.d.ts +58 -0
  40. package/dist/utils/scraper.d.ts.map +1 -0
  41. package/dist/utils/scraper.js +146 -0
  42. package/dist/utils/scraper.js.map +1 -0
  43. package/package.json +91 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AI Vault Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,287 @@
1
+ # ๐Ÿ›๏ธ AI Vault
2
+
3
+ **Own your data.** Open-source CLI tool for comprehensive archival of AI interactionsโ€”conversations, generated images, videos, code artifacts, and all metadataโ€”across multiple platforms.
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue.svg)](https://www.typescriptlang.org/)
7
+ [![Node](https://img.shields.io/badge/Node-%3E%3D18.0.0-green.svg)](https://nodejs.org/)
8
+
9
+ ## ๐ŸŽฏ Mission
10
+
11
+ Your AI interactions are valuable assets. They contain your thoughts, research, creative work, problem-solving, generated media, and code artifacts. But they live in siloed platforms, controlled by different companies, subject to data loss, policy changes, or account restrictions.
12
+
13
+ **AI Vault** gives you back complete control with:
14
+
15
+ - ๐Ÿ”„ **Automated daily backups** - Set it and forget it
16
+ - ๐ŸŽฏ **Smart targeting** - Archive what matters, skip the noise
17
+ - ๐Ÿ“ฆ **Multi-platform support** - ChatGPT, Claude, Grok, Gemini, and more
18
+ - ๐Ÿ–ผ๏ธ **Complete media preservation** - Images, videos, diagrams, code artifacts with intelligent deduplication
19
+ - ๐Ÿ“ **Full conversation history** - Every message, timestamp, metadata, and context
20
+ - ๐Ÿ  **Local-first** - Your data stays on your machine, encrypted and secure
21
+ - ๐Ÿ”Œ **Plugin architecture** - Easy to extend with new providers
22
+
23
+ ## โœจ Features
24
+
25
+ ### Supported Platforms
26
+
27
+ | Platform | Status | API Support | Web Scraping | Media Download |
28
+ | --------------- | -------------- | ----------- | ------------ | -------------- |
29
+ | **Grok (X.AI)** | ๐Ÿšง In Progress | โœ… | โœ… | โœ… |
30
+ | **ChatGPT** | ๐Ÿ“‹ Planned | โœ… | โœ… | โœ… |
31
+ | **Claude** | ๐Ÿ“‹ Planned | โœ… | โœ… | โœ… |
32
+ | **Gemini** | ๐Ÿ“‹ Planned | โš ๏ธ Partial | โœ… | โœ… |
33
+ | **Perplexity** | ๐Ÿ“‹ Planned | โŒ | โœ… | โœ… |
34
+
35
+ ### Smart Features
36
+
37
+ - **Incremental Backups** - Only fetch new/updated conversations
38
+ - **Media Deduplication** - Don't store the same image twice
39
+ - **Flexible Scheduling** - Daily, weekly, or custom cron expressions
40
+ - **Rich Export Formats** - JSON, Markdown, HTML with metadata
41
+ - **Automatic Cookie Management** - Extract session cookies from your browser
42
+ - **Filtering & Targeting** - Date ranges, conversation importance, custom queries
43
+
44
+ ## ๐Ÿ“ฆ Installation
45
+
46
+ ### Quick Install (All Platforms)
47
+
48
+ ```bash
49
+ curl -fsSL https://raw.githubusercontent.com/dotCipher/ai-vault/main/install.sh | bash
50
+ ```
51
+
52
+ Or with wget:
53
+
54
+ ```bash
55
+ wget -qO- https://raw.githubusercontent.com/dotCipher/ai-vault/main/install.sh | bash
56
+ ```
57
+
58
+ ### Package Managers
59
+
60
+ **npm (All Platforms)**
61
+
62
+ ```bash
63
+ npm install -g ai-vault
64
+ ```
65
+
66
+ **pnpm (All Platforms)**
67
+
68
+ ```bash
69
+ pnpm install -g ai-vault
70
+ ```
71
+
72
+ **Homebrew (macOS)**
73
+
74
+ ```bash
75
+ brew install node@22
76
+ npm install -g ai-vault
77
+ ```
78
+
79
+ _Coming soon: Direct Homebrew tap for native installation without Node.js_
80
+
81
+ ### From Source (Development)
82
+
83
+ ```bash
84
+ git clone https://github.com/dotCipher/ai-vault.git
85
+ cd ai-vault
86
+ pnpm install && pnpm run build
87
+ ```
88
+
89
+ ### Updating
90
+
91
+ **npm/pnpm**
92
+
93
+ ```bash
94
+ npm update -g ai-vault
95
+ # or
96
+ pnpm update -g ai-vault
97
+ ```
98
+
99
+ **Homebrew (once tap is available)**
100
+
101
+ ```bash
102
+ brew upgrade ai-vault
103
+ ```
104
+
105
+ **Check current version**
106
+
107
+ ```bash
108
+ ai-vault --version
109
+ ```
110
+
111
+ ### Uninstalling
112
+
113
+ **npm/pnpm**
114
+
115
+ ```bash
116
+ npm uninstall -g ai-vault
117
+ # or
118
+ pnpm uninstall -g ai-vault
119
+ ```
120
+
121
+ **Homebrew (once tap is available)**
122
+
123
+ ```bash
124
+ brew uninstall ai-vault
125
+ ```
126
+
127
+ **Remove configuration and data** (optional)
128
+
129
+ ```bash
130
+ # macOS/Linux
131
+ rm -rf ~/.config/ai-vault
132
+ rm -rf ~/ai-vault-data
133
+
134
+ # Windows
135
+ rmdir /s %APPDATA%\ai-vault
136
+ rmdir /s %USERPROFILE%\ai-vault-data
137
+ ```
138
+
139
+ ## ๐Ÿš€ Quick Start
140
+
141
+ ```bash
142
+ # Interactive setup wizard
143
+ ai-vault setup
144
+
145
+ # Run your first archive
146
+ ai-vault archive
147
+
148
+ # Schedule automated backups
149
+ ai-vault schedule --daily
150
+
151
+ # List archived conversations
152
+ ai-vault list
153
+ ```
154
+
155
+ ## ๐Ÿ“– Usage
156
+
157
+ ### Setup
158
+
159
+ ```bash
160
+ ai-vault setup
161
+ ```
162
+
163
+ The interactive wizard will:
164
+
165
+ 1. Choose which AI platforms to archive
166
+ 2. Configure authentication (API keys or browser cookies)
167
+ 3. Set your backup preferences
168
+ 4. Choose export formats
169
+
170
+ ### Archive Now
171
+
172
+ ```bash
173
+ # Archive all configured platforms
174
+ ai-vault archive
175
+
176
+ # Archive specific platform
177
+ ai-vault archive --provider grok
178
+
179
+ # Archive with date filter
180
+ ai-vault archive --since 2025-01-01
181
+
182
+ # Dry run (see what would be archived)
183
+ ai-vault archive --dry-run
184
+ ```
185
+
186
+ ### Schedule Automated Backups
187
+
188
+ ```bash
189
+ # Set up daily backups
190
+ ai-vault schedule --daily
191
+
192
+ # Custom cron expression
193
+ ai-vault schedule --cron "0 2 * * *" # Every day at 2 AM
194
+
195
+ # View scheduled jobs
196
+ ai-vault schedule --list
197
+ ```
198
+
199
+ ### List Archived Conversations
200
+
201
+ ```bash
202
+ # List all archived conversations
203
+ ai-vault list
204
+
205
+ # Filter by provider
206
+ ai-vault list --provider chatgpt
207
+
208
+ # Search by keyword
209
+ ai-vault list --search "machine learning"
210
+ ```
211
+
212
+ ## ๐Ÿ—๏ธ Architecture
213
+
214
+ AI Vault uses a **plugin-based provider architecture** that makes it easy to add new AI platforms:
215
+
216
+ ```
217
+ src/
218
+ โ”œโ”€โ”€ providers/ # Pluggable AI platform providers
219
+ โ”‚ โ”œโ”€โ”€ base.ts # Abstract Provider interface
220
+ โ”‚ โ”œโ”€โ”€ grok/ # Grok (X.AI) implementation
221
+ โ”‚ โ”œโ”€โ”€ chatgpt/ # ChatGPT implementation
222
+ โ”‚ โ””โ”€โ”€ claude/ # Claude implementation
223
+ โ”œโ”€โ”€ core/ # Core archival logic
224
+ โ”‚ โ”œโ”€โ”€ archiver.ts # Main archival orchestration
225
+ โ”‚ โ”œโ”€โ”€ storage.ts # Local storage management
226
+ โ”‚ โ”œโ”€โ”€ media.ts # Media download & dedup
227
+ โ”‚ โ””โ”€โ”€ scheduler.ts # Backup scheduling
228
+ โ”œโ”€โ”€ cli/ # CLI commands
229
+ โ””โ”€โ”€ types/ # Shared TypeScript types
230
+ ```
231
+
232
+ See [ARCHITECTURE.md](docs/architecture.md) for details.
233
+
234
+ ## ๐Ÿค Contributing
235
+
236
+ We welcome contributions! Whether you want to:
237
+
238
+ - Add support for a new AI platform
239
+ - Improve existing providers
240
+ - Add features or fix bugs
241
+ - Improve documentation
242
+
243
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
244
+
245
+ ### Adding a New Provider
246
+
247
+ Adding a new AI platform takes ~30 minutes:
248
+
249
+ 1. Copy `src/providers/_template/` to your new provider
250
+ 2. Implement the `Provider` interface
251
+ 3. Add authentication method
252
+ 4. Implement conversation fetching
253
+ 5. Add tests and documentation
254
+
255
+ See [docs/providers.md](docs/providers.md) for a detailed guide.
256
+
257
+ ## ๐Ÿ“‹ Roadmap
258
+
259
+ - [x] Project setup and architecture
260
+ - [ ] Grok provider (API + scraping)
261
+ - [ ] ChatGPT provider
262
+ - [ ] Claude provider
263
+ - [ ] Media downloader with deduplication
264
+ - [ ] Smart filtering system
265
+ - [ ] Scheduling with cron/launchd
266
+ - [ ] Gemini provider
267
+ - [ ] Perplexity provider
268
+ - [ ] Export to knowledge management tools (Obsidian, Notion)
269
+ - [ ] Search across all archived conversations
270
+ - [ ] Web UI for browsing archives
271
+
272
+ ## ๐Ÿ“„ License
273
+
274
+ MIT License - see [LICENSE](LICENSE) for details.
275
+
276
+ ## ๐Ÿ™ Acknowledgments
277
+
278
+ Built with:
279
+
280
+ - [Playwright](https://playwright.dev/) - Web automation
281
+ - [Commander.js](https://github.com/tj/commander.js) - CLI framework
282
+ - [Clack](https://github.com/natemoo-re/clack) - Interactive prompts
283
+ - [Zod](https://zod.dev/) - Schema validation
284
+
285
+ ---
286
+
287
+ **Remember:** Your data is yours. Keep it safe. ๐Ÿ›๏ธ
package/dist/cli.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AI Vault CLI
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;GAEG"}
package/dist/cli.js ADDED
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * AI Vault CLI
4
+ */
5
+ import { Command } from 'commander';
6
+ import chalk from 'chalk';
7
+ const program = new Command();
8
+ program
9
+ .name('ai-vault')
10
+ .description('Own your data. Archive AI conversations across multiple platforms.')
11
+ .version('1.0.0');
12
+ program
13
+ .command('setup')
14
+ .description('Interactive setup wizard')
15
+ .action(async () => {
16
+ console.log(chalk.blue('Setup wizard coming soon!'));
17
+ console.log(chalk.gray('This will help you configure providers and authentication.'));
18
+ });
19
+ program
20
+ .command('archive')
21
+ .description('Archive conversations from configured providers')
22
+ .option('-p, --provider <provider>', 'Specific provider to archive')
23
+ .option('--since <date>', 'Archive conversations since date')
24
+ .option('--dry-run', 'Preview what would be archived without downloading')
25
+ .action(async (options) => {
26
+ console.log(chalk.blue('Archive command coming soon!'));
27
+ console.log(chalk.gray('Options:'), options);
28
+ });
29
+ program
30
+ .command('list')
31
+ .description('List archived conversations')
32
+ .option('-p, --provider <provider>', 'Filter by provider')
33
+ .option('--search <query>', 'Search conversations')
34
+ .action(async (options) => {
35
+ console.log(chalk.blue('List command coming soon!'));
36
+ console.log(chalk.gray('Options:'), options);
37
+ });
38
+ program
39
+ .command('schedule')
40
+ .description('Configure automated backup schedule')
41
+ .option('--daily', 'Schedule daily backups')
42
+ .option('--cron <expression>', 'Custom cron expression')
43
+ .option('--list', 'List scheduled jobs')
44
+ .action(async (options) => {
45
+ console.log(chalk.blue('Schedule command coming soon!'));
46
+ console.log(chalk.gray('Options:'), options);
47
+ });
48
+ program.parse();
49
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,oEAAoE,CAAC;KACjF,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,0BAA0B,CAAC;KACvC,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,SAAS,CAAC;KAClB,WAAW,CAAC,iDAAiD,CAAC;KAC9D,MAAM,CAAC,2BAA2B,EAAE,8BAA8B,CAAC;KACnE,MAAM,CAAC,gBAAgB,EAAE,kCAAkC,CAAC;KAC5D,MAAM,CAAC,WAAW,EAAE,oDAAoD,CAAC;KACzE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,6BAA6B,CAAC;KAC1C,MAAM,CAAC,2BAA2B,EAAE,oBAAoB,CAAC;KACzD,MAAM,CAAC,kBAAkB,EAAE,sBAAsB,CAAC;KAClD,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,qCAAqC,CAAC;KAClD,MAAM,CAAC,SAAS,EAAE,wBAAwB,CAAC;KAC3C,MAAM,CAAC,qBAAqB,EAAE,wBAAwB,CAAC;KACvD,MAAM,CAAC,QAAQ,EAAE,qBAAqB,CAAC;KACvC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC,CAAC;IACzD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Template for creating new AI platform providers
3
+ *
4
+ * To create a new provider:
5
+ * 1. Copy this directory to src/providers/yourplatform/
6
+ * 2. Rename the class and implement all methods
7
+ * 3. Add provider name to types/index.ts ProviderName type
8
+ * 4. Register in src/providers/index.ts
9
+ * 5. Create documentation in docs/providers/yourplatform.md
10
+ */
11
+ import { BaseProvider } from '../base';
12
+ import type { ProviderConfig, Conversation } from '../../types';
13
+ import type { ListConversationsOptions, ConversationSummary } from '../../types/provider';
14
+ export declare class TemplateProvider extends BaseProvider {
15
+ readonly name: any;
16
+ readonly displayName = "Template Provider";
17
+ readonly supportedAuthMethods: ('api-key' | 'cookies' | 'oauth')[];
18
+ /**
19
+ * Authenticate with the provider
20
+ */
21
+ authenticate(config: ProviderConfig): Promise<boolean>;
22
+ /**
23
+ * Check if currently authenticated
24
+ */
25
+ isAuthenticated(): Promise<boolean>;
26
+ /**
27
+ * List all conversations
28
+ */
29
+ listConversations(options?: ListConversationsOptions): Promise<ConversationSummary[]>;
30
+ /**
31
+ * Fetch complete conversation with all messages
32
+ */
33
+ fetchConversation(id: string): Promise<Conversation>;
34
+ }
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/_template/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAG1F,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,QAAQ,CAAC,IAAI,EAAa,GAAG,CAAC;IAC9B,QAAQ,CAAC,WAAW,uBAAuB;IAC3C,QAAQ,CAAC,oBAAoB,EAAE,CAAC,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC,EAAE,CAA0B;IAE5F;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAsC5D;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAYzC;;OAEG;IACG,iBAAiB,CAAC,OAAO,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAqC3F;;OAEG;IACG,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CA4D3D"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Template for creating new AI platform providers
3
+ *
4
+ * To create a new provider:
5
+ * 1. Copy this directory to src/providers/yourplatform/
6
+ * 2. Rename the class and implement all methods
7
+ * 3. Add provider name to types/index.ts ProviderName type
8
+ * 4. Register in src/providers/index.ts
9
+ * 5. Create documentation in docs/providers/yourplatform.md
10
+ */
11
+ import { BaseProvider } from '../base';
12
+ import { AuthenticationError, NotFoundError } from '../../types/provider';
13
+ export class TemplateProvider extends BaseProvider {
14
+ name = 'grok'; // Change to your provider name (must match ProviderName type)
15
+ displayName = 'Template Provider'; // Human-readable name
16
+ supportedAuthMethods = ['api-key', 'cookies']; // Supported auth methods
17
+ /**
18
+ * Authenticate with the provider
19
+ */
20
+ async authenticate(config) {
21
+ this.config = config;
22
+ // Example: API key authentication
23
+ if (config.authMethod === 'api-key') {
24
+ if (!config.apiKey) {
25
+ throw new AuthenticationError('API key is required');
26
+ }
27
+ this.initClient('https://api.yourplatform.com', {
28
+ Authorization: `Bearer ${config.apiKey}`,
29
+ });
30
+ // Test authentication
31
+ await this.client.get('/auth/verify');
32
+ return true;
33
+ }
34
+ // Example: Cookie authentication
35
+ if (config.authMethod === 'cookies') {
36
+ if (!config.cookies) {
37
+ throw new AuthenticationError('Cookies are required');
38
+ }
39
+ const cookieString = Object.entries(config.cookies)
40
+ .map(([key, value]) => `${key}=${value}`)
41
+ .join('; ');
42
+ this.initClient('https://yourplatform.com', {
43
+ Cookie: cookieString,
44
+ });
45
+ return this.isAuthenticated();
46
+ }
47
+ throw new AuthenticationError(`Unsupported auth method: ${config.authMethod}`);
48
+ }
49
+ /**
50
+ * Check if currently authenticated
51
+ */
52
+ async isAuthenticated() {
53
+ this.requireAuth();
54
+ try {
55
+ // Make a test request to verify authentication
56
+ await this.client.get('/api/user/me');
57
+ return true;
58
+ }
59
+ catch {
60
+ return false;
61
+ }
62
+ }
63
+ /**
64
+ * List all conversations
65
+ */
66
+ async listConversations(options) {
67
+ this.requireAuth();
68
+ const params = {
69
+ limit: options?.limit || 100,
70
+ offset: options?.offset || 0,
71
+ };
72
+ if (options?.since) {
73
+ params.since = options.since.toISOString();
74
+ }
75
+ if (options?.until) {
76
+ params.until = options.until.toISOString();
77
+ }
78
+ try {
79
+ const response = await this.client.get('/api/conversations', { params });
80
+ // Transform API response to ConversationSummary format
81
+ return response.data.conversations.map((conv) => ({
82
+ id: conv.id,
83
+ title: conv.title || 'Untitled',
84
+ messageCount: conv.message_count,
85
+ createdAt: new Date(conv.created_at),
86
+ updatedAt: new Date(conv.updated_at),
87
+ hasMedia: conv.has_media || false,
88
+ preview: conv.preview_text,
89
+ }));
90
+ }
91
+ catch (error) {
92
+ if (error.response?.status === 401) {
93
+ throw new AuthenticationError('Session expired');
94
+ }
95
+ throw error;
96
+ }
97
+ }
98
+ /**
99
+ * Fetch complete conversation with all messages
100
+ */
101
+ async fetchConversation(id) {
102
+ this.requireAuth();
103
+ try {
104
+ const response = await this.client.get(`/api/conversations/${id}`);
105
+ const data = response.data;
106
+ // Transform API response to Conversation format
107
+ return {
108
+ id: data.id,
109
+ provider: this.name,
110
+ title: data.title || 'Untitled',
111
+ messages: data.messages.map((msg) => ({
112
+ id: msg.id,
113
+ role: msg.role,
114
+ content: msg.content,
115
+ timestamp: new Date(msg.timestamp),
116
+ metadata: msg.metadata || {},
117
+ attachments: msg.attachments?.map((att) => ({
118
+ id: att.id,
119
+ type: att.type,
120
+ url: att.url,
121
+ mimeType: att.mime_type,
122
+ size: att.size,
123
+ })),
124
+ })),
125
+ createdAt: new Date(data.created_at),
126
+ updatedAt: new Date(data.updated_at),
127
+ metadata: {
128
+ messageCount: data.messages.length,
129
+ characterCount: data.messages.reduce((sum, m) => sum + m.content.length, 0),
130
+ mediaCount: data.messages.reduce((sum, m) => sum + (m.attachments?.length || 0), 0),
131
+ ...data.metadata,
132
+ },
133
+ };
134
+ }
135
+ catch (error) {
136
+ if (error.response?.status === 404) {
137
+ throw new NotFoundError(`Conversation ${id} not found`);
138
+ }
139
+ if (error.response?.status === 401) {
140
+ throw new AuthenticationError('Session expired');
141
+ }
142
+ throw error;
143
+ }
144
+ }
145
+ }
146
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/providers/_template/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1E,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IACvC,IAAI,GAAG,MAAa,CAAC,CAAC,8DAA8D;IACpF,WAAW,GAAG,mBAAmB,CAAC,CAAC,sBAAsB;IACzD,oBAAoB,GAAwC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,yBAAyB;IAEtH;;OAEG;IACH,KAAK,CAAC,YAAY,CAAC,MAAsB;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,kCAAkC;QAClC,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACnB,MAAM,IAAI,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;YACvD,CAAC;YAED,IAAI,CAAC,UAAU,CAAC,8BAA8B,EAAE;gBAC9C,aAAa,EAAE,UAAU,MAAM,CAAC,MAAM,EAAE;aACzC,CAAC,CAAC;YAEH,sBAAsB;YACtB,MAAM,IAAI,CAAC,MAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;YACvC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,iCAAiC;QACjC,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,mBAAmB,CAAC,sBAAsB,CAAC,CAAC;YACxD,CAAC;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,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,EAAE,CAAC;gBACnC,MAAM,IAAI,aAAa,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;YAC1D,CAAC;YACD,IAAI,KAAK,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,EAAE,CAAC;gBACnC,MAAM,IAAI,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;YACnD,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CAaF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Abstract base provider class with shared functionality
3
+ */
4
+ import type { Provider, ListConversationsOptions, ConversationSummary, MediaDownloadResult } from '../types/provider';
5
+ import type { ProviderName, ProviderConfig, Conversation } from '../types';
6
+ import { AxiosInstance } from 'axios';
7
+ export declare abstract class BaseProvider implements Provider {
8
+ abstract readonly name: ProviderName;
9
+ abstract readonly displayName: string;
10
+ abstract readonly supportedAuthMethods: ('api-key' | 'cookies' | 'oauth')[];
11
+ protected config?: ProviderConfig;
12
+ protected client?: AxiosInstance;
13
+ /**
14
+ * Initialize HTTP client with authentication
15
+ */
16
+ protected initClient(baseURL: string, headers?: Record<string, string>): void;
17
+ abstract authenticate(config: ProviderConfig): Promise<boolean>;
18
+ abstract isAuthenticated(): Promise<boolean>;
19
+ abstract listConversations(options?: ListConversationsOptions): Promise<ConversationSummary[]>;
20
+ abstract fetchConversation(id: string): Promise<Conversation>;
21
+ /**
22
+ * Default implementation for downloading media files
23
+ */
24
+ downloadMedia(url: string, outputPath: string): Promise<MediaDownloadResult>;
25
+ /**
26
+ * Helper to check if authentication is configured
27
+ */
28
+ protected requireAuth(): void;
29
+ /**
30
+ * Helper for exponential backoff retry
31
+ */
32
+ protected retry<T>(fn: () => Promise<T>, maxRetries?: number, baseDelay?: number): Promise<T>;
33
+ }
34
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/providers/base.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