v16.ai 0.2.15 → 0.3.0

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.
@@ -0,0 +1,513 @@
1
+ # Browser Automation & Workflow System
2
+
3
+ The V16 local agent now includes powerful browser automation capabilities with secure credential management, workflow automation, web search, and email checking.
4
+
5
+ ## Features
6
+
7
+ ### 1. **Secure Credential Vault**
8
+ - AES-256-GCM encryption for passwords and API keys
9
+ - Stores credentials locally on your machine
10
+ - Master key protection
11
+ - Domain-based credential lookup
12
+
13
+ ### 2. **Workflow Automation**
14
+ - Step-by-step browser automation
15
+ - Credential injection into forms
16
+ - Screenshot capture after each step
17
+ - Error handling and recovery
18
+
19
+ ### 3. **Web Search**
20
+ - Google and DuckDuckGo integration
21
+ - Result extraction and parsing
22
+ - Information extraction from web pages
23
+
24
+ ### 4. **Email Checking**
25
+ - Gmail and Outlook support
26
+ - Check inbox, search emails, find unread
27
+ - Read specific email content
28
+
29
+ ### 5. **Session Persistence**
30
+ - Save browser sessions (cookies, localStorage)
31
+ - Restore sessions to avoid repeated logins
32
+ - Domain-based session management
33
+
34
+ ## API Endpoints
35
+
36
+ ### Credential Management
37
+
38
+ ```bash
39
+ # Store a credential
40
+ POST /api/local-agent/credentials
41
+ {
42
+ "name": "My Gmail Password",
43
+ "type": "password",
44
+ "domain": "gmail.com",
45
+ "username": "user@gmail.com",
46
+ "value": "secret123"
47
+ }
48
+
49
+ # List all credentials
50
+ GET /api/local-agent/credentials
51
+
52
+ # Get specific credential
53
+ GET /api/local-agent/credentials/:id
54
+
55
+ # Delete credential
56
+ DELETE /api/local-agent/credentials/:id
57
+
58
+ # Find credentials by domain
59
+ GET /api/local-agent/credentials/domain/gmail.com
60
+ ```
61
+
62
+ ### Workflow Management
63
+
64
+ ```bash
65
+ # Create workflow
66
+ POST /api/local-agent/workflows
67
+ {
68
+ "name": "Gmail Login",
69
+ "description": "Automated Gmail login",
70
+ "steps": [
71
+ {
72
+ "action": "navigate",
73
+ "value": "https://mail.google.com"
74
+ },
75
+ {
76
+ "action": "type",
77
+ "selector": "input[type='email']",
78
+ "credentialId": "credential-id-here"
79
+ },
80
+ {
81
+ "action": "click",
82
+ "selector": "button[type='submit']"
83
+ }
84
+ ],
85
+ "credentialIds": ["credential-id-here"]
86
+ }
87
+
88
+ # List workflows
89
+ GET /api/local-agent/workflows
90
+
91
+ # Execute workflow
92
+ POST /api/local-agent/workflows/:id/execute
93
+ ```
94
+
95
+ ### Web Search
96
+
97
+ ```bash
98
+ # Search the web
99
+ POST /api/local-agent/search
100
+ {
101
+ "query": "latest news on AI",
102
+ "maxResults": 10,
103
+ "engine": "google" // or "duckduckgo" or "auto"
104
+ }
105
+
106
+ # Extract information
107
+ POST /api/local-agent/search/extract
108
+ {
109
+ "query": "weather in New York",
110
+ "task": "Get current temperature"
111
+ }
112
+ ```
113
+
114
+ ### Email Checking
115
+
116
+ ```bash
117
+ # Check emails
118
+ POST /api/local-agent/email/check
119
+ {
120
+ "provider": "gmail", // or "outlook"
121
+ "maxEmails": 20
122
+ }
123
+
124
+ # Search emails
125
+ POST /api/local-agent/email/search
126
+ {
127
+ "provider": "gmail",
128
+ "query": "from:someone@example.com"
129
+ }
130
+
131
+ # Get unread emails
132
+ POST /api/local-agent/email/unread
133
+ {
134
+ "provider": "gmail"
135
+ }
136
+
137
+ # Read specific email
138
+ POST /api/local-agent/email/read
139
+ {
140
+ "provider": "gmail",
141
+ "emailIdentifier": "subject query or from:email"
142
+ }
143
+ ```
144
+
145
+ ### Session Management
146
+
147
+ ```bash
148
+ # Save current browser session
149
+ POST /api/local-agent/sessions/save
150
+ {
151
+ "domain": "gmail.com",
152
+ "name": "Gmail Session"
153
+ }
154
+
155
+ # Restore session
156
+ POST /api/local-agent/sessions/restore
157
+ {
158
+ "sessionId": "session-credential-id"
159
+ }
160
+
161
+ # List sessions
162
+ GET /api/local-agent/sessions
163
+
164
+ # Delete session
165
+ DELETE /api/local-agent/sessions/:id
166
+ ```
167
+
168
+ ## Example Workflows
169
+
170
+ ### Example 1: Gmail Login and Check Unread
171
+
172
+ ```json
173
+ {
174
+ "name": "Gmail Morning Check",
175
+ "description": "Login to Gmail and check unread emails",
176
+ "steps": [
177
+ {
178
+ "stepId": "step-1",
179
+ "action": "navigate",
180
+ "value": "https://mail.google.com"
181
+ },
182
+ {
183
+ "stepId": "step-2",
184
+ "action": "wait",
185
+ "waitMs": 2000
186
+ },
187
+ {
188
+ "stepId": "step-3",
189
+ "action": "screenshot"
190
+ }
191
+ ],
192
+ "credentialIds": []
193
+ }
194
+ ```
195
+
196
+ ### Example 2: LinkedIn Profile Update
197
+
198
+ ```json
199
+ {
200
+ "name": "Update LinkedIn Profile",
201
+ "description": "Navigate to LinkedIn and update profile headline",
202
+ "steps": [
203
+ {
204
+ "stepId": "step-1",
205
+ "action": "navigate",
206
+ "value": "https://www.linkedin.com/in/me/"
207
+ },
208
+ {
209
+ "stepId": "step-2",
210
+ "action": "wait",
211
+ "waitMs": 2000
212
+ },
213
+ {
214
+ "stepId": "step-3",
215
+ "action": "click",
216
+ "selector": "button[aria-label='Edit intro']"
217
+ },
218
+ {
219
+ "stepId": "step-4",
220
+ "action": "wait",
221
+ "waitMs": 1000
222
+ },
223
+ {
224
+ "stepId": "step-5",
225
+ "action": "type",
226
+ "selector": "input[name='headline']",
227
+ "value": "AI Engineer | Building the Future"
228
+ },
229
+ {
230
+ "stepId": "step-6",
231
+ "action": "click",
232
+ "selector": "button[type='submit']"
233
+ },
234
+ {
235
+ "stepId": "step-7",
236
+ "action": "screenshot"
237
+ }
238
+ ],
239
+ "credentialIds": []
240
+ }
241
+ ```
242
+
243
+ ### Example 3: Research Automation
244
+
245
+ ```json
246
+ {
247
+ "name": "Market Research",
248
+ "description": "Search for competitor information and extract data",
249
+ "steps": [
250
+ {
251
+ "stepId": "step-1",
252
+ "action": "navigate",
253
+ "value": "https://www.google.com"
254
+ },
255
+ {
256
+ "stepId": "step-2",
257
+ "action": "type",
258
+ "selector": "textarea[name='q']",
259
+ "value": "best AI coding assistants 2026"
260
+ },
261
+ {
262
+ "stepId": "step-3",
263
+ "action": "click",
264
+ "selector": "input[type='submit']"
265
+ },
266
+ {
267
+ "stepId": "step-4",
268
+ "action": "wait",
269
+ "waitMs": 3000
270
+ },
271
+ {
272
+ "stepId": "step-5",
273
+ "action": "screenshot"
274
+ },
275
+ {
276
+ "stepId": "step-6",
277
+ "action": "extract",
278
+ "selector": "#search"
279
+ }
280
+ ],
281
+ "credentialIds": []
282
+ }
283
+ ```
284
+
285
+ ### Example 4: Form Filling with Credentials
286
+
287
+ ```json
288
+ {
289
+ "name": "Automated Form Submission",
290
+ "description": "Fill out a contact form with saved credentials",
291
+ "steps": [
292
+ {
293
+ "stepId": "step-1",
294
+ "action": "navigate",
295
+ "value": "https://example.com/contact"
296
+ },
297
+ {
298
+ "stepId": "step-2",
299
+ "action": "type",
300
+ "selector": "input[name='name']",
301
+ "credentialId": "name-credential-id"
302
+ },
303
+ {
304
+ "stepId": "step-3",
305
+ "action": "type",
306
+ "selector": "input[name='email']",
307
+ "credentialId": "email-credential-id"
308
+ },
309
+ {
310
+ "stepId": "step-4",
311
+ "action": "type",
312
+ "selector": "textarea[name='message']",
313
+ "value": "Hello, I'm interested in your product."
314
+ },
315
+ {
316
+ "stepId": "step-5",
317
+ "action": "click",
318
+ "selector": "button[type='submit']"
319
+ },
320
+ {
321
+ "stepId": "step-6",
322
+ "action": "wait",
323
+ "waitMs": 2000
324
+ },
325
+ {
326
+ "stepId": "step-7",
327
+ "action": "screenshot"
328
+ }
329
+ ],
330
+ "credentialIds": ["name-credential-id", "email-credential-id"]
331
+ }
332
+ ```
333
+
334
+ ## Session Persistence Best Practices
335
+
336
+ ### Saving a Session
337
+
338
+ After logging in to a website manually (e.g., Gmail), save the session:
339
+
340
+ ```bash
341
+ curl -X POST http://localhost:3000/api/local-agent/sessions/save \
342
+ -H "Content-Type: application/json" \
343
+ -H "x-user-id: your-user-id" \
344
+ -d '{
345
+ "domain": "gmail.com",
346
+ "name": "My Gmail Session"
347
+ }'
348
+ ```
349
+
350
+ ### Restoring a Session
351
+
352
+ Before running a workflow, restore the saved session:
353
+
354
+ ```bash
355
+ curl -X POST http://localhost:3000/api/local-agent/sessions/restore \
356
+ -H "Content-Type: application/json" \
357
+ -H "x-user-id: your-user-id" \
358
+ -d '{
359
+ "sessionId": "session-credential-id"
360
+ }'
361
+ ```
362
+
363
+ ## Security Considerations
364
+
365
+ 1. **Credentials are stored locally** on your machine in `~/.v16/vault/`
366
+ 2. **AES-256-GCM encryption** protects all sensitive data
367
+ 3. **Master key** is stored with restricted permissions (0600)
368
+ 4. **Never share** your vault files or master key
369
+ 5. **Sessions** include cookies and storage - treat them as sensitive
370
+
371
+ ## Workflow Actions
372
+
373
+ Available actions in workflows:
374
+
375
+ - `navigate`: Navigate to a URL
376
+ - `value`: URL to navigate to
377
+
378
+ - `click`: Click an element
379
+ - `selector`: CSS selector for element
380
+
381
+ - `type`: Type text into an input
382
+ - `selector`: CSS selector for input
383
+ - `value`: Text to type (or use `credentialId` to inject from vault)
384
+ - `credentialId`: (optional) ID of credential to use as value
385
+
386
+ - `wait`: Wait for a duration
387
+ - `waitMs`: Milliseconds to wait
388
+
389
+ - `screenshot`: Take a screenshot
390
+ - No parameters needed
391
+
392
+ - `extract`: Extract text from an element
393
+ - `selector`: CSS selector for element
394
+
395
+ ## Error Handling
396
+
397
+ Workflows stop on the first error. Each step returns:
398
+
399
+ ```json
400
+ {
401
+ "stepId": "step-1",
402
+ "success": true,
403
+ "action": "navigate",
404
+ "result": {
405
+ "url": "https://example.com",
406
+ "title": "Example Domain"
407
+ },
408
+ "screenshot": "data:image/png;base64,...",
409
+ "duration": 1234
410
+ }
411
+ ```
412
+
413
+ ## Tips for Reliable Automation
414
+
415
+ 1. **Use persistent browser mode** - sessions survive restarts
416
+ 2. **Add wait steps** after navigation and clicks
417
+ 3. **Save sessions** after manual logins
418
+ 4. **Use domain-specific credentials** for easy lookup
419
+ 5. **Test workflows** with screenshots after critical steps
420
+ 6. **Handle errors** by checking step results
421
+ 7. **Update selectors** if websites change
422
+
423
+ ## Development Mode
424
+
425
+ For local testing without authentication:
426
+
427
+ ```bash
428
+ # Start local agent
429
+ v16 connect --dev
430
+
431
+ # Make requests with x-user-id header
432
+ curl -X POST http://localhost:3000/api/local-agent/credentials \
433
+ -H "Content-Type: application/json" \
434
+ -H "x-user-id: test-user" \
435
+ -d '{"name": "Test", "type": "password", "value": "secret"}'
436
+ ```
437
+
438
+ ## Troubleshooting
439
+
440
+ ### Browser not initializing
441
+ - Check if Chrome is installed
442
+ - Try `browser-init` command with different modes: `existing`, `persistent`, or `fresh`
443
+
444
+ ### Credentials not found
445
+ - Ensure credential vault is initialized
446
+ - Check credential ID is correct
447
+ - Verify domain matches
448
+
449
+ ### Workflow execution fails
450
+ - Check each step result for errors
451
+ - Verify selectors are correct (websites change!)
452
+ - Add wait steps between actions
453
+ - Use screenshots to debug
454
+
455
+ ### Session restore not working
456
+ - Ensure you navigated to the same domain
457
+ - Check if cookies are still valid
458
+ - Some sites may require re-login after time
459
+
460
+ ## Architecture
461
+
462
+ ```
463
+ ┌─────────────────────────────────────────────────────────────┐
464
+ │ Backend API │
465
+ │ /api/local-agent/* endpoints │
466
+ └───────────────────────┬─────────────────────────────────────┘
467
+ │ Socket.io
468
+
469
+ ┌───────────────────────▼─────────────────────────────────────┐
470
+ │ Local Agent (CLI) │
471
+ │ │
472
+ │ ┌─────────────────┐ ┌──────────────────┐ │
473
+ │ │ Credential Vault│ │ Workflow Engine │ │
474
+ │ │ (AES-256-GCM) │ │ (Step Executor) │ │
475
+ │ └─────────────────┘ └──────────────────┘ │
476
+ │ │
477
+ │ ┌─────────────────┐ ┌──────────────────┐ │
478
+ │ │ Web Search │ │ Email Checker │ │
479
+ │ │ (Google/DDG) │ │ (Gmail/Outlook) │ │
480
+ │ └─────────────────┘ └──────────────────┘ │
481
+ │ │
482
+ │ ┌──────────────────────────────────────┐ │
483
+ │ │ Puppeteer Browser Automation │ │
484
+ │ │ (Existing/Persistent/Fresh modes) │ │
485
+ │ └──────────────────────────────────────┘ │
486
+ └─────────────────────────────────────────────────────────────┘
487
+ ```
488
+
489
+ ## Future Enhancements
490
+
491
+ - [ ] Multi-step transaction rollback
492
+ - [ ] Workflow scheduling and cron
493
+ - [ ] Visual workflow builder
494
+ - [ ] Playwright support (recommended by 2026 research)
495
+ - [ ] Cloud session storage
496
+ - [ ] Workflow templates marketplace
497
+ - [ ] Integration with password managers
498
+ - [ ] 2FA automation support
499
+ - [ ] Headless browser optimization
500
+ - [ ] Session validation before workflow execution
501
+
502
+ ## Contributing
503
+
504
+ When adding new workflow actions:
505
+
506
+ 1. Add the action type to `WorkflowStep` interface
507
+ 2. Implement the action in `WorkflowAutomation.executeStep()`
508
+ 3. Update this documentation
509
+ 4. Add example workflows
510
+
511
+ ## License
512
+
513
+ Part of V16 General AI Agent platform.
package/CHANGELOG.md ADDED
@@ -0,0 +1,164 @@
1
+ # Changelog
2
+
3
+ All notable changes to the V16 Local Agent will be documented in this file.
4
+
5
+ ## [0.3.0] - 2026-01-30
6
+
7
+ ### Added - Major Browser Automation Update 🎉
8
+
9
+ #### Secure Credential Vault
10
+ - **AES-256-GCM encryption** for passwords, API keys, and sensitive data
11
+ - Local-only storage in `~/.v16/vault/`
12
+ - Domain-based credential lookup
13
+ - Master key protection with file permissions (0600)
14
+ - CRUD API endpoints for credential management
15
+
16
+ #### Workflow Automation System
17
+ - Multi-step browser workflow execution
18
+ - Support for 6 workflow actions: navigate, click, type, wait, screenshot, extract
19
+ - Credential injection into form fields
20
+ - Step-by-step execution with error handling
21
+ - Screenshot capture after each action
22
+ - Workflow storage and retrieval from encrypted vault
23
+
24
+ #### Web Search Integration
25
+ - **Google Search** - Programmatic search with result extraction
26
+ - **DuckDuckGo Search** - Privacy-focused alternative
27
+ - Automatic engine fallback (Google → DuckDuckGo)
28
+ - Information extraction from top search results
29
+ - Screenshot capture of search results
30
+
31
+ #### Email Checking
32
+ - **Gmail support** - Check inbox, search, find unread
33
+ - **Outlook/Hotmail support** - Full inbox access
34
+ - Email metadata extraction (sender, subject, snippet, date, unread status)
35
+ - Email search functionality
36
+ - Read specific email content
37
+
38
+ #### Browser Session Persistence
39
+ - Save browser sessions (cookies, localStorage, sessionStorage)
40
+ - Restore sessions to avoid repeated logins
41
+ - Domain-based session management
42
+ - Session storage in encrypted credential vault
43
+
44
+ #### API Endpoints
45
+ New endpoints added to `/api/local-agent/`:
46
+ - `POST /credentials` - Store encrypted credentials
47
+ - `GET /credentials` - List all credentials
48
+ - `GET /credentials/:id` - Get specific credential
49
+ - `DELETE /credentials/:id` - Delete credential
50
+ - `GET /credentials/domain/:domain` - Find credentials by domain
51
+ - `POST /workflows` - Create workflow
52
+ - `GET /workflows` - List workflows
53
+ - `POST /workflows/:id/execute` - Execute workflow
54
+ - `POST /search` - Web search
55
+ - `POST /search/extract` - Extract information from search
56
+ - `POST /email/check` - Check emails
57
+ - `POST /email/unread` - Get unread emails
58
+ - `POST /sessions/save` - Save browser session
59
+ - `POST /sessions/restore` - Restore session
60
+
61
+ #### Documentation
62
+ - **BROWSER_AUTOMATION.md** - Complete documentation for all new features
63
+ - **QUICKSTART.md** - 5-minute quick start guide with curl examples
64
+ - **examples.ts** - 10+ ready-to-use workflow templates
65
+ - Updated README.md with new capabilities
66
+
67
+ ### Changed
68
+ - Updated package description to reflect new capabilities
69
+ - Added new keywords: workflow, credential-vault, password-manager, email-checker, web-scraping, form-automation
70
+ - Version bump from 0.2.15 to 0.3.0
71
+
72
+ ### Dependencies
73
+ - Added `axios` ^1.13.4 for HTTP requests
74
+
75
+ ### Security
76
+ - All credentials encrypted with AES-256-GCM
77
+ - Master key stored with restricted permissions (0600)
78
+ - Credentials never leave local machine
79
+ - Session data encrypted before storage
80
+
81
+ ## [0.2.15] - Previous version
82
+
83
+ ### Features
84
+ - Desktop control (mouse, keyboard, screenshots)
85
+ - Browser automation with Puppeteer
86
+ - Three-tier browser approach (Existing → Persistent → Fresh)
87
+ - File system access
88
+ - Terminal/PTY sessions
89
+ - CLI command execution
90
+
91
+ ---
92
+
93
+ ## Upgrade Guide
94
+
95
+ ### From 0.2.x to 0.3.0
96
+
97
+ No breaking changes. All existing functionality remains the same. New features are additive.
98
+
99
+ To use the new features:
100
+
101
+ 1. **Update the package**:
102
+ ```bash
103
+ npm update -g v16.ai
104
+ ```
105
+
106
+ 2. **Credential vault is auto-initialized** when you connect:
107
+ ```bash
108
+ v16 connect --token YOUR_TOKEN
109
+ ```
110
+
111
+ 3. **Start using new endpoints** - see QUICKSTART.md for examples
112
+
113
+ ### Example Migration
114
+
115
+ **Before (0.2.x)**: Manual browser automation
116
+ ```bash
117
+ curl -X POST /api/local-agent/browser/navigate \
118
+ -d '{"url": "https://example.com"}'
119
+ curl -X POST /api/local-agent/browser/type \
120
+ -d '{"selector": "input", "text": "password123"}'
121
+ ```
122
+
123
+ **After (0.3.0)**: Automated workflow with credentials
124
+ ```bash
125
+ # 1. Store credential once
126
+ curl -X POST /api/local-agent/credentials \
127
+ -d '{"name": "My Password", "type": "password", "value": "password123"}'
128
+
129
+ # 2. Create reusable workflow
130
+ curl -X POST /api/local-agent/workflows \
131
+ -d '{
132
+ "name": "Login",
133
+ "steps": [
134
+ {"action": "navigate", "value": "https://example.com"},
135
+ {"action": "type", "selector": "input", "credentialId": "CRED_ID"}
136
+ ]
137
+ }'
138
+
139
+ # 3. Execute workflow anytime
140
+ curl -X POST /api/local-agent/workflows/WORKFLOW_ID/execute
141
+ ```
142
+
143
+ ---
144
+
145
+ ## Roadmap
146
+
147
+ ### Planned for 0.4.0
148
+ - [ ] Playwright support (recommended by 2026 research)
149
+ - [ ] Enhanced session validation
150
+ - [ ] Workflow scheduling (cron)
151
+ - [ ] 2FA automation support
152
+
153
+ ### Planned for 0.5.0
154
+ - [ ] Visual workflow builder (web UI)
155
+ - [ ] Workflow marketplace/templates
156
+ - [ ] Cloud session sync (optional)
157
+ - [ ] Password manager integrations
158
+
159
+ ---
160
+
161
+ For more details, see:
162
+ - [Quick Start Guide](./QUICKSTART.md)
163
+ - [Browser Automation Documentation](./BROWSER_AUTOMATION.md)
164
+ - [Example Workflows](./src/workflows/examples.ts)