@rulvar/core 1.189.0 → 1.190.0
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/index.d.ts +18 -1
- package/dist/index.js +17 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11238,14 +11238,31 @@ interface McpConfig {
|
|
|
11238
11238
|
* request timeout per tools/list page and per tools/call; without
|
|
11239
11239
|
* them the SDK's own 60s default request timeout applies. A call
|
|
11240
11240
|
* timeout surfaces as the tool's error result, never past policy.
|
|
11241
|
-
*
|
|
11241
|
+
* discoveryMs (RV1808) is the WALL-CLOCK cap over one whole
|
|
11242
|
+
* tools/list sweep, all pages included: per-page listMs cannot bound
|
|
11243
|
+
* a server that answers every page promptly and paginates forever
|
|
11244
|
+
* with unique cursors under maxPages' radar only when maxPages is
|
|
11245
|
+
* set, and cannot bound a slow-but-under-listMs page crawl at all.
|
|
11246
|
+
* On expiry the sweep refuses typed. Each a positive finite number
|
|
11247
|
+
* of milliseconds.
|
|
11242
11248
|
*/
|
|
11243
11249
|
timeouts?: {
|
|
11244
11250
|
connectMs?: number;
|
|
11245
11251
|
listMs?: number;
|
|
11246
11252
|
callMs?: number;
|
|
11253
|
+
discoveryMs?: number;
|
|
11247
11254
|
};
|
|
11248
11255
|
/**
|
|
11256
|
+
* Demand the discovery bounds (RV1808): with `requireBounds: true`
|
|
11257
|
+
* the source refuses at construction unless maxTools, maxPages,
|
|
11258
|
+
* maxSchemaBytes, and timeouts.discoveryMs are ALL declared. The
|
|
11259
|
+
* production posture: an unbounded discovery sweep against a remote
|
|
11260
|
+
* registry is an availability decision someone should have made on
|
|
11261
|
+
* purpose, so the flag turns the four absences into one typed error
|
|
11262
|
+
* naming what is missing instead of four silent unboundeds.
|
|
11263
|
+
*/
|
|
11264
|
+
requireBounds?: boolean;
|
|
11265
|
+
/**
|
|
11249
11266
|
* streamable-http only (RV1516): headers injected into EVERY wire
|
|
11250
11267
|
* request through a wrapped fetch. The hook form is awaited before
|
|
11251
11268
|
* each send, so it IS the refresh point: rotate a token in the hook
|
package/dist/index.js
CHANGED
|
@@ -4055,11 +4055,21 @@ function validateBounds(cfg) {
|
|
|
4055
4055
|
for (const key of [
|
|
4056
4056
|
"connectMs",
|
|
4057
4057
|
"listMs",
|
|
4058
|
-
"callMs"
|
|
4058
|
+
"callMs",
|
|
4059
|
+
"discoveryMs"
|
|
4059
4060
|
]) {
|
|
4060
4061
|
const value = cfg.timeouts?.[key];
|
|
4061
4062
|
if (value !== void 0 && (!Number.isFinite(value) || value <= 0)) throw new ConfigError(`mcp: 'timeouts.${key}' must be a positive finite number of milliseconds, got ${String(value)}`);
|
|
4062
4063
|
}
|
|
4064
|
+
if (cfg.requireBounds === true) {
|
|
4065
|
+
const missing = [
|
|
4066
|
+
...cfg.maxTools === void 0 ? ["maxTools"] : [],
|
|
4067
|
+
...cfg.maxPages === void 0 ? ["maxPages"] : [],
|
|
4068
|
+
...cfg.maxSchemaBytes === void 0 ? ["maxSchemaBytes"] : [],
|
|
4069
|
+
...cfg.timeouts?.discoveryMs === void 0 ? ["timeouts.discoveryMs"] : []
|
|
4070
|
+
];
|
|
4071
|
+
if (missing.length > 0) throw new ConfigError(`mcp: requireBounds demands every discovery bound; missing ${missing.join(", ")}`);
|
|
4072
|
+
}
|
|
4063
4073
|
if (cfg.drift !== void 0 && cfg.drift !== "rekey" && cfg.drift !== "refuse") throw new ConfigError(`mcp: 'drift' must be 'rekey' or 'refuse', got '${String(cfg.drift)}'`);
|
|
4064
4074
|
const headers = cfg.http?.headers;
|
|
4065
4075
|
if (headers !== void 0 && typeof headers !== "function" && typeof headers !== "object") throw new ConfigError("mcp: 'http.headers' must be a record of header values or a (possibly async) function returning one");
|
|
@@ -4201,13 +4211,19 @@ function mcp(cfg) {
|
|
|
4201
4211
|
const tools = [];
|
|
4202
4212
|
let cursor;
|
|
4203
4213
|
let pages = 0;
|
|
4214
|
+
const visited = /* @__PURE__ */ new Set();
|
|
4215
|
+
const startedAt = Date.now();
|
|
4216
|
+
const discoveryMs = cfg.timeouts?.discoveryMs;
|
|
4204
4217
|
const listOptions = cfg.timeouts?.listMs === void 0 ? void 0 : { timeout: cfg.timeouts.listMs };
|
|
4205
4218
|
do {
|
|
4219
|
+
if (discoveryMs !== void 0 && Date.now() - startedAt > discoveryMs) throw new ConfigError(`mcp: tools/list of '${sourceIdOf(cfg)}' exceeded the discovery deadline (timeouts.discoveryMs ${discoveryMs}) after ${pages} page(s)`);
|
|
4220
|
+
if (cursor !== void 0) visited.add(cursor);
|
|
4206
4221
|
const page = await client.listTools(cursor === void 0 ? {} : { cursor }, listOptions);
|
|
4207
4222
|
pages += 1;
|
|
4208
4223
|
tools.push(...page.tools);
|
|
4209
4224
|
if (cfg.maxTools !== void 0 && tools.length > cfg.maxTools) throw new ConfigError(`mcp: tools/list of '${sourceIdOf(cfg)}' returned at least ${tools.length} wire tools, over the declared maxTools ${cfg.maxTools}; raise the cap or trim the server`);
|
|
4210
4225
|
if (page.nextCursor !== void 0 && page.nextCursor !== "" && page.nextCursor === cursor) throw new ConfigError(`mcp: tools/list of '${sourceIdOf(cfg)}' returned the cursor it was queried with ('${page.nextCursor}') on page ${pages}: the pagination makes no progress`);
|
|
4226
|
+
if (page.nextCursor !== void 0 && page.nextCursor !== "" && visited.has(page.nextCursor)) throw new ConfigError(`mcp: tools/list of '${sourceIdOf(cfg)}' returned a cursor this sweep already visited ('${page.nextCursor}') on page ${pages}: the pagination cycles`);
|
|
4211
4227
|
cursor = page.nextCursor;
|
|
4212
4228
|
if (cfg.maxPages !== void 0 && pages >= cfg.maxPages && cursor !== void 0 && cursor !== "") throw new ConfigError(`mcp: tools/list of '${sourceIdOf(cfg)}' still reports another page after ${pages} page(s), over the declared maxPages ${cfg.maxPages}; raise the cap or trim the server`);
|
|
4213
4229
|
} while (cursor !== void 0 && cursor !== "");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulvar/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.190.0",
|
|
4
4
|
"description": "Rulvar core: L0 contracts, journal kernel, ctx primitives, agent runtime, model router, tool system, dynamic orchestrator, InMemory and JSONL stores, event stream.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|