@trops/dash-core 0.1.711 → 0.1.713
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 +80 -19
- package/dist/electron/index.js.map +1 -1
- package/package.json +1 -1
package/dist/electron/index.js
CHANGED
|
@@ -2481,6 +2481,12 @@ function requestApproval$3(req, opts = {}) {
|
|
|
2481
2481
|
siblingWidgetIds: Array.isArray(req.siblingWidgetIds)
|
|
2482
2482
|
? req.siblingWidgetIds
|
|
2483
2483
|
: [req.widgetId],
|
|
2484
|
+
// A wildcard the widget declares that covers this tool
|
|
2485
|
+
// ("algolia_search_*"). The modal offers it as a broader grant.
|
|
2486
|
+
toolPattern:
|
|
2487
|
+
typeof req.toolPattern === "string" && req.toolPattern
|
|
2488
|
+
? req.toolPattern
|
|
2489
|
+
: null,
|
|
2484
2490
|
});
|
|
2485
2491
|
});
|
|
2486
2492
|
}
|
|
@@ -11110,7 +11116,7 @@ function requireDedupeWidgetFolders () {
|
|
|
11110
11116
|
|
|
11111
11117
|
const MIN_LITERAL_CHARS = 3;
|
|
11112
11118
|
|
|
11113
|
-
function isToolPattern(name) {
|
|
11119
|
+
function isToolPattern$1(name) {
|
|
11114
11120
|
return typeof name === "string" && name.includes("*");
|
|
11115
11121
|
}
|
|
11116
11122
|
|
|
@@ -11137,21 +11143,21 @@ function _patternRegex(pattern) {
|
|
|
11137
11143
|
}
|
|
11138
11144
|
|
|
11139
11145
|
/** True when `entry` (a tool name or pattern) covers `toolName`. */
|
|
11140
|
-
function toolMatches(entry, toolName) {
|
|
11146
|
+
function toolMatches$1(entry, toolName) {
|
|
11141
11147
|
if (typeof entry !== "string" || typeof toolName !== "string") return false;
|
|
11142
11148
|
if (entry === toolName) return true;
|
|
11143
|
-
return isToolPattern(entry) && _patternRegex(entry).test(toolName);
|
|
11149
|
+
return isToolPattern$1(entry) && _patternRegex(entry).test(toolName);
|
|
11144
11150
|
}
|
|
11145
11151
|
|
|
11146
11152
|
/** True when any entry in `tools` covers `toolName`. */
|
|
11147
11153
|
function toolListAllows$1(tools, toolName) {
|
|
11148
|
-
return Array.isArray(tools) && tools.some((t) => toolMatches(t, toolName));
|
|
11154
|
+
return Array.isArray(tools) && tools.some((t) => toolMatches$1(t, toolName));
|
|
11149
11155
|
}
|
|
11150
11156
|
|
|
11151
11157
|
var toolPattern = {
|
|
11152
|
-
isToolPattern,
|
|
11158
|
+
isToolPattern: isToolPattern$1,
|
|
11153
11159
|
toolPatternFromTemplate,
|
|
11154
|
-
toolMatches,
|
|
11160
|
+
toolMatches: toolMatches$1,
|
|
11155
11161
|
toolListAllows: toolListAllows$1,
|
|
11156
11162
|
};
|
|
11157
11163
|
|
|
@@ -11198,7 +11204,11 @@ function requireScanWidgetPackagePermissions () {
|
|
|
11198
11204
|
|
|
11199
11205
|
const fs = require$$0$3;
|
|
11200
11206
|
const path = require$$1$2;
|
|
11201
|
-
const {
|
|
11207
|
+
const {
|
|
11208
|
+
toolPatternFromTemplate,
|
|
11209
|
+
isToolPattern,
|
|
11210
|
+
toolListAllows,
|
|
11211
|
+
} = toolPattern;
|
|
11202
11212
|
|
|
11203
11213
|
const SOURCE_EXTS = new Set([".js", ".jsx", ".ts", ".tsx"]);
|
|
11204
11214
|
const SKIP_DIRS = new Set([
|
|
@@ -11231,18 +11241,20 @@ function requireScanWidgetPackagePermissions () {
|
|
|
11231
11241
|
if (typeof code !== "string" || !code) return { providers: [], tools: [] };
|
|
11232
11242
|
const stripped = _stripLineComments(code);
|
|
11233
11243
|
const providerPattern = /useMcpProvider\s*\(\s*["'`]([^"'`]+)["'`]/g;
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11244
|
+
// Group 2 is the literal; group 3 is set when the literal is followed by
|
|
11245
|
+
// `.concat(` — the compiled form of a template (`"a_".concat(x)`).
|
|
11246
|
+
const callPattern = /callTool\s*\(\s*(["'`])([^"'`]+)\1(\s*\.concat\s*\()?/g;
|
|
11247
|
+
const tools = [];
|
|
11248
|
+
for (const m of stripped.matchAll(callPattern)) {
|
|
11237
11249
|
// Template names (`algolia_search_${index}`) become wildcard patterns
|
|
11238
11250
|
// (`algolia_search_*`); ones too vague to pattern are dropped.
|
|
11239
|
-
|
|
11240
|
-
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11244
|
-
|
|
11245
|
-
),
|
|
11251
|
+
const raw = m[3] ? m[2] + "${}" : m[2];
|
|
11252
|
+
const tool = toolPatternFromTemplate(raw);
|
|
11253
|
+
if (tool) tools.push(tool);
|
|
11254
|
+
}
|
|
11255
|
+
return {
|
|
11256
|
+
providers: Array.from(new Set(_captureAll(stripped, providerPattern))),
|
|
11257
|
+
tools: Array.from(new Set(tools)),
|
|
11246
11258
|
};
|
|
11247
11259
|
}
|
|
11248
11260
|
|
|
@@ -11459,7 +11471,12 @@ function requireScanWidgetPackagePermissions () {
|
|
|
11459
11471
|
} else {
|
|
11460
11472
|
const existing = new Set(out[name].tools || []);
|
|
11461
11473
|
for (const t of perms.tools || []) existing.add(t);
|
|
11462
|
-
|
|
11474
|
+
// Drop plain names a scanned wildcard already covers, e.g. the
|
|
11475
|
+
// "algolia_search_" older scans read from compiled bundles.
|
|
11476
|
+
const wildcards = (perms.tools || []).filter(isToolPattern);
|
|
11477
|
+
out[name].tools = Array.from(existing)
|
|
11478
|
+
.filter((t) => isToolPattern(t) || !toolListAllows(wildcards, t))
|
|
11479
|
+
.sort();
|
|
11463
11480
|
}
|
|
11464
11481
|
}
|
|
11465
11482
|
}
|
|
@@ -36825,7 +36842,7 @@ const { requestApproval } = jitConsent$1;
|
|
|
36825
36842
|
const { lookup: lookupMountToken } = mountTokenRegistry;
|
|
36826
36843
|
const { resolveSiblings } = resolveSiblings_1;
|
|
36827
36844
|
const { getWidgetMcpPermissions: getWidgetMcpPermissions$1 } = widgetPermissions;
|
|
36828
|
-
const { toolListAllows } = toolPattern;
|
|
36845
|
+
const { toolListAllows, isToolPattern, toolMatches } = toolPattern;
|
|
36829
36846
|
|
|
36830
36847
|
// Lazy default for the registry snapshot — `widgetRegistry.js` pulls
|
|
36831
36848
|
// in a lot, so we don't want to require it at module-load time. The
|
|
@@ -37045,6 +37062,42 @@ function gateBotToolCall({ botId, serverName, toolName, args }) {
|
|
|
37045
37062
|
});
|
|
37046
37063
|
}
|
|
37047
37064
|
|
|
37065
|
+
/**
|
|
37066
|
+
* The wildcard ("algolia_search_*") this widget declares that covers
|
|
37067
|
+
* `toolName`, or null. Declarations are keyed by provider type
|
|
37068
|
+
* ("algolia") while calls carry the provider instance name
|
|
37069
|
+
* ("Algolia Public HR"), so every declared server is checked, the
|
|
37070
|
+
* matching name first.
|
|
37071
|
+
*/
|
|
37072
|
+
function _declaredToolPattern(widgetId, serverName, toolName) {
|
|
37073
|
+
const servers = getWidgetMcpPermissions$1(widgetId)?.servers || {};
|
|
37074
|
+
const names = Object.keys(servers).sort((a, b) =>
|
|
37075
|
+
a === serverName ? -1 : b === serverName ? 1 : 0,
|
|
37076
|
+
);
|
|
37077
|
+
for (const name of names) {
|
|
37078
|
+
const hit = (servers[name]?.tools || []).find(
|
|
37079
|
+
(t) => isToolPattern(t) && toolMatches(t, toolName),
|
|
37080
|
+
);
|
|
37081
|
+
if (hit) return hit;
|
|
37082
|
+
}
|
|
37083
|
+
return null;
|
|
37084
|
+
}
|
|
37085
|
+
|
|
37086
|
+
/**
|
|
37087
|
+
* Keep only wildcard tools the gate offered for this request. The
|
|
37088
|
+
* renderer builds the grant, so a pattern it sends must be exactly the
|
|
37089
|
+
* declared one — anything broader is dropped.
|
|
37090
|
+
*/
|
|
37091
|
+
function _limitGrantPatterns(granted, allowedPattern) {
|
|
37092
|
+
for (const perms of Object.values(granted?.servers || {})) {
|
|
37093
|
+
if (!Array.isArray(perms?.tools)) continue;
|
|
37094
|
+
perms.tools = perms.tools.filter(
|
|
37095
|
+
(t) => !isToolPattern(t) || t === allowedPattern,
|
|
37096
|
+
);
|
|
37097
|
+
}
|
|
37098
|
+
return granted;
|
|
37099
|
+
}
|
|
37100
|
+
|
|
37048
37101
|
/**
|
|
37049
37102
|
* Filter a sibling-widget list down to widgets whose static manifest
|
|
37050
37103
|
* declares the given `serverName + toolName`. The originating widget
|
|
@@ -37214,6 +37267,12 @@ async function gateToolCallWithJit$1(req, opts = {}) {
|
|
|
37214
37267
|
req.toolName,
|
|
37215
37268
|
);
|
|
37216
37269
|
|
|
37270
|
+
const toolPattern = _declaredToolPattern(
|
|
37271
|
+
verifiedWidgetId,
|
|
37272
|
+
req.serverName,
|
|
37273
|
+
req.toolName,
|
|
37274
|
+
);
|
|
37275
|
+
|
|
37217
37276
|
let decision;
|
|
37218
37277
|
try {
|
|
37219
37278
|
decision = await requestApproval(
|
|
@@ -37228,6 +37287,7 @@ async function gateToolCallWithJit$1(req, opts = {}) {
|
|
|
37228
37287
|
},
|
|
37229
37288
|
packageId: siblingInfo.packageId,
|
|
37230
37289
|
siblingWidgetIds: applicableSiblingIds,
|
|
37290
|
+
toolPattern,
|
|
37231
37291
|
},
|
|
37232
37292
|
{ timeoutMs: opts.timeoutMs },
|
|
37233
37293
|
);
|
|
@@ -37271,6 +37331,7 @@ async function gateToolCallWithJit$1(req, opts = {}) {
|
|
|
37271
37331
|
};
|
|
37272
37332
|
// Force grantOrigin: "live" regardless of what the renderer sent.
|
|
37273
37333
|
addition.grantOrigin = "live";
|
|
37334
|
+
_limitGrantPatterns(addition, toolPattern);
|
|
37274
37335
|
|
|
37275
37336
|
// Slice 5: when the user opted into "Apply to all widgets from
|
|
37276
37337
|
// <package>", write the same merged grant for every sibling — each
|