prism-mcp-server 20.0.7 → 20.0.8

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.
@@ -1,70 +0,0 @@
1
- /**
2
- * Tavily API Client
3
- *
4
- * This module provides Tavily Search and Extract helpers for the Web Scholar
5
- * pipeline. It serves as an additive alternative to Brave Search + Firecrawl
6
- * when TAVILY_API_KEY is set.
7
- *
8
- * 1. performTavilySearch — Web search returning URLs (mirrors Brave web search)
9
- * 2. performTavilyExtract — URL content extraction returning markdown (mirrors Firecrawl scrape)
10
- */
11
- import { tavily } from "@tavily/core";
12
- function getClient(apiKey) {
13
- return tavily({ apiKey });
14
- }
15
- /**
16
- * Searches the web via Tavily and returns an array of result objects.
17
- */
18
- export async function performTavilySearch(apiKey, query, maxResults = 10) {
19
- try {
20
- const client = getClient(apiKey);
21
- const response = await client.search(query, {
22
- maxResults,
23
- searchDepth: "advanced",
24
- topic: "general",
25
- });
26
- return (response.results || []).map((r) => ({
27
- title: r.title || "",
28
- url: r.url || "",
29
- content: r.content || "",
30
- score: r.score ?? 0,
31
- }));
32
- }
33
- catch (error) {
34
- console.error(`[Tavily Search] Error performing search for query "${query}":`, error);
35
- return [];
36
- }
37
- }
38
- /**
39
- * Extracts article content from URLs via Tavily Extract.
40
- * Returns markdown content for each successfully extracted URL.
41
- */
42
- export async function performTavilyExtract(apiKey, urls) {
43
- if (urls.length === 0)
44
- return [];
45
- const client = getClient(apiKey);
46
- const allResults = [];
47
- // Tavily extract accepts up to 20 URLs at once
48
- for (let i = 0; i < urls.length; i += 20) {
49
- const batch = urls.slice(i, i + 20);
50
- try {
51
- const response = await client.extract(batch, {
52
- extractDepth: "basic",
53
- });
54
- // Optionally log failed URLs from this batch
55
- if (response.failedResults && response.failedResults.length > 0) {
56
- console.warn(`[Tavily Extract] Failed to extract ${response.failedResults.length} URLs in this batch.`, response.failedResults);
57
- }
58
- const mapped = (response.results || []).map((r) => ({
59
- url: r.url || "",
60
- rawContent: r.rawContent || "",
61
- }));
62
- allResults.push(...mapped);
63
- }
64
- catch (error) {
65
- // Log the error but continue to the next batch to prevent total data loss
66
- console.error(`[Tavily Extract] Error extracting batch ${i} to ${Math.min(i + 20, urls.length)}:`, error);
67
- }
68
- }
69
- return allResults;
70
- }
@@ -1,192 +0,0 @@
1
- /**
2
- * v12.5: Tier-Gated VM Quota Enforcer
3
- *
4
- * Enforces subscription-based VM limits.
5
- * Each Synalux tier has maximum VM counts, CPU, RAM, and storage quotas.
6
- */
7
- import { debugLog } from "../utils/logger.js";
8
- // ─── Tier Quotas ─────────────────────────────────────────────
9
- const TIER_QUOTAS = {
10
- free: {
11
- maxVMs: 1,
12
- maxCpuCores: 2,
13
- maxRamGb: 4,
14
- maxStorageGb: 20,
15
- maxConcurrentRuns: 1,
16
- allowedPlatforms: ["linux"],
17
- },
18
- standard: {
19
- maxVMs: 5,
20
- maxCpuCores: 8,
21
- maxRamGb: 16,
22
- maxStorageGb: 100,
23
- maxConcurrentRuns: 2,
24
- allowedPlatforms: ["linux", "macos", "windows"],
25
- },
26
- advanced: {
27
- maxVMs: 20,
28
- maxCpuCores: 32,
29
- maxRamGb: 64,
30
- maxStorageGb: 500,
31
- maxConcurrentRuns: 5,
32
- allowedPlatforms: ["linux", "macos", "windows", "ios", "android", "visionos"],
33
- },
34
- enterprise: {
35
- maxVMs: -1, // unlimited
36
- maxCpuCores: -1,
37
- maxRamGb: -1,
38
- maxStorageGb: -1,
39
- maxConcurrentRuns: -1,
40
- allowedPlatforms: ["*"],
41
- },
42
- };
43
- // ─── State ───────────────────────────────────────────────────
44
- let currentTier = "free";
45
- let currentUsage = {
46
- activeVMs: 0,
47
- totalCpuCores: 0,
48
- totalRamGb: 0,
49
- totalStorageGb: 0,
50
- concurrentRuns: 0,
51
- };
52
- export function setTier(tier) {
53
- currentTier = tier;
54
- debugLog(`VM Quota: Tier set to '${tier}'`);
55
- }
56
- export function getTier() {
57
- return currentTier;
58
- }
59
- export function getQuota(tier) {
60
- return { ...TIER_QUOTAS[tier || currentTier] };
61
- }
62
- export function getUsage() {
63
- return { ...currentUsage };
64
- }
65
- export function updateUsage(usage) {
66
- currentUsage = { ...currentUsage, ...usage };
67
- }
68
- // ─── Quota Checks ────────────────────────────────────────────
69
- function isUnlimited(value) {
70
- return value === -1;
71
- }
72
- /**
73
- * Check if creating a new VM is allowed.
74
- */
75
- export function checkVMCreation(cpuCores = 1, ramGb = 2, storageGb = 10, platform = "linux") {
76
- const quota = TIER_QUOTAS[currentTier];
77
- // Check platform
78
- if (!quota.allowedPlatforms.includes("*") && !quota.allowedPlatforms.includes(platform)) {
79
- return {
80
- allowed: false,
81
- resource: "platform",
82
- requested: 0,
83
- available: 0,
84
- limit: 0,
85
- tier: currentTier,
86
- reason: `Platform '${platform}' not available on ${currentTier} tier. Available: ${quota.allowedPlatforms.join(", ")}`,
87
- };
88
- }
89
- // Check VM count
90
- if (!isUnlimited(quota.maxVMs) && currentUsage.activeVMs >= quota.maxVMs) {
91
- return {
92
- allowed: false,
93
- resource: "vms",
94
- requested: 1,
95
- available: quota.maxVMs - currentUsage.activeVMs,
96
- limit: quota.maxVMs,
97
- tier: currentTier,
98
- reason: `VM limit reached (${currentUsage.activeVMs}/${quota.maxVMs})`,
99
- };
100
- }
101
- // Check CPU
102
- if (!isUnlimited(quota.maxCpuCores) && currentUsage.totalCpuCores + cpuCores > quota.maxCpuCores) {
103
- return {
104
- allowed: false,
105
- resource: "cpu",
106
- requested: cpuCores,
107
- available: quota.maxCpuCores - currentUsage.totalCpuCores,
108
- limit: quota.maxCpuCores,
109
- tier: currentTier,
110
- reason: `CPU quota exceeded (${currentUsage.totalCpuCores + cpuCores}/${quota.maxCpuCores} cores)`,
111
- };
112
- }
113
- // Check RAM
114
- if (!isUnlimited(quota.maxRamGb) && currentUsage.totalRamGb + ramGb > quota.maxRamGb) {
115
- return {
116
- allowed: false,
117
- resource: "ram",
118
- requested: ramGb,
119
- available: quota.maxRamGb - currentUsage.totalRamGb,
120
- limit: quota.maxRamGb,
121
- tier: currentTier,
122
- reason: `RAM quota exceeded (${currentUsage.totalRamGb + ramGb}/${quota.maxRamGb} GB)`,
123
- };
124
- }
125
- // Check storage
126
- if (!isUnlimited(quota.maxStorageGb) && currentUsage.totalStorageGb + storageGb > quota.maxStorageGb) {
127
- return {
128
- allowed: false,
129
- resource: "storage",
130
- requested: storageGb,
131
- available: quota.maxStorageGb - currentUsage.totalStorageGb,
132
- limit: quota.maxStorageGb,
133
- tier: currentTier,
134
- reason: `Storage quota exceeded (${currentUsage.totalStorageGb + storageGb}/${quota.maxStorageGb} GB)`,
135
- };
136
- }
137
- return {
138
- allowed: true,
139
- resource: "all",
140
- requested: 0,
141
- available: 0,
142
- limit: 0,
143
- tier: currentTier,
144
- reason: "All quota checks passed",
145
- };
146
- }
147
- /**
148
- * Check if a concurrent run is allowed.
149
- */
150
- export function checkConcurrentRun() {
151
- const quota = TIER_QUOTAS[currentTier];
152
- if (!isUnlimited(quota.maxConcurrentRuns) && currentUsage.concurrentRuns >= quota.maxConcurrentRuns) {
153
- return {
154
- allowed: false,
155
- resource: "concurrent_runs",
156
- requested: 1,
157
- available: quota.maxConcurrentRuns - currentUsage.concurrentRuns,
158
- limit: quota.maxConcurrentRuns,
159
- tier: currentTier,
160
- reason: `Concurrent run limit reached (${currentUsage.concurrentRuns}/${quota.maxConcurrentRuns})`,
161
- };
162
- }
163
- return {
164
- allowed: true,
165
- resource: "concurrent_runs",
166
- requested: 1,
167
- available: isUnlimited(quota.maxConcurrentRuns) ? -1 : quota.maxConcurrentRuns - currentUsage.concurrentRuns,
168
- limit: quota.maxConcurrentRuns,
169
- tier: currentTier,
170
- reason: "Concurrent run allowed",
171
- };
172
- }
173
- /**
174
- * Get a summary of quota usage vs limits.
175
- */
176
- export function getQuotaSummary() {
177
- const limits = TIER_QUOTAS[currentTier];
178
- const pct = (used, max) => max === -1 ? 0 : Math.round((used / max) * 100);
179
- return {
180
- tier: currentTier,
181
- usage: { ...currentUsage },
182
- limits: { ...limits },
183
- percentUsed: {
184
- vms: pct(currentUsage.activeVMs, limits.maxVMs),
185
- cpu: pct(currentUsage.totalCpuCores, limits.maxCpuCores),
186
- ram: pct(currentUsage.totalRamGb, limits.maxRamGb),
187
- storage: pct(currentUsage.totalStorageGb, limits.maxStorageGb),
188
- runs: pct(currentUsage.concurrentRuns, limits.maxConcurrentRuns),
189
- },
190
- };
191
- }
192
- debugLog("v12.5: VM quota enforcer loaded");