@orkestrel/mcp 0.0.36 → 0.0.37

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.
@@ -4115,6 +4115,26 @@ function isInitializeRequest(value) {
4115
4115
  return owned.success && isJSONRPCInvocation(owned.value) && owned.value["method"] === "initialize";
4116
4116
  }
4117
4117
  /**
4118
+ * Determines whether a parsed value is a legacy MCP `ping` request.
4119
+ *
4120
+ * @remarks
4121
+ * Requires a valid request id and excludes the modern per-request wire shape.
4122
+ * Notifications and hostile or malformed values return false.
4123
+ *
4124
+ * @param value - The already-parsed value to test
4125
+ * @returns True if `value` is a legacy `ping` request; false otherwise
4126
+ *
4127
+ * @example
4128
+ * ```ts
4129
+ * isPingRequest({ jsonrpc: '2.0', method: 'ping', id: 1 }) // true
4130
+ * isPingRequest({ jsonrpc: '2.0', method: 'ping' }) // false
4131
+ * ```
4132
+ */
4133
+ function isPingRequest(value) {
4134
+ const owned = (0, _orkestrel_contract.attempt)(() => (0, _orkestrel_contract.cloneJSONRecord)(value));
4135
+ return owned.success && isJSONRPCRequest(owned.value) && owned.value.method === "ping" && !isModernRequest(owned.value);
4136
+ }
4137
+ /**
4118
4138
  * Determines whether a JSON-RPC invocation uses the modern per-request MCP wire shape.
4119
4139
  *
4120
4140
  * @remarks
@@ -5549,7 +5569,7 @@ var MCPServer = class {
5549
5569
  if (!isBoundedString(verified, this.#limits.state) || verified.length === 0) return this.#contain(/* @__PURE__ */ new Error("Continuation port opened a value outside the configured state bound"), id);
5550
5570
  const state = parseMCPInputState(verified);
5551
5571
  if (state === void 0) return this.#contain(/* @__PURE__ */ new Error("Continuation port opened a malformed protected payload"), id);
5552
- if (state.expiry <= Date.now() || state.id === id || state.version !== context.version || state.method !== request.method || state.name !== name || state.digest !== digest) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
5572
+ if (state.expiry <= (configured.clock ?? Date.now)() || state.id === id || state.version !== context.version || state.method !== request.method || state.name !== name || state.digest !== digest) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
5553
5573
  const responses = this.#checkAnswers(state.requests, inputResponses);
5554
5574
  if (responses === void 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: an input response is missing or malformed");
5555
5575
  const principal = await configured.principal(request, options);
@@ -5561,7 +5581,7 @@ var MCPServer = class {
5561
5581
  responses,
5562
5582
  ...state.state !== void 0 ? { state: state.state } : {}
5563
5583
  }, options);
5564
- if (state.expiry <= Date.now()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
5584
+ if (state.expiry <= (configured.clock ?? Date.now)()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
5565
5585
  if (selected === void 0) return void 0;
5566
5586
  const round = this.#ownRound(selected);
5567
5587
  if (round === void 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: input policy returned an invalid round or continuation context");
@@ -5602,8 +5622,8 @@ var MCPServer = class {
5602
5622
  depth: this.#limits.depth
5603
5623
  });
5604
5624
  if (configured === void 0 || context === void 0 || !(0, _orkestrel_contract.isString)(principal) || principal.length === 0 || !(0, _orkestrel_contract.isFiniteNumber)(configured.ttl) || configured.ttl <= 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: input policy returned an invalid round or continuation context");
5605
- if (previous !== void 0 && previous <= Date.now()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
5606
- const expiry = Date.now() + configured.ttl;
5625
+ if (previous !== void 0 && previous <= (configured.clock ?? Date.now)()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
5626
+ const expiry = (configured.clock ?? Date.now)() + configured.ttl;
5607
5627
  const protectedState = {
5608
5628
  principal,
5609
5629
  expiry,
@@ -5626,7 +5646,7 @@ var MCPServer = class {
5626
5646
  if (serialized === void 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state exceeds the configured limit");
5627
5647
  const requestState = await configured.continuation.seal(serialized);
5628
5648
  if (!isBoundedString(requestState, this.#limits.state) || requestState.length === 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state exceeds the configured limit");
5629
- if (expiry <= Date.now() || previous !== void 0 && previous <= Date.now()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, previous === void 0 ? "Invalid params: request state expired before it could be issued" : "Invalid params: request state could not be verified for this retry");
5649
+ if (expiry <= (configured.clock ?? Date.now)() || previous !== void 0 && previous <= (configured.clock ?? Date.now)()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, previous === void 0 ? "Invalid params: request state expired before it could be issued" : "Invalid params: request state could not be verified for this retry");
5630
5650
  return buildJSONRPCResult(id, {
5631
5651
  resultType: "input_required",
5632
5652
  inputRequests: round.requests,
@@ -7051,6 +7071,7 @@ exports.isMCPTextResource = isMCPTextResource;
7051
7071
  exports.isMCPToolAnnotations = isMCPToolAnnotations;
7052
7072
  exports.isMCPVersion = isMCPVersion;
7053
7073
  exports.isModernRequest = isModernRequest;
7074
+ exports.isPingRequest = isPingRequest;
7054
7075
  exports.isRFC3339Date = isRFC3339Date;
7055
7076
  exports.isRFC3339DateTime = isRFC3339DateTime;
7056
7077
  exports.isStandardBase64 = isStandardBase64;