Skip to content

Commit 0222fca

Browse files
SilkWebclaude
andcommitted
Add SilkWeb Chrome extension — 20 agents in every browser tab
- Manifest V3, dark glassmorphism UI, 380x580px popup - All 20 agents with search, action forms, JSON results display - Right-click context menus: AEGIS scan, JUSTICE review, PHANTOM investigate - Floating button on every page with smart auto-fill - Ready for Chrome Web Store publishing Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7af9629 commit 0222fca

16 files changed

Lines changed: 2717 additions & 0 deletions

chrome-extension/README.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# SilkWeb Agents - Chrome Extension
2+
3+
Access 20 specialized AI agents from any browser tab. Security scans, legal review, financial analysis, and more -- all one click away.
4+
5+
## Features
6+
7+
- **20 AI Agents** across cybersecurity, legal, finance, healthcare, DevOps, HR, e-commerce, education, and more
8+
- **Popup Interface** with search, agent list, expandable actions, input forms, and inline JSON results
9+
- **Floating Button** on every page with a quick-access agent picker overlay
10+
- **Right-Click Context Menus**: Scan pages with AEGIS, analyze selected text with JUSTICE, investigate domains with PHANTOM
11+
- **Smart Auto-Fill**: Current page URL and selected text are automatically injected into relevant agent actions
12+
- **Result Caching**: Recent API results are cached locally for 5 minutes
13+
- **Dark Theme**: Matches the SilkWeb brand (purple #6366f1, green #10B981, dark background #06060b)
14+
- **Settings**: Configurable API base URL, API key, and floating button visibility
15+
16+
## Installation (Developer Mode)
17+
18+
1. Clone or download this directory
19+
2. Generate icon PNGs (see Icons section below)
20+
3. Open Chrome and go to `chrome://extensions/`
21+
4. Enable **Developer mode** (toggle in the top-right corner)
22+
5. Click **Load unpacked**
23+
6. Select the `chrome-extension/` directory
24+
7. The SilkWeb Agents icon will appear in your toolbar
25+
26+
## Generating Icons
27+
28+
Before loading the extension, generate the icon PNG files:
29+
30+
**Option A -- Node.js (no dependencies):**
31+
```bash
32+
cd icons/
33+
node create-icons-node.js
34+
```
35+
36+
**Option B -- Browser:**
37+
1. Open `icons/generate-icons.html` in Chrome
38+
2. Click "Generate & Download Icons"
39+
3. Move the downloaded files into the `icons/` directory
40+
41+
## Usage
42+
43+
### Popup
44+
Click the SilkWeb icon in the Chrome toolbar to open the popup. Search for agents, expand them to see available actions, click an action to open the input form, and hit Run.
45+
46+
### Floating Button
47+
A small spider web button appears in the bottom-right corner of every page. Click it to open a compact agent picker. Actions auto-fill with the current page URL or selected text where applicable.
48+
49+
### Context Menus
50+
Right-click on any page to access:
51+
- **Scan this page with AEGIS** -- runs a URL security scan
52+
- **Analyze selected text with JUSTICE** -- analyzes selected text as a contract
53+
- **Check domain with PHANTOM** -- investigates the current domain
54+
55+
### Settings
56+
Click the gear icon in the popup to configure:
57+
- **API Base URL** -- defaults to `https://api.silkweb.io`
58+
- **API Key** -- your SilkWeb API key for authenticated requests
59+
- **Show floating button** -- toggle the in-page floating button
60+
61+
## Publishing to Chrome Web Store
62+
63+
1. Generate production icons (see above)
64+
2. Create a ZIP of the `chrome-extension/` directory (exclude `icons/generate-*` helper files)
65+
3. Go to the [Chrome Web Store Developer Dashboard](https://chrome.google.com/webstore/devconsole)
66+
4. Click **New Item** and upload the ZIP
67+
5. Fill in the listing details:
68+
- **Name**: SilkWeb Agents
69+
- **Description**: Access 20 specialized AI agents from any browser tab
70+
- **Category**: Productivity
71+
- **Screenshots**: Capture the popup, the overlay on a page, and the context menu
72+
6. Submit for review (typically 1-3 business days)
73+
74+
## Agent Roster
75+
76+
| Agent | Domain | Tier | Key Actions |
77+
|-------|--------|------|-------------|
78+
| AEGIS | Cybersecurity | Expert | URL Scan, SSL Audit, Domain Check, Full Report |
79+
| NAVIGATOR | Logistics | Authority | Route Calculator, Customs Check, Carbon Footprint |
80+
| SENTINEL | IT Monitoring | Expert | Health Check, DNS Check, SSL Expiry |
81+
| ORACLE | Finance | Authority | Fraud Detection, Compliance Check |
82+
| ATLAS | Geospatial | Authority | Distance Calculator, Sunrise/Sunset |
83+
| JUSTICE | Contract Law | Expert | Contract Review, NDA Review |
84+
| SHIELD | Personal Injury | Expert | Case Evaluation, Damages Calculator |
85+
| FORTRESS | Criminal Defense | Expert | Charge Analysis, Know Your Rights |
86+
| DESIGN | Graphics | Expert | Social Card Generator |
87+
| MEDIC | Healthcare | Expert | Symptom Check, Drug Interactions |
88+
| ARCHITECT | Code & DevOps | Expert | Code Review, Tech Debt Score |
89+
| BROKER | Real Estate | Authority | Property Analysis, ROI Calculator |
90+
| SCRIBE | Content & Copy | Expert | Blog Outline, Social Posts |
91+
| PHANTOM | OSINT | Expert | Domain Investigation, Email Investigation |
92+
| DIPLOMAT | HR & Compliance | Expert | Salary Benchmark, Job Post Analysis |
93+
| MERCHANT | E-Commerce | Expert | Listing Optimizer, Pricing Analysis |
94+
| TUTOR | Education | Expert | Quiz Generator, Flashcards |
95+
| CLIMATE | Sustainability | Expert | Carbon Calculator, ESG Score |
96+
| SIGNAL | PR & Comms | Expert | Press Release, Crisis Response |
97+
| FORGE | Manufacturing | Authority | Supplier Score, Quality Analysis |
98+
99+
## File Structure
100+
101+
```
102+
chrome-extension/
103+
manifest.json # Extension manifest (Manifest V3)
104+
popup/
105+
popup.html # Popup UI
106+
popup.css # Popup styles
107+
popup.js # Popup logic + agent data
108+
background/
109+
service-worker.js # Context menus, API calls, caching
110+
content/
111+
content.js # Floating button + overlay
112+
content.css # Content script styles
113+
icons/
114+
icon16.png # 16x16 toolbar icon
115+
icon48.png # 48x48 extension page icon
116+
icon128.png # 128x128 store icon
117+
generate-icons.html # Browser-based icon generator
118+
create-icons-node.js # Node.js icon generator
119+
```
120+
121+
## License
122+
123+
Part of the SilkWeb platform. All rights reserved.
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
/* ===== SilkWeb Agents - Background Service Worker ===== */
2+
3+
const DEFAULT_API_BASE = 'https://api.silkweb.io';
4+
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
5+
6+
/* ===== Context Menus ===== */
7+
chrome.runtime.onInstalled.addListener(() => {
8+
chrome.contextMenus.create({
9+
id: 'silkweb-scan-page',
10+
title: 'Scan this page with AEGIS',
11+
contexts: ['page']
12+
});
13+
14+
chrome.contextMenus.create({
15+
id: 'silkweb-analyze-text',
16+
title: 'Analyze selected text with JUSTICE',
17+
contexts: ['selection']
18+
});
19+
20+
chrome.contextMenus.create({
21+
id: 'silkweb-check-domain',
22+
title: 'Check domain with PHANTOM',
23+
contexts: ['page']
24+
});
25+
});
26+
27+
/* ===== Context Menu Click Handlers ===== */
28+
chrome.contextMenus.onClicked.addListener(async (info, tab) => {
29+
switch (info.menuItemId) {
30+
case 'silkweb-scan-page':
31+
await handleContextAction(
32+
'/agents/aegis/scan/url',
33+
{ url: tab.url },
34+
tab.id
35+
);
36+
break;
37+
38+
case 'silkweb-analyze-text':
39+
await handleContextAction(
40+
'/agents/justice/analyze/contract',
41+
{ text: info.selectionText },
42+
tab.id
43+
);
44+
break;
45+
46+
case 'silkweb-check-domain':
47+
const domain = new URL(tab.url).hostname;
48+
await handleContextAction(
49+
'/agents/phantom/investigate/domain',
50+
{ domain },
51+
tab.id
52+
);
53+
break;
54+
}
55+
});
56+
57+
/* ===== Handle Context Menu Action ===== */
58+
async function handleContextAction(endpoint, payload, tabId) {
59+
try {
60+
const result = await makeApiCall(endpoint, payload);
61+
62+
// Cache the result
63+
const cacheKey = `result_${endpoint}_${JSON.stringify(payload)}`;
64+
await chrome.storage.local.set({
65+
[cacheKey]: {
66+
data: result,
67+
timestamp: Date.now()
68+
}
69+
});
70+
71+
// Send result to content script for display
72+
chrome.tabs.sendMessage(tabId, {
73+
type: 'SHOW_RESULT',
74+
agent: endpoint.split('/')[2].toUpperCase(),
75+
data: result
76+
});
77+
} catch (err) {
78+
chrome.tabs.sendMessage(tabId, {
79+
type: 'SHOW_ERROR',
80+
error: err.message
81+
});
82+
}
83+
}
84+
85+
/* ===== Message Listener ===== */
86+
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
87+
if (message.type === 'API_CALL') {
88+
handleApiCall(message.endpoint, message.payload)
89+
.then(data => sendResponse({ data }))
90+
.catch(err => sendResponse({ error: err.message }));
91+
return true; // Keep channel open for async response
92+
}
93+
94+
if (message.type === 'GET_PAGE_URL') {
95+
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
96+
sendResponse({ url: tabs[0]?.url || '' });
97+
});
98+
return true;
99+
}
100+
});
101+
102+
/* ===== API Call Handler with Caching ===== */
103+
async function handleApiCall(endpoint, payload) {
104+
// Check cache first
105+
const cacheKey = `result_${endpoint}_${JSON.stringify(payload)}`;
106+
const cached = await getCached(cacheKey);
107+
if (cached) return cached;
108+
109+
const result = await makeApiCall(endpoint, payload);
110+
111+
// Store in cache
112+
await chrome.storage.local.set({
113+
[cacheKey]: {
114+
data: result,
115+
timestamp: Date.now()
116+
}
117+
});
118+
119+
return result;
120+
}
121+
122+
/* ===== Cache Retrieval ===== */
123+
async function getCached(key) {
124+
return new Promise((resolve) => {
125+
chrome.storage.local.get([key], (result) => {
126+
const entry = result[key];
127+
if (entry && (Date.now() - entry.timestamp) < CACHE_TTL) {
128+
resolve(entry.data);
129+
} else {
130+
// Clean up expired entry
131+
if (entry) chrome.storage.local.remove(key);
132+
resolve(null);
133+
}
134+
});
135+
});
136+
}
137+
138+
/* ===== Make API Call ===== */
139+
async function makeApiCall(endpoint, payload) {
140+
const settings = await getSettings();
141+
const baseUrl = settings.apiBaseUrl || DEFAULT_API_BASE;
142+
const apiKey = settings.apiKey || '';
143+
144+
const headers = {
145+
'Content-Type': 'application/json'
146+
};
147+
148+
if (apiKey) {
149+
headers['Authorization'] = `Bearer ${apiKey}`;
150+
}
151+
152+
const url = `${baseUrl}${endpoint}`;
153+
154+
const response = await fetch(url, {
155+
method: 'POST',
156+
headers,
157+
body: JSON.stringify(payload)
158+
});
159+
160+
if (!response.ok) {
161+
const errorBody = await response.text().catch(() => '');
162+
throw new Error(
163+
`API Error ${response.status}: ${errorBody || response.statusText}`
164+
);
165+
}
166+
167+
return response.json();
168+
}
169+
170+
/* ===== Get Settings ===== */
171+
function getSettings() {
172+
return new Promise((resolve) => {
173+
chrome.storage.local.get(['apiBaseUrl', 'apiKey', 'showFab'], (data) => {
174+
resolve(data || {});
175+
});
176+
});
177+
}
178+
179+
/* ===== Periodic Cache Cleanup ===== */
180+
chrome.alarms.create('cache-cleanup', { periodInMinutes: 10 });
181+
182+
chrome.alarms.onAlarm.addListener((alarm) => {
183+
if (alarm.name === 'cache-cleanup') {
184+
cleanupCache();
185+
}
186+
});
187+
188+
async function cleanupCache() {
189+
const all = await chrome.storage.local.get(null);
190+
const keysToRemove = [];
191+
192+
for (const [key, value] of Object.entries(all)) {
193+
if (key.startsWith('result_') && value.timestamp) {
194+
if (Date.now() - value.timestamp > CACHE_TTL) {
195+
keysToRemove.push(key);
196+
}
197+
}
198+
}
199+
200+
if (keysToRemove.length > 0) {
201+
chrome.storage.local.remove(keysToRemove);
202+
}
203+
}

0 commit comments

Comments
 (0)