@orkestrel/mcp 0.0.36 → 0.0.38

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.
@@ -2208,6 +2208,24 @@ export declare function isMCPVersion(value: unknown): value is MCPVersion;
2208
2208
  */
2209
2209
  export declare function isModernRequest(value: unknown): value is JSONRPCInvocation;
2210
2210
 
2211
+ /**
2212
+ * Determines whether a parsed value is a legacy MCP `ping` request.
2213
+ *
2214
+ * @remarks
2215
+ * Requires a valid request id and excludes the modern per-request wire shape.
2216
+ * Notifications and hostile or malformed values return false.
2217
+ *
2218
+ * @param value - The already-parsed value to test
2219
+ * @returns True if `value` is a legacy `ping` request; false otherwise
2220
+ *
2221
+ * @example
2222
+ * ```ts
2223
+ * isPingRequest({ jsonrpc: '2.0', method: 'ping', id: 1 }) // true
2224
+ * isPingRequest({ jsonrpc: '2.0', method: 'ping' }) // false
2225
+ * ```
2226
+ */
2227
+ export declare function isPingRequest(value: unknown): value is JSONRPCRequest;
2228
+
2211
2229
  /**
2212
2230
  * Determines whether a value is one RFC 3339 `full-date` naming a real calendar day.
2213
2231
  *
@@ -3555,10 +3573,18 @@ export declare interface MCPInputContext {
3555
3573
  */
3556
3574
  export declare type MCPInputHandler = (context: MCPInputContext, options: MCPMethodOptions) => MCPInputRound | undefined | Promise<MCPInputRound | undefined>;
3557
3575
 
