@trops/dash-core 0.1.693 → 0.1.694
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.
- package/dist/electron/index.js +664 -41
- package/dist/electron/index.js.map +1 -1
- package/package.json +1 -1
package/dist/electron/index.js
CHANGED
|
@@ -18691,7 +18691,7 @@ var settingsController_1 = settingsController$4;
|
|
|
18691
18691
|
* window.mainApi.myService.getData({ ...pc, cache: true, forceRefresh: true }); // bypass
|
|
18692
18692
|
*/
|
|
18693
18693
|
|
|
18694
|
-
const cache$
|
|
18694
|
+
const cache$2 = new Map(); // key → { data, timestamp, ttl }
|
|
18695
18695
|
const inflight = new Map(); // key → Promise
|
|
18696
18696
|
|
|
18697
18697
|
function stableHash(obj) {
|
|
@@ -18707,13 +18707,13 @@ const responseCache$3 = {
|
|
|
18707
18707
|
async get(key, fetcher, options = {}) {
|
|
18708
18708
|
const { ttl = 30000, forceRefresh = false } = options;
|
|
18709
18709
|
|
|
18710
|
-
if (!forceRefresh && cache$
|
|
18711
|
-
const entry = cache$
|
|
18710
|
+
if (!forceRefresh && cache$2.has(key)) {
|
|
18711
|
+
const entry = cache$2.get(key);
|
|
18712
18712
|
if (Date.now() - entry.timestamp < entry.ttl) {
|
|
18713
18713
|
console.log(`[responseCache] HIT ${key}`);
|
|
18714
18714
|
return entry.data;
|
|
18715
18715
|
}
|
|
18716
|
-
cache$
|
|
18716
|
+
cache$2.delete(key);
|
|
18717
18717
|
}
|
|
18718
18718
|
|
|
18719
18719
|
if (!forceRefresh && inflight.has(key)) {
|
|
@@ -18727,7 +18727,7 @@ const responseCache$3 = {
|
|
|
18727
18727
|
try {
|
|
18728
18728
|
const data = await promise;
|
|
18729
18729
|
if (data && !data.error) {
|
|
18730
|
-
cache$
|
|
18730
|
+
cache$2.set(key, { data, timestamp: Date.now(), ttl });
|
|
18731
18731
|
}
|
|
18732
18732
|
return data;
|
|
18733
18733
|
} finally {
|
|
@@ -18765,25 +18765,25 @@ const responseCache$3 = {
|
|
|
18765
18765
|
},
|
|
18766
18766
|
|
|
18767
18767
|
invalidate(key) {
|
|
18768
|
-
cache$
|
|
18768
|
+
cache$2.delete(key);
|
|
18769
18769
|
},
|
|
18770
18770
|
|
|
18771
18771
|
invalidatePrefix(prefix) {
|
|
18772
|
-
for (const k of cache$
|
|
18773
|
-
if (k.startsWith(prefix)) cache$
|
|
18772
|
+
for (const k of cache$2.keys()) {
|
|
18773
|
+
if (k.startsWith(prefix)) cache$2.delete(k);
|
|
18774
18774
|
}
|
|
18775
18775
|
},
|
|
18776
18776
|
|
|
18777
18777
|
clear() {
|
|
18778
|
-
cache$
|
|
18778
|
+
cache$2.clear();
|
|
18779
18779
|
inflight.clear();
|
|
18780
18780
|
},
|
|
18781
18781
|
|
|
18782
18782
|
stats() {
|
|
18783
18783
|
return {
|
|
18784
|
-
entries: cache$
|
|
18784
|
+
entries: cache$2.size,
|
|
18785
18785
|
inflight: inflight.size,
|
|
18786
|
-
keys: [...cache$
|
|
18786
|
+
keys: [...cache$2.keys()],
|
|
18787
18787
|
};
|
|
18788
18788
|
},
|
|
18789
18789
|
};
|
|
@@ -54635,7 +54635,7 @@ function checkUrl(url, allowedSites) {
|
|
|
54635
54635
|
* @param {{ open?: Function }} deps
|
|
54636
54636
|
* @returns {Promise<{ finalUrl: string, status: number, contentType: string, buffer: Buffer }>}
|
|
54637
54637
|
*/
|
|
54638
|
-
async function safeFetch$
|
|
54638
|
+
async function safeFetch$2(rawUrl, opts, deps = {}) {
|
|
54639
54639
|
const open = deps.open || httpsOpen;
|
|
54640
54640
|
let url;
|
|
54641
54641
|
try {
|
|
@@ -54737,7 +54737,7 @@ async function safeFetch$1(rawUrl, opts, deps = {}) {
|
|
|
54737
54737
|
}
|
|
54738
54738
|
|
|
54739
54739
|
var safeFetch_1 = {
|
|
54740
|
-
safeFetch: safeFetch$
|
|
54740
|
+
safeFetch: safeFetch$2,
|
|
54741
54741
|
guardedLookup,
|
|
54742
54742
|
hostAllowed,
|
|
54743
54743
|
WebFetchError: WebFetchError$1,
|
|
@@ -54936,7 +54936,7 @@ var htmlToText_1 = { htmlToText: htmlToText$1, decodeEntities };
|
|
|
54936
54936
|
|
|
54937
54937
|
const { McpServer: McpServer$1 } = mcp;
|
|
54938
54938
|
const z$2 = require$$8$1;
|
|
54939
|
-
const { safeFetch, WebFetchError, formatMb } = safeFetch_1;
|
|
54939
|
+
const { safeFetch: safeFetch$1, WebFetchError, formatMb } = safeFetch_1;
|
|
54940
54940
|
const { sniffImage } = imageSniff;
|
|
54941
54941
|
const { htmlToText } = htmlToText_1;
|
|
54942
54942
|
|
|
@@ -55041,7 +55041,7 @@ function textResult(text, isError = false) {
|
|
|
55041
55041
|
function createWebFetchServer$1(credentials, opts = {}) {
|
|
55042
55042
|
const settings = readSettings(credentials);
|
|
55043
55043
|
const serverName = opts.serverName || "Web Fetch";
|
|
55044
|
-
const doFetch = opts.fetch || safeFetch;
|
|
55044
|
+
const doFetch = opts.fetch || safeFetch$1;
|
|
55045
55045
|
const shrink = opts.shrink || nativeShrink;
|
|
55046
55046
|
const where = (setting) =>
|
|
55047
55047
|
`(Settings › Providers › ${serverName} › ${setting})`;
|
|
@@ -57059,7 +57059,7 @@ const { getStoredToken: getStoredToken$4, authedFetch } = registryAuthController
|
|
|
57059
57059
|
const DEFAULT_REGISTRY_API_URL = "https://main.d919rwhuzp7rj.amplifyapp.com";
|
|
57060
57060
|
|
|
57061
57061
|
// Cache TTL: 5 minutes
|
|
57062
|
-
const CACHE_TTL_MS = 5 * 60 * 1000;
|
|
57062
|
+
const CACHE_TTL_MS$1 = 5 * 60 * 1000;
|
|
57063
57063
|
|
|
57064
57064
|
// Cache is keyed by userId so anonymous + authenticated results don't mix.
|
|
57065
57065
|
// When a user signs in, their cache entry is empty and gets populated with
|
|
@@ -57102,7 +57102,7 @@ async function fetchRegistryIndex(forceRefresh = false) {
|
|
|
57102
57102
|
const cached = caches.get(cacheKey);
|
|
57103
57103
|
|
|
57104
57104
|
// Return cached data if still valid
|
|
57105
|
-
if (!forceRefresh && cached && now - cached.timestamp < CACHE_TTL_MS) {
|
|
57105
|
+
if (!forceRefresh && cached && now - cached.timestamp < CACHE_TTL_MS$1) {
|
|
57106
57106
|
console.log(
|
|
57107
57107
|
`[RegistryController] Returning cached registry index (key=${cacheKey})`,
|
|
57108
57108
|
);
|
|
@@ -57199,7 +57199,7 @@ async function fetchRegistryIndex(forceRefresh = false) {
|
|
|
57199
57199
|
* @param {string[]} filters.appCapabilities - Only return packages whose required API providers are all in this list
|
|
57200
57200
|
* @returns {Promise<Object>} { packages: [...], totalWidgets: number }
|
|
57201
57201
|
*/
|
|
57202
|
-
async function searchRegistry$
|
|
57202
|
+
async function searchRegistry$3(query = "", filters = {}) {
|
|
57203
57203
|
const index = await fetchRegistryIndex();
|
|
57204
57204
|
let packages = index.packages || [];
|
|
57205
57205
|
|
|
@@ -57580,7 +57580,7 @@ async function checkUpdates(installedWidgets = []) {
|
|
|
57580
57580
|
* @returns {Promise<Object>} { packages: [...], totalWidgets: number }
|
|
57581
57581
|
*/
|
|
57582
57582
|
async function searchDashboards(query = "", filters = {}) {
|
|
57583
|
-
return searchRegistry$
|
|
57583
|
+
return searchRegistry$3(query, { ...filters, type: "dashboard" });
|
|
57584
57584
|
}
|
|
57585
57585
|
|
|
57586
57586
|
/**
|
|
@@ -57592,7 +57592,7 @@ async function searchDashboards(query = "", filters = {}) {
|
|
|
57592
57592
|
* @returns {Promise<Object>} { packages: [...], totalWidgets: number }
|
|
57593
57593
|
*/
|
|
57594
57594
|
async function searchThemes(query = "", filters = {}) {
|
|
57595
|
-
return searchRegistry$
|
|
57595
|
+
return searchRegistry$3(query, { ...filters, type: "theme" });
|
|
57596
57596
|
}
|
|
57597
57597
|
|
|
57598
57598
|
/**
|
|
@@ -57927,7 +57927,7 @@ async function fetchPackageManifest(packageName) {
|
|
|
57927
57927
|
|
|
57928
57928
|
var registryController$3 = {
|
|
57929
57929
|
fetchRegistryIndex,
|
|
57930
|
-
searchRegistry: searchRegistry$
|
|
57930
|
+
searchRegistry: searchRegistry$3,
|
|
57931
57931
|
searchDashboards,
|
|
57932
57932
|
searchThemes,
|
|
57933
57933
|
getPackage: getPackage$1,
|
|
@@ -64370,7 +64370,7 @@ const DEFAULT_TTL = 24 * 60 * 60 * 1000; // 24 hours
|
|
|
64370
64370
|
const MAX_ENTRIES = 50;
|
|
64371
64371
|
|
|
64372
64372
|
// Map preserves insertion order — we use this for LRU tracking
|
|
64373
|
-
const cache = new Map(); // url → { data, timestamp, ttl }
|
|
64373
|
+
const cache$1 = new Map(); // url → { data, timestamp, ttl }
|
|
64374
64374
|
|
|
64375
64375
|
/**
|
|
64376
64376
|
* Get a cached result for the given URL, or run the fetcher and cache the result.
|
|
@@ -64385,29 +64385,29 @@ async function get(url, fetcher, options = {}) {
|
|
|
64385
64385
|
const { ttl = DEFAULT_TTL, forceRefresh = false } = options;
|
|
64386
64386
|
const key = url.toLowerCase().replace(/\/+$/, ""); // normalize
|
|
64387
64387
|
|
|
64388
|
-
if (!forceRefresh && cache.has(key)) {
|
|
64389
|
-
const entry = cache.get(key);
|
|
64388
|
+
if (!forceRefresh && cache$1.has(key)) {
|
|
64389
|
+
const entry = cache$1.get(key);
|
|
64390
64390
|
if (Date.now() - entry.timestamp < entry.ttl) {
|
|
64391
64391
|
// Move to end (most recently used)
|
|
64392
|
-
cache.delete(key);
|
|
64393
|
-
cache.set(key, entry);
|
|
64392
|
+
cache$1.delete(key);
|
|
64393
|
+
cache$1.set(key, entry);
|
|
64394
64394
|
console.log(`[extractionCache] HIT ${key}`);
|
|
64395
64395
|
return entry.data;
|
|
64396
64396
|
}
|
|
64397
64397
|
// Expired
|
|
64398
|
-
cache.delete(key);
|
|
64398
|
+
cache$1.delete(key);
|
|
64399
64399
|
}
|
|
64400
64400
|
|
|
64401
64401
|
console.log(`[extractionCache] ${forceRefresh ? "REFRESH" : "MISS"} ${key}`);
|
|
64402
64402
|
const data = await fetcher();
|
|
64403
64403
|
|
|
64404
64404
|
// Store result
|
|
64405
|
-
cache.set(key, { data, timestamp: Date.now(), ttl });
|
|
64405
|
+
cache$1.set(key, { data, timestamp: Date.now(), ttl });
|
|
64406
64406
|
|
|
64407
64407
|
// LRU eviction — remove oldest entries if over limit
|
|
64408
|
-
while (cache.size > MAX_ENTRIES) {
|
|
64409
|
-
const oldestKey = cache.keys().next().value;
|
|
64410
|
-
cache.delete(oldestKey);
|
|
64408
|
+
while (cache$1.size > MAX_ENTRIES) {
|
|
64409
|
+
const oldestKey = cache$1.keys().next().value;
|
|
64410
|
+
cache$1.delete(oldestKey);
|
|
64411
64411
|
console.log(`[extractionCache] EVICT ${oldestKey}`);
|
|
64412
64412
|
}
|
|
64413
64413
|
|
|
@@ -64421,10 +64421,10 @@ async function get(url, fetcher, options = {}) {
|
|
|
64421
64421
|
*/
|
|
64422
64422
|
function has(url) {
|
|
64423
64423
|
const key = url.toLowerCase().replace(/\/+$/, "");
|
|
64424
|
-
if (!cache.has(key)) return false;
|
|
64425
|
-
const entry = cache.get(key);
|
|
64424
|
+
if (!cache$1.has(key)) return false;
|
|
64425
|
+
const entry = cache$1.get(key);
|
|
64426
64426
|
if (Date.now() - entry.timestamp >= entry.ttl) {
|
|
64427
|
-
cache.delete(key);
|
|
64427
|
+
cache$1.delete(key);
|
|
64428
64428
|
return false;
|
|
64429
64429
|
}
|
|
64430
64430
|
return true;
|
|
@@ -64432,7 +64432,7 @@ function has(url) {
|
|
|
64432
64432
|
|
|
64433
64433
|
/** Clear all cached entries. */
|
|
64434
64434
|
function clear() {
|
|
64435
|
-
cache.clear();
|
|
64435
|
+
cache$1.clear();
|
|
64436
64436
|
console.log("[extractionCache] CLEARED");
|
|
64437
64437
|
}
|
|
64438
64438
|
|
|
@@ -64442,15 +64442,15 @@ function clear() {
|
|
|
64442
64442
|
*/
|
|
64443
64443
|
function invalidate(url) {
|
|
64444
64444
|
const key = url.toLowerCase().replace(/\/+$/, "");
|
|
64445
|
-
cache.delete(key);
|
|
64445
|
+
cache$1.delete(key);
|
|
64446
64446
|
}
|
|
64447
64447
|
|
|
64448
64448
|
/** Get cache statistics. */
|
|
64449
64449
|
function stats() {
|
|
64450
64450
|
return {
|
|
64451
|
-
entries: cache.size,
|
|
64451
|
+
entries: cache$1.size,
|
|
64452
64452
|
maxEntries: MAX_ENTRIES,
|
|
64453
|
-
keys: [...cache.keys()],
|
|
64453
|
+
keys: [...cache$1.keys()],
|
|
64454
64454
|
};
|
|
64455
64455
|
}
|
|
64456
64456
|
|
|
@@ -71226,7 +71226,7 @@ const {
|
|
|
71226
71226
|
remapLayoutPackageScopes,
|
|
71227
71227
|
assertNoLocalScopes,
|
|
71228
71228
|
} = dashboardConfigUtils$1;
|
|
71229
|
-
const { searchRegistry, getPackage } = registryController$3;
|
|
71229
|
+
const { searchRegistry: searchRegistry$2, getPackage } = registryController$3;
|
|
71230
71230
|
const { getStoredToken, clearToken } = registryAuthController$2;
|
|
71231
71231
|
const themeController$2 = themeController_1;
|
|
71232
71232
|
|
|
@@ -80072,6 +80072,418 @@ function unassignTeam$1({ store, pause }, workspaceId) {
|
|
|
80072
80072
|
|
|
80073
80073
|
var teams = { normalizeWorkspaceId: normalizeWorkspaceId$1, isOnTeam: isOnTeam$2, teamOf: teamOf$1, unassignTeam: unassignTeam$1 };
|
|
80074
80074
|
|
|
80075
|
+
/**
|
|
80076
|
+
* providerDiscovery.js
|
|
80077
|
+
*
|
|
80078
|
+
* find_providers for team leads (bot-capabilities CAP-003): given a plain
|
|
80079
|
+
* description of a missing capability ("download an image from a URL"), find
|
|
80080
|
+
* providers that could fill it, in trust order:
|
|
80081
|
+
* 1. installed — the user's own providers (Settings › Providers)
|
|
80082
|
+
* 2. built-in — Dash's catalog (mcpServerCatalog.json)
|
|
80083
|
+
* 3. vetted — the curated known-external list
|
|
80084
|
+
* 4. community — the official MCP Registry (unverified)
|
|
80085
|
+
*
|
|
80086
|
+
* Read-only: nothing is installed here — leads only suggest, the user installs
|
|
80087
|
+
* (CAP-005). Local tiers use simple keyword matching; the registry does its own
|
|
80088
|
+
* search. Portable (NFR-006): no Electron — the catalogs, the user's providers
|
|
80089
|
+
* and the registry search are injected.
|
|
80090
|
+
*/
|
|
80091
|
+
|
|
80092
|
+
const TIER_ORDER = ["installed", "built-in", "vetted", "community"];
|
|
80093
|
+
const PER_TIER = { installed: 10, "built-in": 5, vetted: 5, community: 5 };
|
|
80094
|
+
const REGISTRY_KEYWORDS = 3;
|
|
80095
|
+
|
|
80096
|
+
const STOP_WORDS = new Set(
|
|
80097
|
+
(
|
|
80098
|
+
"a an the and or of to from for in on at by with into onto via as is are be " +
|
|
80099
|
+
"can could should would that this these those it its my your their our some " +
|
|
80100
|
+
"any all each per using use get make do does need needs want like such " +
|
|
80101
|
+
"provider providers tool tools server servers mcp service services"
|
|
80102
|
+
).split(" "),
|
|
80103
|
+
);
|
|
80104
|
+
|
|
80105
|
+
/** Meaningful lowercase words of a capability description. */
|
|
80106
|
+
function keywordsOf(text) {
|
|
80107
|
+
const seen = new Set();
|
|
80108
|
+
const out = [];
|
|
80109
|
+
for (const w of String(text || "")
|
|
80110
|
+
.toLowerCase()
|
|
80111
|
+
.split(/[^a-z0-9]+/)) {
|
|
80112
|
+
if (w.length < 3 || STOP_WORDS.has(w) || seen.has(w)) continue;
|
|
80113
|
+
seen.add(w);
|
|
80114
|
+
out.push(w);
|
|
80115
|
+
}
|
|
80116
|
+
return out;
|
|
80117
|
+
}
|
|
80118
|
+
|
|
80119
|
+
// "images" also matches "image", "pages" matches "page".
|
|
80120
|
+
function stem(word) {
|
|
80121
|
+
return word.length > 4 && word.endsWith("s") ? word.slice(0, -1) : word;
|
|
80122
|
+
}
|
|
80123
|
+
|
|
80124
|
+
// Common verbs/nouns that appear in most descriptions ("search", "send",
|
|
80125
|
+
// "messages"). They count toward a match but can't make one on their own.
|
|
80126
|
+
const WEAK_WORDS = new Set(
|
|
80127
|
+
(
|
|
80128
|
+
"search searches read write send sends find list create update delete manage " +
|
|
80129
|
+
"post check view open text message messages data file files web page pages " +
|
|
80130
|
+
"info information content api apis access account accounts query"
|
|
80131
|
+
).split(" "),
|
|
80132
|
+
);
|
|
80133
|
+
|
|
80134
|
+
const isWeak = (k) => WEAK_WORDS.has(k) || WEAK_WORDS.has(stem(k));
|
|
80135
|
+
|
|
80136
|
+
/** Words that say what's specific about the capability (else all of them). */
|
|
80137
|
+
function strongKeywords(keywords) {
|
|
80138
|
+
const strong = keywords.filter((k) => !isWeak(k));
|
|
80139
|
+
return strong.length ? strong : keywords;
|
|
80140
|
+
}
|
|
80141
|
+
|
|
80142
|
+
/**
|
|
80143
|
+
* How well `text` fits the capability: the number of keywords it contains,
|
|
80144
|
+
* or 0 unless it contains at least half of them including a specific
|
|
80145
|
+
* (non-weak) one — so "send SMS" doesn't match every messaging provider.
|
|
80146
|
+
*/
|
|
80147
|
+
function score(text, keywords) {
|
|
80148
|
+
const hay = String(text || "").toLowerCase();
|
|
80149
|
+
const hits = keywords.filter((k) => hay.includes(k) || hay.includes(stem(k)));
|
|
80150
|
+
if (!hits.length) return 0;
|
|
80151
|
+
const strong = keywords.filter((k) => !isWeak(k));
|
|
80152
|
+
if (strong.length && !hits.some((k) => !isWeak(k))) return 0;
|
|
80153
|
+
if (hits.length < Math.ceil(keywords.length / 2)) return 0;
|
|
80154
|
+
return hits.length;
|
|
80155
|
+
}
|
|
80156
|
+
|
|
80157
|
+
function catalogText(entry) {
|
|
80158
|
+
return [entry.id, entry.name, entry.description, ...(entry.tags || [])].join(
|
|
80159
|
+
" ",
|
|
80160
|
+
);
|
|
80161
|
+
}
|
|
80162
|
+
|
|
80163
|
+
/** What a catalog entry runs, in a few words. */
|
|
80164
|
+
function describeRuns(mcpConfig) {
|
|
80165
|
+
const c = mcpConfig || {};
|
|
80166
|
+
if (c.transport === "in_process") return "Built into Dash";
|
|
80167
|
+
if (c.transport === "streamable_http") return c.url || "Remote server";
|
|
80168
|
+
return [c.command, ...(c.args || [])].filter(Boolean).join(" ");
|
|
80169
|
+
}
|
|
80170
|
+
|
|
80171
|
+
/** Display names of the credentials a catalog entry asks for. */
|
|
80172
|
+
function credentialsOf(credentialSchema) {
|
|
80173
|
+
return Object.entries(credentialSchema || {})
|
|
80174
|
+
.filter(([, f]) => f && (f.secret === true || f.required === true))
|
|
80175
|
+
.map(([key, f]) => f.displayName || key);
|
|
80176
|
+
}
|
|
80177
|
+
|
|
80178
|
+
function fromCatalog(entry, tier) {
|
|
80179
|
+
return {
|
|
80180
|
+
id: `${tier === "vetted" ? "vetted" : "builtin"}:${entry.id}`,
|
|
80181
|
+
tier,
|
|
80182
|
+
name: entry.name,
|
|
80183
|
+
description: entry.description || "",
|
|
80184
|
+
runs: describeRuns(entry.mcpConfig),
|
|
80185
|
+
credentials: credentialsOf(entry.credentialSchema),
|
|
80186
|
+
sourceUrl: entry.sourceUrl || null,
|
|
80187
|
+
installable: true,
|
|
80188
|
+
install: {
|
|
80189
|
+
kind: tier === "vetted" ? "vetted" : "catalog",
|
|
80190
|
+
catalogId: entry.id,
|
|
80191
|
+
},
|
|
80192
|
+
};
|
|
80193
|
+
}
|
|
80194
|
+
|
|
80195
|
+
// Registry rows → one entry per server, latest version, with install info.
|
|
80196
|
+
function latestOf(rows) {
|
|
80197
|
+
const meta = (r) =>
|
|
80198
|
+
(r && r._meta && r._meta["io.modelcontextprotocol.registry/official"]) ||
|
|
80199
|
+
{};
|
|
80200
|
+
return rows.slice().sort((a, b) => {
|
|
80201
|
+
const la = meta(a).isLatest ? 1 : 0;
|
|
80202
|
+
const lb = meta(b).isLatest ? 1 : 0;
|
|
80203
|
+
if (la !== lb) return lb - la;
|
|
80204
|
+
return String(meta(b).updatedAt || "").localeCompare(
|
|
80205
|
+
String(meta(a).updatedAt || ""),
|
|
80206
|
+
);
|
|
80207
|
+
})[0];
|
|
80208
|
+
}
|
|
80209
|
+
|
|
80210
|
+
function registryInstall(server) {
|
|
80211
|
+
for (const pkg of Array.isArray(server.packages) ? server.packages : []) {
|
|
80212
|
+
const id = pkg && pkg.identifier;
|
|
80213
|
+
if (!id) continue;
|
|
80214
|
+
const spec = pkg.version ? `${id}@${pkg.version}` : id;
|
|
80215
|
+
let mcpConfig = null;
|
|
80216
|
+
if (pkg.registryType === "npm") {
|
|
80217
|
+
mcpConfig = { transport: "stdio", command: "npx", args: ["-y", spec] };
|
|
80218
|
+
} else if (pkg.registryType === "pypi") {
|
|
80219
|
+
mcpConfig = {
|
|
80220
|
+
transport: "stdio",
|
|
80221
|
+
command: "uvx",
|
|
80222
|
+
args: [pkg.version ? `${id}==${pkg.version}` : id],
|
|
80223
|
+
};
|
|
80224
|
+
}
|
|
80225
|
+
if (!mcpConfig) continue;
|
|
80226
|
+
const envMapping = {};
|
|
80227
|
+
const credentialSchema = {};
|
|
80228
|
+
for (const v of Array.isArray(pkg.environmentVariables)
|
|
80229
|
+
? pkg.environmentVariables
|
|
80230
|
+
: []) {
|
|
80231
|
+
if (!v || !v.name) continue;
|
|
80232
|
+
envMapping[v.name] = v.name;
|
|
80233
|
+
credentialSchema[v.name] = {
|
|
80234
|
+
type: "text",
|
|
80235
|
+
displayName: v.name,
|
|
80236
|
+
required: !!v.isRequired,
|
|
80237
|
+
secret: !!v.isSecret,
|
|
80238
|
+
instructions: v.description || null,
|
|
80239
|
+
};
|
|
80240
|
+
}
|
|
80241
|
+
mcpConfig.envMapping = envMapping;
|
|
80242
|
+
return { mcpConfig, credentialSchema };
|
|
80243
|
+
}
|
|
80244
|
+
for (const remote of Array.isArray(server.remotes) ? server.remotes : []) {
|
|
80245
|
+
if (!remote || remote.type !== "streamable-http" || !remote.url) continue;
|
|
80246
|
+
const mcpConfig = { transport: "streamable_http", url: remote.url };
|
|
80247
|
+
const credentialSchema = {};
|
|
80248
|
+
const headerTemplate = {};
|
|
80249
|
+
for (const h of Array.isArray(remote.headers) ? remote.headers : []) {
|
|
80250
|
+
if (!h || !h.name) continue;
|
|
80251
|
+
const key = h.name.replace(/[^A-Za-z0-9]/g, "");
|
|
80252
|
+
headerTemplate[h.name] = `{{${key}}}`;
|
|
80253
|
+
credentialSchema[key] = {
|
|
80254
|
+
type: "text",
|
|
80255
|
+
displayName: h.name,
|
|
80256
|
+
required: !!h.isRequired,
|
|
80257
|
+
secret: !!h.isSecret,
|
|
80258
|
+
instructions: h.description || null,
|
|
80259
|
+
};
|
|
80260
|
+
}
|
|
80261
|
+
if (Object.keys(headerTemplate).length)
|
|
80262
|
+
mcpConfig.headerTemplate = headerTemplate;
|
|
80263
|
+
return { mcpConfig, credentialSchema };
|
|
80264
|
+
}
|
|
80265
|
+
return null;
|
|
80266
|
+
}
|
|
80267
|
+
|
|
80268
|
+
/**
|
|
80269
|
+
* @param {{ servers?: object[] }} json MCP Registry /v0/servers response
|
|
80270
|
+
* @param {string[]} keywords for ranking
|
|
80271
|
+
*/
|
|
80272
|
+
function normalizeRegistryServers(json, keywords = []) {
|
|
80273
|
+
const rows = (json && Array.isArray(json.servers) ? json.servers : []).filter(
|
|
80274
|
+
(r) => r && r.server && r.server.name,
|
|
80275
|
+
);
|
|
80276
|
+
const byName = new Map();
|
|
80277
|
+
for (const r of rows) {
|
|
80278
|
+
const list = byName.get(r.server.name) || [];
|
|
80279
|
+
list.push(r);
|
|
80280
|
+
byName.set(r.server.name, list);
|
|
80281
|
+
}
|
|
80282
|
+
const out = [];
|
|
80283
|
+
for (const [name, list] of byName) {
|
|
80284
|
+
const server = latestOf(list).server;
|
|
80285
|
+
const install = registryInstall(server);
|
|
80286
|
+
const kinds = [
|
|
80287
|
+
...new Set(
|
|
80288
|
+
[
|
|
80289
|
+
...(server.packages || []).map((p) => p && p.registryType),
|
|
80290
|
+
...(server.remotes || []).map((r) => r && r.type),
|
|
80291
|
+
].filter(Boolean),
|
|
80292
|
+
),
|
|
80293
|
+
];
|
|
80294
|
+
out.push({
|
|
80295
|
+
id: `community:${name}`,
|
|
80296
|
+
tier: "community",
|
|
80297
|
+
name: server.title || name,
|
|
80298
|
+
description: String(server.description || "").slice(0, 300),
|
|
80299
|
+
version: server.version || null,
|
|
80300
|
+
runs: install
|
|
80301
|
+
? describeRuns(install.mcpConfig)
|
|
80302
|
+
: `No install info Dash can use${kinds.length ? ` (${kinds.join(", ")})` : ""}`,
|
|
80303
|
+
credentials: install ? Object.keys(install.credentialSchema) : [],
|
|
80304
|
+
sourceUrl:
|
|
80305
|
+
(server.repository && server.repository.url) ||
|
|
80306
|
+
server.websiteUrl ||
|
|
80307
|
+
null,
|
|
80308
|
+
installable: !!install,
|
|
80309
|
+
install: install
|
|
80310
|
+
? { kind: "custom", name: server.title || name, ...install }
|
|
80311
|
+
: null,
|
|
80312
|
+
_score: registryScore(
|
|
80313
|
+
`${name} ${server.title || ""} ${server.description || ""}`,
|
|
80314
|
+
keywords,
|
|
80315
|
+
),
|
|
80316
|
+
});
|
|
80317
|
+
}
|
|
80318
|
+
return out.filter((e) => e._score > 0 || !keywords.length);
|
|
80319
|
+
}
|
|
80320
|
+
|
|
80321
|
+
// The registry already matched the query, so one specific word is enough
|
|
80322
|
+
// (it ranks; the strict local rule would drop good one-line descriptions).
|
|
80323
|
+
function registryScore(text, keywords) {
|
|
80324
|
+
const hay = String(text || "").toLowerCase();
|
|
80325
|
+
const hits = keywords.filter((k) => hay.includes(k) || hay.includes(stem(k)));
|
|
80326
|
+
return hits.some((k) => strongKeywords(keywords).includes(k))
|
|
80327
|
+
? hits.length
|
|
80328
|
+
: 0;
|
|
80329
|
+
}
|
|
80330
|
+
|
|
80331
|
+
/**
|
|
80332
|
+
* @param {string} capability
|
|
80333
|
+
* @param {{ listInstalled: () => object[], getCatalog: () => object[],
|
|
80334
|
+
* getKnownExternal: () => object[],
|
|
80335
|
+
* searchRegistry: (query: string) => Promise<object> }} deps
|
|
80336
|
+
* @returns {Promise<{ results: object[], notes: string[] }>}
|
|
80337
|
+
*/
|
|
80338
|
+
async function findProviders$1(capability, deps) {
|
|
80339
|
+
const keywords = keywordsOf(capability);
|
|
80340
|
+
if (!keywords.length) {
|
|
80341
|
+
throw new Error(
|
|
80342
|
+
"Describe the capability you need, e.g. 'download an image from a URL'.",
|
|
80343
|
+
);
|
|
80344
|
+
}
|
|
80345
|
+
const notes = [];
|
|
80346
|
+
const catalog = (deps.getCatalog && deps.getCatalog()) || [];
|
|
80347
|
+
const vetted = (deps.getKnownExternal && deps.getKnownExternal()) || [];
|
|
80348
|
+
const installed = (deps.listInstalled && deps.listInstalled()) || [];
|
|
80349
|
+
const catalogById = new Map(
|
|
80350
|
+
[...catalog, ...vetted].filter((e) => e && e.id).map((e) => [e.id, e]),
|
|
80351
|
+
);
|
|
80352
|
+
|
|
80353
|
+
const tiers = { installed: [], "built-in": [], vetted: [], community: [] };
|
|
80354
|
+
|
|
80355
|
+
// 1. Installed — matched on name, type, tools, and their catalog entry.
|
|
80356
|
+
const installedTypes = new Set();
|
|
80357
|
+
for (const p of installed) {
|
|
80358
|
+
if (!p || !p.name) continue;
|
|
80359
|
+
const entry = catalogById.get(p.type);
|
|
80360
|
+
const s = score(
|
|
80361
|
+
[
|
|
80362
|
+
p.name,
|
|
80363
|
+
p.type,
|
|
80364
|
+
...(p.tools || []),
|
|
80365
|
+
entry ? catalogText(entry) : "",
|
|
80366
|
+
].join(" "),
|
|
80367
|
+
keywords,
|
|
80368
|
+
);
|
|
80369
|
+
if (!s) continue;
|
|
80370
|
+
if (p.type) installedTypes.add(p.type);
|
|
80371
|
+
tiers.installed.push({
|
|
80372
|
+
id: `installed:${p.name}`,
|
|
80373
|
+
tier: "installed",
|
|
80374
|
+
name: p.name,
|
|
80375
|
+
description: entry ? entry.description || "" : "",
|
|
80376
|
+
runs: "Already set up",
|
|
80377
|
+
credentials: [],
|
|
80378
|
+
sourceUrl: null,
|
|
80379
|
+
installable: true,
|
|
80380
|
+
install: { kind: "use", providerName: p.name },
|
|
80381
|
+
tools: Array.isArray(p.tools) ? p.tools : null,
|
|
80382
|
+
_score: s,
|
|
80383
|
+
});
|
|
80384
|
+
}
|
|
80385
|
+
|
|
80386
|
+
// 2–3. Built-in and vetted catalogs (skip types the user already has).
|
|
80387
|
+
for (const [tier, list] of [
|
|
80388
|
+
["built-in", catalog],
|
|
80389
|
+
["vetted", vetted],
|
|
80390
|
+
]) {
|
|
80391
|
+
for (const entry of list) {
|
|
80392
|
+
if (!entry || !entry.id || installedTypes.has(entry.id)) continue;
|
|
80393
|
+
const s = score(catalogText(entry), keywords);
|
|
80394
|
+
if (s) tiers[tier].push({ ...fromCatalog(entry, tier), _score: s });
|
|
80395
|
+
}
|
|
80396
|
+
}
|
|
80397
|
+
|
|
80398
|
+
// 4. Community — the registry searches by keyword; merge a few searches.
|
|
80399
|
+
// A failed search doesn't sink the others (the registry can be flaky).
|
|
80400
|
+
if (typeof deps.searchRegistry === "function") {
|
|
80401
|
+
const settled = await Promise.allSettled(
|
|
80402
|
+
strongKeywords(keywords)
|
|
80403
|
+
.slice(0, REGISTRY_KEYWORDS)
|
|
80404
|
+
.map((k) => Promise.resolve().then(() => deps.searchRegistry(k))),
|
|
80405
|
+
);
|
|
80406
|
+
const ok = settled.filter((s) => s.status === "fulfilled");
|
|
80407
|
+
if (!ok.length) {
|
|
80408
|
+
notes.push(
|
|
80409
|
+
"Community search (the MCP Registry) is unavailable right now; showing Dash's own lists only.",
|
|
80410
|
+
);
|
|
80411
|
+
} else {
|
|
80412
|
+
const merged = {
|
|
80413
|
+
servers: ok.flatMap((s) =>
|
|
80414
|
+
s.value && Array.isArray(s.value.servers) ? s.value.servers : [],
|
|
80415
|
+
),
|
|
80416
|
+
};
|
|
80417
|
+
tiers.community = normalizeRegistryServers(merged, keywords);
|
|
80418
|
+
if (ok.length < settled.length) {
|
|
80419
|
+
notes.push(
|
|
80420
|
+
"Some community searches (the MCP Registry) didn't answer; results may be incomplete.",
|
|
80421
|
+
);
|
|
80422
|
+
}
|
|
80423
|
+
}
|
|
80424
|
+
}
|
|
80425
|
+
|
|
80426
|
+
const results = [];
|
|
80427
|
+
for (const tier of TIER_ORDER) {
|
|
80428
|
+
tiers[tier]
|
|
80429
|
+
.sort((a, b) => b._score - a._score)
|
|
80430
|
+
.slice(0, PER_TIER[tier])
|
|
80431
|
+
.forEach(({ _score, ...entry }) => results.push(entry));
|
|
80432
|
+
}
|
|
80433
|
+
return { results, notes };
|
|
80434
|
+
}
|
|
80435
|
+
|
|
80436
|
+
/** The lead-facing text for find_providers results (fenced by the caller). */
|
|
80437
|
+
function describeFindings$1(capability, { results, notes }) {
|
|
80438
|
+
const label = {
|
|
80439
|
+
installed: "Already set up (use these first)",
|
|
80440
|
+
"built-in": "Built into Dash (the user adds it in Settings › Providers)",
|
|
80441
|
+
vetted: "Vetted by Dash (the user installs it after a confirmation)",
|
|
80442
|
+
community:
|
|
80443
|
+
"Community — UNVERIFIED third-party code from the MCP Registry (only if nothing above fits)",
|
|
80444
|
+
};
|
|
80445
|
+
const lines = [`Providers for "${capability}":`];
|
|
80446
|
+
if (!results.length) {
|
|
80447
|
+
lines.push(
|
|
80448
|
+
"Nothing found. Put the capability in propose_bot's needs so the user knows it's missing.",
|
|
80449
|
+
);
|
|
80450
|
+
}
|
|
80451
|
+
for (const tier of TIER_ORDER) {
|
|
80452
|
+
const group = results.filter((e) => e.tier === tier);
|
|
80453
|
+
if (!group.length) continue;
|
|
80454
|
+
lines.push("", `${label[tier]}:`);
|
|
80455
|
+
for (const e of group) {
|
|
80456
|
+
const bits = [`- ${e.name} [id: ${e.id}]`];
|
|
80457
|
+
if (e.description) bits.push(`— ${e.description}`);
|
|
80458
|
+
lines.push(bits.join(" "));
|
|
80459
|
+
const details = [`runs: ${e.runs}`];
|
|
80460
|
+
if (e.tools && e.tools.length)
|
|
80461
|
+
details.push(`tools: ${e.tools.join(", ")}`);
|
|
80462
|
+
if (e.credentials.length)
|
|
80463
|
+
details.push(`needs: ${e.credentials.join(", ")}`);
|
|
80464
|
+
if (e.sourceUrl) details.push(`source: ${e.sourceUrl}`);
|
|
80465
|
+
if (!e.installable) details.push("can't be installed from Dash");
|
|
80466
|
+
lines.push(` ${details.join(" · ")}`);
|
|
80467
|
+
}
|
|
80468
|
+
}
|
|
80469
|
+
for (const n of notes) lines.push("", n);
|
|
80470
|
+
if (results.length) {
|
|
80471
|
+
lines.push(
|
|
80472
|
+
"",
|
|
80473
|
+
"To suggest one on a draft, pass propose_bot gaps: [{ need, suggestions: [id, …] }] using the ids above. Installed providers can also go straight in providers. You can't install anything — the user does.",
|
|
80474
|
+
);
|
|
80475
|
+
}
|
|
80476
|
+
return lines.join("\n");
|
|
80477
|
+
}
|
|
80478
|
+
|
|
80479
|
+
var providerDiscovery = {
|
|
80480
|
+
findProviders: findProviders$1,
|
|
80481
|
+
describeFindings: describeFindings$1,
|
|
80482
|
+
keywordsOf,
|
|
80483
|
+
normalizeRegistryServers,
|
|
80484
|
+
TIER_ORDER,
|
|
80485
|
+
};
|
|
80486
|
+
|
|
80075
80487
|
/**
|
|
80076
80488
|
* teamTools.js
|
|
80077
80489
|
*
|
|
@@ -80093,6 +80505,7 @@ var teams = { normalizeWorkspaceId: normalizeWorkspaceId$1, isOnTeam: isOnTeam$2
|
|
|
80093
80505
|
*/
|
|
80094
80506
|
|
|
80095
80507
|
const { teamOf } = teams;
|
|
80508
|
+
const { describeFindings } = providerDiscovery;
|
|
80096
80509
|
|
|
80097
80510
|
const TEAM_SERVER$1 = "bot-team";
|
|
80098
80511
|
const RUN_ANSWER_LIMIT = 1500;
|
|
@@ -80156,10 +80569,26 @@ const TEAM_TOOLS$2 = [
|
|
|
80156
80569
|
"List the user's providers (from Settings › Providers): name, type, and the tools each one offers. Use this before propose_bot so a draft suggests providers the user actually has.",
|
|
80157
80570
|
inputSchema: { type: "object", properties: {} },
|
|
80158
80571
|
},
|
|
80572
|
+
{
|
|
80573
|
+
name: "find_providers",
|
|
80574
|
+
description:
|
|
80575
|
+
"Search for providers that could give a bot a capability the user's providers don't cover (e.g. 'download an image from a URL', 'search stock photos'). Looks in the user's providers, Dash's built-in catalog, Dash's vetted list, and the public MCP Registry (unverified community servers), in that order, and returns ids you can suggest in propose_bot's gaps. Read-only: you can't install anything; the user does.",
|
|
80576
|
+
inputSchema: {
|
|
80577
|
+
type: "object",
|
|
80578
|
+
properties: {
|
|
80579
|
+
capability: {
|
|
80580
|
+
type: "string",
|
|
80581
|
+
description:
|
|
80582
|
+
"What the bot needs to do, in a few plain words — e.g. 'download images', 'send SMS'.",
|
|
80583
|
+
},
|
|
80584
|
+
},
|
|
80585
|
+
required: ["capability"],
|
|
80586
|
+
},
|
|
80587
|
+
},
|
|
80159
80588
|
{
|
|
80160
80589
|
name: "propose_bot",
|
|
80161
80590
|
description:
|
|
80162
|
-
"Draft a new bot for this team when the user asks for one. Creates a DRAFT only — the user reviews it in this dashboard's Bots view and saves it themselves; you can't create, save or run bots. Call team_providers first and suggest only those providers (by name or type)
|
|
80591
|
+
"Draft a new bot for this team when the user asks for one. Creates a DRAFT only — the user reviews it in this dashboard's Bots view and saves it themselves; you can't create, save or run bots. Call team_providers first and suggest only those providers (by name or type). For a capability none of them covers, call find_providers and list it in 'gaps' with the ids it returned, so the user can add one from the review. Event triggers can only be other bots on this team finishing ('completed') or failing ('failed'). If a team bot already does this, say so instead of drafting a duplicate.",
|
|
80163
80592
|
inputSchema: {
|
|
80164
80593
|
type: "object",
|
|
80165
80594
|
properties: {
|
|
@@ -80212,6 +80641,27 @@ const TEAM_TOOLS$2 = [
|
|
|
80212
80641
|
"Short names of services the user would need a provider for (e.g. 'Microsoft Teams'). Put anything else in reasoning.",
|
|
80213
80642
|
items: { type: "string" },
|
|
80214
80643
|
},
|
|
80644
|
+
gaps: {
|
|
80645
|
+
type: "array",
|
|
80646
|
+
description:
|
|
80647
|
+
"Capabilities the user's providers don't cover, each with provider ids from find_providers that could fill it (best first). Only ids find_providers returned are kept.",
|
|
80648
|
+
items: {
|
|
80649
|
+
type: "object",
|
|
80650
|
+
properties: {
|
|
80651
|
+
need: {
|
|
80652
|
+
type: "string",
|
|
80653
|
+
description: "The capability, e.g. 'download images'.",
|
|
80654
|
+
},
|
|
80655
|
+
suggestions: {
|
|
80656
|
+
type: "array",
|
|
80657
|
+
description:
|
|
80658
|
+
"Ids from find_providers, e.g. 'builtin:web-fetch'.",
|
|
80659
|
+
items: { type: "string" },
|
|
80660
|
+
},
|
|
80661
|
+
},
|
|
80662
|
+
required: ["need"],
|
|
80663
|
+
},
|
|
80664
|
+
},
|
|
80215
80665
|
},
|
|
80216
80666
|
required: ["name", "instructions"],
|
|
80217
80667
|
},
|
|
@@ -80408,6 +80858,24 @@ function handleTeamTool$1(deps, ctx, toolName, args = {}) {
|
|
|
80408
80858
|
.join("\n"),
|
|
80409
80859
|
);
|
|
80410
80860
|
}
|
|
80861
|
+
case "find_providers": {
|
|
80862
|
+
// Async (the registry search); callers await tool results.
|
|
80863
|
+
const capability = String((args && args.capability) || "").trim();
|
|
80864
|
+
if (!capability) {
|
|
80865
|
+
return fail$1("Say what capability you need, e.g. 'download images'.");
|
|
80866
|
+
}
|
|
80867
|
+
if (typeof deps.findProviders !== "function") {
|
|
80868
|
+
return fail$1("Finding providers isn't available here.");
|
|
80869
|
+
}
|
|
80870
|
+
return Promise.resolve()
|
|
80871
|
+
.then(() => deps.findProviders(ctx, capability))
|
|
80872
|
+
.then((found) => ok$1(describeFindings(capability, found)))
|
|
80873
|
+
.catch((err) =>
|
|
80874
|
+
fail$1(
|
|
80875
|
+
`Couldn't search for providers: ${err.message || String(err)}`,
|
|
80876
|
+
),
|
|
80877
|
+
);
|
|
80878
|
+
}
|
|
80411
80879
|
case "propose_bot": {
|
|
80412
80880
|
if (typeof deps.proposeBot !== "function") {
|
|
80413
80881
|
return fail$1("Drafting bots isn't available here.");
|
|
@@ -80450,6 +80918,15 @@ function describeDraft(draft) {
|
|
|
80450
80918
|
.join("; "),
|
|
80451
80919
|
);
|
|
80452
80920
|
}
|
|
80921
|
+
for (const gap of draft.gaps || []) {
|
|
80922
|
+
lines.push(
|
|
80923
|
+
gap.suggestions.length
|
|
80924
|
+
? `For "${gap.need}" the user can add: ${gap.suggestions
|
|
80925
|
+
.map((s) => `${s.name} (${s.tier})`)
|
|
80926
|
+
.join(", ")} — from the draft review.`
|
|
80927
|
+
: `For "${gap.need}" no suggested provider was kept (only ids from find_providers count).`,
|
|
80928
|
+
);
|
|
80929
|
+
}
|
|
80453
80930
|
if (draft.missing && draft.missing.length) {
|
|
80454
80931
|
lines.push(
|
|
80455
80932
|
`Needs a provider the user doesn't have: ${draft.missing.join(", ")} — they can add it in Settings › Providers.`,
|
|
@@ -80545,8 +81022,10 @@ function defaultLeadProvider(providers) {
|
|
|
80545
81022
|
// versions are kept so ensureLead can upgrade leads still using them —
|
|
80546
81023
|
// instructions the user edited are never touched.
|
|
80547
81024
|
const CURRENT_LEAD_ACTION =
|
|
80548
|
-
"You can't change, save or run bots yourself. If the user wants a new bot, check team_providers for what they have, draft it with propose_bot, and tell them it's waiting for their review in this dashboard's Bots view (under Drafts) — never say it's created. Drafts you made earlier may have been saved or discarded since — check team_list_bots before saying one is waiting. If they want to change an existing bot, describe the change and point them to that bot's Settings tab in the Bots view.";
|
|
81025
|
+
"You can't change, save or run bots yourself. If the user wants a new bot, check team_providers for what they have, draft it with propose_bot, and tell them it's waiting for their review in this dashboard's Bots view (under Drafts) — never say it's created. If the bot needs something none of their providers can do, use find_providers to look for one and list it in propose_bot's gaps; never tell the user it's impossible without searching first, and remember you can only suggest — the user installs. Drafts you made earlier may have been saved or discarded since — check team_list_bots before saying one is waiting. If they want to change an existing bot, describe the change and point them to that bot's Settings tab in the Bots view.";
|
|
80549
81026
|
const LEAD_ACTION_HISTORY = [
|
|
81027
|
+
// TEAM-005 (before find_providers, bot-capabilities CAP-003)
|
|
81028
|
+
"You can't change, save or run bots yourself. If the user wants a new bot, check team_providers for what they have, draft it with propose_bot, and tell them it's waiting for their review in this dashboard's Bots view (under Drafts) — never say it's created. Drafts you made earlier may have been saved or discarded since — check team_list_bots before saying one is waiting. If they want to change an existing bot, describe the change and point them to that bot's Settings tab in the Bots view.",
|
|
80550
81029
|
// TEAM-005 5a/5b (before checking current drafts)
|
|
80551
81030
|
"You can't change, save or run bots yourself. If the user wants a new bot, check team_providers for what they have, draft it with propose_bot, and tell them it's waiting for their review in this dashboard's Bots view (under Drafts) — never say it's created. If they want to change an existing bot, describe the change and point them to that bot's Settings tab in the Bots view.",
|
|
80552
81031
|
// TEAM-005 development build (before team_providers)
|
|
@@ -80762,6 +81241,10 @@ const MAX_NAME = 80;
|
|
|
80762
81241
|
const MAX_INSTRUCTIONS = 8000;
|
|
80763
81242
|
const MAX_REASONING = 1000;
|
|
80764
81243
|
const MAX_PER_DASHBOARD = 10;
|
|
81244
|
+
const MAX_GAPS = 10;
|
|
81245
|
+
const MAX_SUGGESTIONS = 5;
|
|
81246
|
+
// find_providers tiers, most trusted first (providerDiscovery.TIER_ORDER).
|
|
81247
|
+
const TIER_RANK = ["installed", "built-in", "vetted", "community"];
|
|
80765
81248
|
|
|
80766
81249
|
const str = (v, max) =>
|
|
80767
81250
|
String(v === undefined || v === null ? "" : v)
|
|
@@ -80793,6 +81276,7 @@ function buildDraft$1({
|
|
|
80793
81276
|
team = [],
|
|
80794
81277
|
workspaceId,
|
|
80795
81278
|
leadId,
|
|
81279
|
+
knownProviders = {},
|
|
80796
81280
|
now,
|
|
80797
81281
|
}) {
|
|
80798
81282
|
const name = str(proposal.name, MAX_NAME);
|
|
@@ -80852,6 +81336,40 @@ function buildDraft$1({
|
|
|
80852
81336
|
if (!have && !missing.includes(n)) missing.push(n);
|
|
80853
81337
|
}
|
|
80854
81338
|
|
|
81339
|
+
// Gaps with suggested providers (bot-capabilities CAP-004): only ids the
|
|
81340
|
+
// lead's find_providers actually returned survive, kept as snapshots so the
|
|
81341
|
+
// review can install without searching again. Best tier first.
|
|
81342
|
+
const gaps = [];
|
|
81343
|
+
for (const gap of (Array.isArray(proposal.gaps) ? proposal.gaps : []).slice(
|
|
81344
|
+
0,
|
|
81345
|
+
MAX_GAPS,
|
|
81346
|
+
)) {
|
|
81347
|
+
const need = str(gap && gap.need, 200);
|
|
81348
|
+
if (!need) continue;
|
|
81349
|
+
const suggestions = [];
|
|
81350
|
+
for (const id of Array.isArray(gap.suggestions) ? gap.suggestions : []) {
|
|
81351
|
+
const key = str(id, 300);
|
|
81352
|
+
const entry =
|
|
81353
|
+
key && Object.prototype.hasOwnProperty.call(knownProviders, key)
|
|
81354
|
+
? knownProviders[key]
|
|
81355
|
+
: null;
|
|
81356
|
+
if (!entry) {
|
|
81357
|
+
if (key) {
|
|
81358
|
+
dropped.push(
|
|
81359
|
+
`Suggested provider "${key}" — not from your find_providers results.`,
|
|
81360
|
+
);
|
|
81361
|
+
}
|
|
81362
|
+
continue;
|
|
81363
|
+
}
|
|
81364
|
+
if (!suggestions.some((s) => s.id === entry.id)) suggestions.push(entry);
|
|
81365
|
+
}
|
|
81366
|
+
suggestions.sort(
|
|
81367
|
+
(a, b) => TIER_RANK.indexOf(a.tier) - TIER_RANK.indexOf(b.tier),
|
|
81368
|
+
);
|
|
81369
|
+
gaps.push({ need, suggestions: suggestions.slice(0, MAX_SUGGESTIONS) });
|
|
81370
|
+
if (!missing.includes(need)) missing.push(need);
|
|
81371
|
+
}
|
|
81372
|
+
|
|
80855
81373
|
// Schedule (optional).
|
|
80856
81374
|
const schedules = [];
|
|
80857
81375
|
const sched = proposal.schedule;
|
|
@@ -80920,6 +81438,7 @@ function buildDraft$1({
|
|
|
80920
81438
|
reasoning: str(proposal.reasoning, MAX_REASONING),
|
|
80921
81439
|
definition,
|
|
80922
81440
|
suggestions,
|
|
81441
|
+
gaps,
|
|
80923
81442
|
missing,
|
|
80924
81443
|
dropped,
|
|
80925
81444
|
duplicateOf: dup ? dup.name : null,
|
|
@@ -80989,6 +81508,65 @@ let DraftStore$1 = class DraftStore {
|
|
|
80989
81508
|
|
|
80990
81509
|
var botDrafts = { buildDraft: buildDraft$1, DraftStore: DraftStore$1, BOT_EVENTS };
|
|
80991
81510
|
|
|
81511
|
+
/**
|
|
81512
|
+
* registrySearch.js
|
|
81513
|
+
*
|
|
81514
|
+
* Searches the official MCP Registry for find_providers' community tier
|
|
81515
|
+
* (bot-capabilities CAP-003). Uses Web Fetch's safeFetch pinned to the
|
|
81516
|
+
* registry host (HTTPS, size cap, timeout, no internal addresses) and caches
|
|
81517
|
+
* each query for a few minutes. Portable — no Electron.
|
|
81518
|
+
*/
|
|
81519
|
+
|
|
81520
|
+
const { safeFetch } = safeFetch_1;
|
|
81521
|
+
|
|
81522
|
+
const REGISTRY_HOST = "registry.modelcontextprotocol.io";
|
|
81523
|
+
const CACHE_TTL_MS = 5 * 60 * 1000;
|
|
81524
|
+
const LIMIT = 30;
|
|
81525
|
+
|
|
81526
|
+
const cache = new Map(); // query → { at, value }
|
|
81527
|
+
|
|
81528
|
+
/**
|
|
81529
|
+
* @param {string} query
|
|
81530
|
+
* @param {{ open?: Function }} deps injectable transport (tests)
|
|
81531
|
+
* @returns {Promise<object>} the registry's /v0/servers JSON
|
|
81532
|
+
*/
|
|
81533
|
+
async function searchRegistry$1(query, deps = {}) {
|
|
81534
|
+
const q = String(query || "").trim();
|
|
81535
|
+
const hit = cache.get(q);
|
|
81536
|
+
if (hit && Date.now() - hit.at < CACHE_TTL_MS) return hit.value;
|
|
81537
|
+
|
|
81538
|
+
const url = new URL(`https://${REGISTRY_HOST}/v0/servers`);
|
|
81539
|
+
url.searchParams.set("search", q);
|
|
81540
|
+
// No version=latest: the registry answers that query slowly or with a 500;
|
|
81541
|
+
// findProviders keeps the latest version of each server itself.
|
|
81542
|
+
url.searchParams.set("limit", String(LIMIT));
|
|
81543
|
+
|
|
81544
|
+
const res = await safeFetch(
|
|
81545
|
+
url.href,
|
|
81546
|
+
{
|
|
81547
|
+
maxBytes: 2 * 1024 * 1024,
|
|
81548
|
+
timeoutMs: 10000,
|
|
81549
|
+
allowedSites: [REGISTRY_HOST],
|
|
81550
|
+
accept: "application/json",
|
|
81551
|
+
},
|
|
81552
|
+
deps.open ? { open: deps.open } : {},
|
|
81553
|
+
);
|
|
81554
|
+
let value;
|
|
81555
|
+
try {
|
|
81556
|
+
value = JSON.parse(res.buffer.toString("utf8"));
|
|
81557
|
+
} catch (_e) {
|
|
81558
|
+
throw new Error("The MCP Registry returned something that isn't JSON.");
|
|
81559
|
+
}
|
|
81560
|
+
cache.set(q, { at: Date.now(), value });
|
|
81561
|
+
return value;
|
|
81562
|
+
}
|
|
81563
|
+
|
|
81564
|
+
function __clearCacheForTest() {
|
|
81565
|
+
cache.clear();
|
|
81566
|
+
}
|
|
81567
|
+
|
|
81568
|
+
var registrySearch = { searchRegistry: searchRegistry$1, REGISTRY_HOST, __clearCacheForTest };
|
|
81569
|
+
|
|
80992
81570
|
/**
|
|
80993
81571
|
* rememberGrant.js — turn an "Always allow" bot approval into a durable grant,
|
|
80994
81572
|
* and revoke it.
|
|
@@ -81301,6 +81879,11 @@ const { isLead, leadOf, planEnsureLead } = teamLeads;
|
|
|
81301
81879
|
const { recentRuns } = recentRuns_1;
|
|
81302
81880
|
const { coalesce } = coalesce_1;
|
|
81303
81881
|
const { buildDraft, DraftStore } = botDrafts;
|
|
81882
|
+
const { findProviders } = providerDiscovery;
|
|
81883
|
+
const { searchRegistry } = registrySearch;
|
|
81884
|
+
|
|
81885
|
+
// How long a lead's find_providers results stay valid for its drafts.
|
|
81886
|
+
const FOUND_PROVIDERS_TTL_MS = 30 * 60 * 1000;
|
|
81304
81887
|
const { onWorkspaceDeleted } = workspaceEvents;
|
|
81305
81888
|
const {
|
|
81306
81889
|
checkChain,
|
|
@@ -81406,6 +81989,9 @@ const botController$1 = {
|
|
|
81406
81989
|
// Bots a team lead drafted, awaiting the user's review (TEAM-005). In
|
|
81407
81990
|
// memory only — a restart drops them (the lead's answer still says so).
|
|
81408
81991
|
this._drafts = new DraftStore();
|
|
81992
|
+
// What each lead's find_providers returned (leadId → { at, entries }), so
|
|
81993
|
+
// drafts only keep suggestions that were really found (CAP-004).
|
|
81994
|
+
this._foundProviders = new Map();
|
|
81409
81995
|
|
|
81410
81996
|
// Event-bus bridge (P1: FR-009): per-bot cooldown so a chatty event can't
|
|
81411
81997
|
// flood the runner with event-triggered runs.
|
|
@@ -81788,11 +82374,46 @@ const botController$1 = {
|
|
|
81788
82374
|
team,
|
|
81789
82375
|
workspaceId,
|
|
81790
82376
|
leadId: botId,
|
|
82377
|
+
knownProviders: this._knownProvidersFor(botId),
|
|
81791
82378
|
});
|
|
81792
82379
|
if (res.draft) this._drafts.add(res.draft);
|
|
81793
82380
|
return res;
|
|
81794
82381
|
},
|
|
81795
82382
|
|
|
82383
|
+
/**
|
|
82384
|
+
* A lead's find_providers (bot-capabilities CAP-003): search the user's
|
|
82385
|
+
* providers, Dash's catalogs and the MCP Registry. What it returns is
|
|
82386
|
+
* remembered for this lead for a while, so a draft can only suggest
|
|
82387
|
+
* providers that were actually found (CAP-004). Read-only.
|
|
82388
|
+
*/
|
|
82389
|
+
async _findProviders({ workspaceId, botId }, capability) {
|
|
82390
|
+
const found = await findProviders(capability, {
|
|
82391
|
+
listInstalled: () => this.listToolSources(workspaceId),
|
|
82392
|
+
getCatalog: () =>
|
|
82393
|
+
(this._mcp.getCatalog && this._mcp.getCatalog(null).catalog) || [],
|
|
82394
|
+
getKnownExternal: () =>
|
|
82395
|
+
(this._mcp.getKnownExternalCatalog &&
|
|
82396
|
+
this._mcp.getKnownExternalCatalog().servers) ||
|
|
82397
|
+
[],
|
|
82398
|
+
searchRegistry: (query) => searchRegistry(query),
|
|
82399
|
+
});
|
|
82400
|
+
const now = Date.now();
|
|
82401
|
+
const prev = this._foundProviders.get(botId);
|
|
82402
|
+
const entries =
|
|
82403
|
+
prev && now - prev.at < FOUND_PROVIDERS_TTL_MS ? prev.entries : {};
|
|
82404
|
+
for (const entry of found.results) entries[entry.id] = entry;
|
|
82405
|
+
this._foundProviders.set(botId, { at: now, entries });
|
|
82406
|
+
return found;
|
|
82407
|
+
},
|
|
82408
|
+
|
|
82409
|
+
/** find_providers results this lead got recently (id → entry). */
|
|
82410
|
+
_knownProvidersFor(botId) {
|
|
82411
|
+
const rec = this._foundProviders && this._foundProviders.get(botId);
|
|
82412
|
+
return rec && Date.now() - rec.at < FOUND_PROVIDERS_TTL_MS
|
|
82413
|
+
? rec.entries
|
|
82414
|
+
: {};
|
|
82415
|
+
},
|
|
82416
|
+
|
|
81796
82417
|
/** Drafts awaiting review on a dashboard, oldest first. */
|
|
81797
82418
|
listDrafts(workspaceId) {
|
|
81798
82419
|
return this._drafts ? this._drafts.list(workspaceId) : [];
|
|
@@ -82555,6 +83176,8 @@ const botController$1 = {
|
|
|
82555
83176
|
isPaused: (id) => this._pause.isPaused(id),
|
|
82556
83177
|
proposeBot: (teamCtx, proposal) =>
|
|
82557
83178
|
this._proposeBot(teamCtx, proposal),
|
|
83179
|
+
findProviders: (teamCtx, capability) =>
|
|
83180
|
+
this._findProviders(teamCtx, capability),
|
|
82558
83181
|
listProviders: () => this.listToolSources(caller.workspaceId),
|
|
82559
83182
|
listDrafts: (ws) => this.listDrafts(ws),
|
|
82560
83183
|
},
|