mirror of
https://github.com/blackboxprogramming/context-bridge.git
synced 2026-03-17 04:57:16 -05:00
Agent Coordination: - Epimetheus (Architect) identity assigned and registered - Connected to PS-SHA-∞ memory system (4,059 entries) - Task claimed from marketplace - Broadcasting to other agents Launch Documentation Created: - PUBLISH_TO_NPM.md - Complete npm publishing guide - STRIPE_LIVE_SETUP.md - Stripe live mode setup guide - AGENT_COORDINATION_REPORT.md - Full status and next steps - EPIMETHEUS_SESSION_COMPLETE.md - Session summary - Added all previous documentation to repo Launch Status: 98% Complete Blocked on: User actions (npm login + Stripe products) Ready: Screenshots, testing, submissions, announcements Next Steps: 1. User: npm login && npm publish (10 min) 2. User: Create Stripe products (5 min) 3. Capture 5 screenshots (15 min) 4. Manual testing on 4 platforms (20 min) 5. Submit to Chrome Web Store (30 min) 6. Launch announcements (10 min) Total time to launch: ~90 minutes Agent Body: qwen2.5-coder:7b (open source) Memory Hash: 4e3d2012 Collaboration: ACTIVE Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
/**
|
|
* Context Bridge - Storage Monitor
|
|
* Monitors chrome.storage.sync usage and warns when approaching quota
|
|
*/
|
|
|
|
const STORAGE_QUOTA = 102400; // 100KB Chrome sync storage limit
|
|
const WARN_THRESHOLD = 0.9; // Warn at 90%
|
|
const ITEM_QUOTA = 8192; // 8KB per item limit
|
|
|
|
async function checkStorageUsage() {
|
|
return new Promise((resolve) => {
|
|
chrome.storage.sync.getBytesInUse(null, (bytesInUse) => {
|
|
const percentUsed = bytesInUse / STORAGE_QUOTA;
|
|
const isNearLimit = percentUsed >= WARN_THRESHOLD;
|
|
|
|
resolve({
|
|
bytesInUse,
|
|
bytesRemaining: STORAGE_QUOTA - bytesInUse,
|
|
percentUsed: Math.round(percentUsed * 100),
|
|
isNearLimit,
|
|
quota: STORAGE_QUOTA
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
async function checkItemSize(key, value) {
|
|
const size = new Blob([JSON.stringify(value)]).size;
|
|
const isTooBig = size > ITEM_QUOTA;
|
|
|
|
return {
|
|
key,
|
|
size,
|
|
isTooBig,
|
|
quota: ITEM_QUOTA,
|
|
percentOfQuota: Math.round((size / ITEM_QUOTA) * 100)
|
|
};
|
|
}
|
|
|
|
async function displayStorageWarning() {
|
|
const usage = await checkStorageUsage();
|
|
|
|
if (usage.isNearLimit) {
|
|
const warningDiv = document.createElement('div');
|
|
warningDiv.className = 'storage-warning';
|
|
warningDiv.innerHTML = `
|
|
<strong>⚠️ Storage Warning</strong>
|
|
<p>You're using ${usage.percentUsed}% of available storage.</p>
|
|
<p>Consider cleaning up old data or switching to local storage.</p>
|
|
`;
|
|
|
|
const container = document.querySelector('.container');
|
|
if (container) {
|
|
container.insertBefore(warningDiv, container.firstChild);
|
|
}
|
|
}
|
|
|
|
return usage;
|
|
}
|
|
|
|
// Monitor storage on popup open
|
|
if (typeof chrome !== 'undefined' && chrome.storage) {
|
|
displayStorageWarning().then(usage => {
|
|
console.log('Storage usage:', usage);
|
|
});
|
|
}
|
|
|
|
// Export for use in popup.js
|
|
if (typeof module !== 'undefined' && module.exports) {
|
|
module.exports = {
|
|
checkStorageUsage,
|
|
checkItemSize,
|
|
displayStorageWarning
|
|
};
|
|
}
|