3558
- /** Configures the consumer policy for the server's multi-round-trip input mechanism. */
3576
+ /**
3577
+ * Configures the consumer policy for the server's multi-round-trip input mechanism.
3578
+ * The injected clock is trusted and must return finite epoch milliseconds.
3579
+ */
3559
3580
  export declare interface MCPInputOptions {
3560
3581
  /** Holds the host-neutral integrity/storage port for the opaque continuation carrier. */
3561
3582
  readonly continuation: MCPContinuationInterface;
3583
+ /**
3584
+ * Supplies epoch milliseconds for continuation expiry checks.
3585
+ * The injected clock is trusted and must return finite epoch milliseconds. Default: `Date.now`.
3586
+ */
3587
+ readonly clock?: () => number;
3562
3588
  /**
3563
3589
  * Sets the continuation lifetime in milliseconds; required so MCP never invents an expiry policy.
3564
3590
  */
@@ -2208,6 +2208,24 @@ export declare function isMCPVersion(value: unknown): value is MCPVersion;
2208
2208
  */
2209
2209
  export declare function isModernRequest(value: unknown): value is JSONRPCInvocation;
2210
2210
 
2211
+ /**
2212
+ * Determines whether a parsed value is a legacy MCP `ping` request.
2213
+ *
2214
+ * @remarks
2215
+ * Requires a valid request id and excludes the modern per-request wire shape.
2216
+ * Notifications and hostile or malformed values return false.
2217
+ *
2218
+ * @param value - The already-parsed value to test
2219
+ * @returns True if `value` is a legacy `ping` request; false otherwise
2220
+ *
2221
+ * @example
2222
+ * ```ts
2223
+ * isPingRequest({ jsonrpc: '2.0', method: 'ping', id: 1 }) // true
2224
+ * isPingRequest({ jsonrpc: '2.0', method: 'ping' }) // false
2225
+ * ```
2226
+ */
2227
+ export declare function isPingRequest(value: unknown): value is JSONRPCRequest;
2228
+
2211
2229
  /**
2212
2230
  * Determines whether a value is one RFC 3339 `full-date` naming a real calendar day.
2213
2231
  *
@@ -3555,10 +3573,18 @@ export declare interface MCPInputContext {
3555
3573
  */
3556
3574
  export declare type MCPInputHandler = (context: MCPInputContext, options: MCPMethodOptions) => MCPInputRound | undefined | Promise<MCPInputRound | undefined>;
3557
3575
 
3558
- /** Configures the consumer policy for the server's multi-round-trip input mechanism. */
3576
+ /**
3577
+ * Configures the consumer policy for the server's multi-round-trip input mechanism.
3578
+ * The injected clock is trusted and must return finite epoch milliseconds.
3579
+ */
3559
3580
  export declare interface MCPInputOptions {
3560
3581
  /** Holds the host-neutral integrity/storage port for the opaque continuation carrier. */
3561
3582
  readonly continuation: MCPContinuationInterface;
3583
+ /**
3584
+ * Supplies epoch milliseconds for continuation expiry checks.
3585
+ * The injected clock is trusted and must return finite epoch milliseconds. Default: `Date.now`.
3586
+ */
3587
+ readonly clock?: () => number;
3562
3588
  /**
3563
3589
  * Sets the continuation lifetime in milliseconds; required so MCP never invents an expiry policy.
3564
3590
  */
@@ -4114,6 +4114,26 @@ function isInitializeRequest(value) {
4114
4114
  return owned.success && isJSONRPCInvocation(owned.value) && owned.value["method"] === "initialize";
4115
4115
  }
4116
4116
  /**
4117
+ * Determines whether a parsed value is a legacy MCP `ping` request.
4118
+ *
4119
+ * @remarks
4120
+ * Requires a valid request id and excludes the modern per-request wire shape.
4121
+ * Notifications and hostile or malformed values return false.
4122
+ *
4123
+ * @param value - The already-parsed value to test
4124
+ * @returns True if `value` is a legacy `ping` request; false otherwise
4125
+ *
4126
+ * @example
4127
+ * ```ts
4128
+ * isPingRequest({ jsonrpc: '2.0', method: 'ping', id: 1 }) // true
4129
+ * isPingRequest({ jsonrpc: '2.0', method: 'ping' }) // false
4130
+ * ```
4131
+ */
4132
+ function isPingRequest(value) {
4133
+ const owned = attempt(() => cloneJSONRecord(value));
4134
+ return owned.success && isJSONRPCRequest(owned.value) && owned.value.method === "ping" && !isModernRequest(owned.value);
4135
+ }
4136
+ /**
4117
4137
  * Determines whether a JSON-RPC invocation uses the modern per-request MCP wire shape.
4118
4138
  *
4119
4139
  * @remarks
@@ -5548,7 +5568,7 @@ var MCPServer = class {
5548
5568
  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);
5549
5569
  const state = parseMCPInputState(verified);
5550
5570
  if (state === void 0) return this.#contain(/* @__PURE__ */ new Error("Continuation port opened a malformed protected payload"), id);
5551
- 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");
5571
+ 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");
5552
5572
  const responses = this.#checkAnswers(state.requests, inputResponses);
5553
5573
  if (responses === void 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: an input response is missing or malformed");
5554
5574
  const principal = await configured.principal(request, options);
@@ -5560,7 +5580,7 @@ var MCPServer = class {
5560
5580
  responses,
5561
5581
  ...state.state !== void 0 ? { state: state.state } : {}
5562
5582
  }, options);
5563
- if (state.expiry <= Date.now()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
5583
+ if (state.expiry <= (configured.clock ?? Date.now)()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
5564
5584
  if (selected === void 0) return void 0;
5565
5585
  const round = this.#ownRound(selected);
5566
5586
  if (round === void 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: input policy returned an invalid round or continuation context");
@@ -5601,8 +5621,8 @@ var MCPServer = class {
5601
5621
  depth: this.#limits.depth
5602
5622
  });
5603
5623
  if (configured === void 0 || context === void 0 || !isString(principal) || principal.length === 0 || !isFiniteNumber(configured.ttl) || configured.ttl <= 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: input policy returned an invalid round or continuation context");
5604
- if (previous !== void 0 && previous <= Date.now()) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state could not be verified for this retry");
5605
- const expiry = Date.now() + configured.ttl;
5624
+ 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");
5625
+ const expiry = (configured.clock ?? Date.now)() + configured.ttl;
5606
5626
  const protectedState = {
5607
5627
  principal,
5608
5628
  expiry,
@@ -5625,7 +5645,7 @@ var MCPServer = class {
5625
5645
  if (serialized === void 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state exceeds the configured limit");
5626
5646
  const requestState = await configured.continuation.seal(serialized);
5627
5647
  if (!isBoundedString(requestState, this.#limits.state) || requestState.length === 0) return buildJSONRPCError(id, JSONRPC_INVALID_PARAMS, "Invalid params: request state exceeds the configured limit");
5628
- 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");
5648
+ 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");
5629
5649
  return buildJSONRPCResult(id, {
5630
5650
  resultType: "input_required",
5631
5651
  inputRequests: round.requests,
@@ -6884,6 +6904,6 @@ function createDuplexClientTransport(transport) {
6884
6904
  };
6885
6905
  }
6886
6906
  //#endregion
6887
- export { DEFAULT_MCP_CACHE_TTL, DEFAULT_MCP_CLIENT_NAME, DEFAULT_MCP_CLIENT_VERSION, DEFAULT_MCP_LIMITS, DEFAULT_MCP_REQUEST_TIMEOUT, DEFAULT_MCP_SUBSCRIPTION_CAPACITY, EMPTY_MCP_ARGUMENTS, HTTPClientTransport, JSONRPC_INTERNAL_ERROR, JSONRPC_INVALID_PARAMS, JSONRPC_INVALID_REQUEST, JSONRPC_METHOD_NOT_FOUND, JSONRPC_PARSE_ERROR, JSONRPC_SERVER_ERROR, MCPClient, MCPError, MCPLegacy, MCPLegacyClientTransport, MCPMethodManager, MCPProgressReporter, MCPServer, MCPStreamController, MCPTaskClient, MCPTextStreamController, MCP_EXTENSION_TASKS, MCP_FALLBACK_VERSION, MCP_HANDSHAKE_VERSION, MCP_HEADER_ANNOTATION, MCP_HEADER_MISMATCH, MCP_LOOKUP_PAGES, MCP_META_CAPABILITIES, MCP_META_CLIENT, MCP_META_SERVER, MCP_META_SUBSCRIPTION, MCP_META_VERSION, MCP_METHOD_HEADER, MCP_MISSING_CAPABILITY, MCP_MODERN_VERSION, MCP_NAME_HEADER, MCP_PARAM_PREFIX, MCP_PROTOCOL_VERSION_HEADER, MCP_SENTINEL_PREFIX, MCP_SENTINEL_SUFFIX, MCP_SESSION_HEADER, MCP_UNSUPPORTED_VERSION, MCP_WEBSOCKET_SUBPROTOCOL, SUPPORTED_LEGACY_PROTOCOL_VERSIONS, SUPPORTED_MCP_VERSIONS, SUPPORTED_MODERN_PROTOCOL_VERSIONS, bindClient, bindServer, buildCallOutcome, buildCancelledNotification, buildDiscoverResult, buildHeaderParameters, buildHeaderProjection, buildInitializeResult, buildJSONRPCError, buildJSONRPCResult, buildMethodOptions, buildModernResult, buildProgressNotification, buildResponseError, buildSubscriptionAcknowledgement, buildSubscriptionFilter, buildSubscriptionResult, buildToolCall, buildToolDescriptors, computeMissingCapabilities, countHeaderAnnotations, createDuplexClientTransport, createMCPClient, createMCPLegacy, createMCPLegacyClientTransport, createMCPServer, decodeBoundedMessage, decodeEvent, decodeSentinel, deliverMessage, digestJSON, encodeSentinel, extractContentText, extractHeaderAnnotations, extractToolSchema, inferEra, inferRequestEra, inferRequestVersion, inferVersion, isAbsoluteURI, isBoundedJSON, isBoundedString, isElicitContent, isFieldToken, isInitializeRequest, isJSONObject, isJSONRPCError, isJSONRPCErrorResponse, isJSONRPCId, isJSONRPCInvocation, isJSONRPCMessage, isJSONRPCNotification, isJSONRPCRequest, isJSONRPCResponse, isJSONRPCResultResponse, isMCPAnnotations, isMCPBlobResource, isMCPCallResult, isMCPClientCapabilities, isMCPCompletion, isMCPCompletionParams, isMCPCompletionReference, isMCPCompletionResult, isMCPConsumerFilter, isMCPContent, isMCPElicitFieldSchema, isMCPElicitForm, isMCPElicitRequest, isMCPElicitResult, isMCPElicitSchema, isMCPElicitURL, isMCPError, isMCPHeaderPrimitive, isMCPIcon, isMCPIdentity, isMCPInputRequest, isMCPInputRequestMap, isMCPInputResponse, isMCPInputResult, isMCPLegacyResult, isMCPLegacyVersion, isMCPLoggingLevel, isMCPMetaKey, isMCPMetaObject, isMCPModernVersion, isMCPNotificationMetaObject, isMCPPaginationParams, isMCPProgress, isMCPPrompt, isMCPPromptArgument, isMCPPromptGetResult, isMCPPromptMessage, isMCPPromptPage, isMCPResource, isMCPResourceContents, isMCPResourcePage, isMCPResourceTemplate, isMCPResourceTemplatePage, isMCPResult, isMCPResultMetaObject, isMCPRoot, isMCPRootResult, isMCPSampleContent, isMCPSampleResult, isMCPServerCapabilities, isMCPStringArguments, isMCPSubscriptionFilter, isMCPSubscriptionResult, isMCPTaskDetail, isMCPTaskDetailResult, isMCPTaskNotification, isMCPTaskResult, isMCPTaskStatus, isMCPTextResource, isMCPToolAnnotations, isMCPVersion, isModernRequest, isRFC3339Date, isRFC3339DateTime, isStandardBase64, legacyInvocationToModern, legacyResultToModern, matchesResultType, matchesSubscriptionNotification, mcpAnnotationsToTool, modernInvocationToLegacy, modernResultToLegacy, parseJSONRPCMessage, parseMCPInputState, parseRequestContext, readCancelledId, readEventStream, renderHeaderValue, sendStream, serializeJSON, snapshotJSON, snapshotToolResult, stampSubscriptionNotification, supportsFormElicitation, supportsTask, toolAnnotationsToMCP };
6907
+ export { DEFAULT_MCP_CACHE_TTL, DEFAULT_MCP_CLIENT_NAME, DEFAULT_MCP_CLIENT_VERSION, DEFAULT_MCP_LIMITS, DEFAULT_MCP_REQUEST_TIMEOUT, DEFAULT_MCP_SUBSCRIPTION_CAPACITY, EMPTY_MCP_ARGUMENTS, HTTPClientTransport, JSONRPC_INTERNAL_ERROR, JSONRPC_INVALID_PARAMS, JSONRPC_INVALID_REQUEST, JSONRPC_METHOD_NOT_FOUND, JSONRPC_PARSE_ERROR, JSONRPC_SERVER_ERROR, MCPClient, MCPError, MCPLegacy, MCPLegacyClientTransport, MCPMethodManager, MCPProgressReporter, MCPServer, MCPStreamController, MCPTaskClient, MCPTextStreamController, MCP_EXTENSION_TASKS, MCP_FALLBACK_VERSION, MCP_HANDSHAKE_VERSION, MCP_HEADER_ANNOTATION, MCP_HEADER_MISMATCH, MCP_LOOKUP_PAGES, MCP_META_CAPABILITIES, MCP_META_CLIENT, MCP_META_SERVER, MCP_META_SUBSCRIPTION, MCP_META_VERSION, MCP_METHOD_HEADER, MCP_MISSING_CAPABILITY, MCP_MODERN_VERSION, MCP_NAME_HEADER, MCP_PARAM_PREFIX, MCP_PROTOCOL_VERSION_HEADER, MCP_SENTINEL_PREFIX, MCP_SENTINEL_SUFFIX, MCP_SESSION_HEADER, MCP_UNSUPPORTED_VERSION, MCP_WEBSOCKET_SUBPROTOCOL, SUPPORTED_LEGACY_PROTOCOL_VERSIONS, SUPPORTED_MCP_VERSIONS, SUPPORTED_MODERN_PROTOCOL_VERSIONS, bindClient, bindServer, buildCallOutcome, buildCancelledNotification, buildDiscoverResult, buildHeaderParameters, buildHeaderProjection, buildInitializeResult, buildJSONRPCError, buildJSONRPCResult, buildMethodOptions, buildModernResult, buildProgressNotification, buildResponseError, buildSubscriptionAcknowledgement, buildSubscriptionFilter, buildSubscriptionResult, buildToolCall, buildToolDescriptors, computeMissingCapabilities, countHeaderAnnotations, createDuplexClientTransport, createMCPClient, createMCPLegacy, createMCPLegacyClientTransport, createMCPServer, decodeBoundedMessage, decodeEvent, decodeSentinel, deliverMessage, digestJSON, encodeSentinel, extractContentText, extractHeaderAnnotations, extractToolSchema, inferEra, inferRequestEra, inferRequestVersion, inferVersion, isAbsoluteURI, isBoundedJSON, isBoundedString, isElicitContent, isFieldToken, isInitializeRequest, isJSONObject, isJSONRPCError, isJSONRPCErrorResponse, isJSONRPCId, isJSONRPCInvocation, isJSONRPCMessage, isJSONRPCNotification, isJSONRPCRequest, isJSONRPCResponse, isJSONRPCResultResponse, isMCPAnnotations, isMCPBlobResource, isMCPCallResult, isMCPClientCapabilities, isMCPCompletion, isMCPCompletionParams, isMCPCompletionReference, isMCPCompletionResult, isMCPConsumerFilter, isMCPContent, isMCPElicitFieldSchema, isMCPElicitForm, isMCPElicitRequest, isMCPElicitResult, isMCPElicitSchema, isMCPElicitURL, isMCPError, isMCPHeaderPrimitive, isMCPIcon, isMCPIdentity, isMCPInputRequest, isMCPInputRequestMap, isMCPInputResponse, isMCPInputResult, isMCPLegacyResult, isMCPLegacyVersion, isMCPLoggingLevel, isMCPMetaKey, isMCPMetaObject, isMCPModernVersion, isMCPNotificationMetaObject, isMCPPaginationParams, isMCPProgress, isMCPPrompt, isMCPPromptArgument, isMCPPromptGetResult, isMCPPromptMessage, isMCPPromptPage, isMCPResource, isMCPResourceContents, isMCPResourcePage, isMCPResourceTemplate, isMCPResourceTemplatePage, isMCPResult, isMCPResultMetaObject, isMCPRoot, isMCPRootResult, isMCPSampleContent, isMCPSampleResult, isMCPServerCapabilities, isMCPStringArguments, isMCPSubscriptionFilter, isMCPSubscriptionResult, isMCPTaskDetail, isMCPTaskDetailResult, isMCPTaskNotification, isMCPTaskResult, isMCPTaskStatus, isMCPTextResource, isMCPToolAnnotations, isMCPVersion, isModernRequest, isPingRequest, isRFC3339Date, isRFC3339DateTime, isStandardBase64, legacyInvocationToModern, legacyResultToModern, matchesResultType, matchesSubscriptionNotification, mcpAnnotationsToTool, modernInvocationToLegacy, modernResultToLegacy, parseJSONRPCMessage, parseMCPInputState, parseRequestContext, readCancelledId, readEventStream, renderHeaderValue, sendStream, serializeJSON, snapshotJSON, snapshotToolResult, stampSubscriptionNotification, supportsFormElicitation, supportsTask, toolAnnotationsToMCP };
6888
6908
 
6889
6909
  //# sourceMappingURL=index.js.map