@cyanheads/mcp-ts-core 0.12.5 → 0.12.6
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/AGENTS.md +25 -14
- package/CLAUDE.md +25 -14
- package/README.md +1 -1
- package/changelog/0.12.x/0.12.6.md +44 -0
- package/dist/core/app.d.ts +2 -2
- package/dist/core/app.js +2 -2
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +2 -2
- package/dist/core/worker.d.ts +1 -1
- package/dist/core/worker.js +1 -1
- package/dist/mcp-server/apps/appBuilders.d.ts +2 -2
- package/dist/mcp-server/apps/appBuilders.js +2 -2
- package/dist/mcp-server/cacheHints.d.ts +1 -1
- package/dist/mcp-server/prompts/prompt-registration.d.ts +1 -1
- package/dist/mcp-server/prompts/prompt-registration.js +1 -1
- package/dist/mcp-server/resources/resource-registration.d.ts +3 -3
- package/dist/mcp-server/resources/resource-registration.js +1 -1
- package/dist/mcp-server/resources/resourceSubscriptions.d.ts +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +2 -2
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +4 -4
- package/dist/mcp-server/server.d.ts +4 -4
- package/dist/mcp-server/server.js +1 -1
- package/dist/mcp-server/tools/tool-registration.d.ts +3 -3
- package/dist/mcp-server/tools/tool-registration.js +2 -2
- package/dist/mcp-server/tools/utils/disabled-tool.d.ts +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +4 -4
- package/dist/mcp-server/transports/auth/authFactory.d.ts +1 -1
- package/dist/mcp-server/transports/auth/authFactory.js +2 -2
- package/dist/mcp-server/transports/auth/authMiddleware.d.ts +1 -1
- package/dist/mcp-server/transports/auth/authMiddleware.js +1 -1
- package/dist/mcp-server/transports/auth/lib/authUtils.js +1 -1
- package/dist/mcp-server/transports/auth/lib/claimParser.d.ts +1 -1
- package/dist/mcp-server/transports/auth/strategies/authStrategy.d.ts +1 -1
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.d.ts +2 -2
- package/dist/mcp-server/transports/auth/strategies/jwtStrategy.js +1 -1
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.d.ts +2 -2
- package/dist/mcp-server/transports/auth/strategies/oauthStrategy.js +1 -1
- package/dist/mcp-server/transports/http/httpErrorHandler.d.ts +1 -1
- package/dist/mcp-server/transports/http/httpServer.d.ts +1 -1
- package/dist/mcp-server/transports/http/httpServer.js +1 -1
- package/dist/mcp-server/transports/http/httpTransport.d.ts +3 -3
- package/dist/mcp-server/transports/http/httpTransport.js +12 -12
- package/dist/mcp-server/transports/http/landing-page/handler.d.ts +1 -1
- package/dist/mcp-server/transports/http/sessionStore.js +1 -1
- package/dist/mcp-server/transports/manager.d.ts +2 -2
- package/dist/mcp-server/transports/manager.js +3 -3
- package/dist/services/llm/providers/openrouter.provider.d.ts +1 -1
- package/dist/storage/core/StorageService.d.ts +1 -1
- package/dist/storage/core/StorageService.js +1 -1
- package/dist/storage/core/storageFactory.d.ts +2 -2
- package/dist/storage/core/storageFactory.js +6 -6
- package/dist/storage/core/storageValidation.d.ts.map +1 -1
- package/dist/storage/core/storageValidation.js +5 -3
- package/dist/storage/core/storageValidation.js.map +1 -1
- package/dist/storage/providers/cloudflare/d1Provider.d.ts +1 -1
- package/dist/storage/providers/cloudflare/d1Provider.js +1 -1
- package/dist/storage/providers/cloudflare/kvProvider.d.ts +1 -1
- package/dist/storage/providers/cloudflare/kvProvider.js +1 -1
- package/dist/storage/providers/cloudflare/r2Provider.d.ts +1 -1
- package/dist/storage/providers/cloudflare/r2Provider.js +1 -1
- package/dist/storage/providers/fileSystem/fileSystemProvider.d.ts +1 -1
- package/dist/storage/providers/fileSystem/fileSystemProvider.js +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.d.ts +3 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.d.ts.map +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.js +11 -7
- package/dist/storage/providers/inMemory/inMemoryProvider.js.map +1 -1
- package/dist/storage/providers/supabase/supabaseProvider.d.ts +2 -2
- package/dist/storage/providers/supabase/supabaseProvider.js +1 -1
- package/dist/testing/fuzz.d.ts.map +1 -1
- package/dist/testing/fuzz.js +92 -53
- package/dist/testing/fuzz.js.map +1 -1
- package/dist/utils/formatting/diffFormatter.d.ts +2 -2
- package/dist/utils/formatting/diffFormatter.js +4 -4
- package/dist/utils/formatting/tableFormatter.d.ts +2 -2
- package/dist/utils/formatting/tableFormatter.js +3 -3
- package/dist/utils/formatting/treeFormatter.d.ts +3 -3
- package/dist/utils/formatting/treeFormatter.js +4 -4
- package/dist/utils/internal/error-handler/errorHandler.js +6 -6
- package/dist/utils/internal/error-handler/helpers.js +1 -1
- package/dist/utils/internal/error-handler/types.d.ts +1 -1
- package/dist/utils/internal/health.js +2 -2
- package/dist/utils/internal/lazyImport.js +1 -1
- package/dist/utils/internal/logger.d.ts +3 -3
- package/dist/utils/internal/logger.js +4 -4
- package/dist/utils/internal/performance.d.ts +1 -1
- package/dist/utils/internal/performance.js +6 -6
- package/dist/utils/internal/requestContext.d.ts +1 -1
- package/dist/utils/internal/requestContext.js +2 -2
- package/dist/utils/metrics/tokenCounter.d.ts +1 -1
- package/dist/utils/metrics/tokenCounter.js +2 -2
- package/dist/utils/network/fetchWithTimeout.d.ts +1 -1
- package/dist/utils/network/fetchWithTimeout.js +6 -6
- package/dist/utils/network/httpError.js +1 -1
- package/dist/utils/network/retry.d.ts +1 -1
- package/dist/utils/network/retry.js +1 -1
- package/dist/utils/pagination/pagination.d.ts +2 -2
- package/dist/utils/pagination/pagination.js +4 -4
- package/dist/utils/parsing/csvParser.d.ts +4 -4
- package/dist/utils/parsing/csvParser.js +6 -6
- package/dist/utils/parsing/dateParser.d.ts +3 -3
- package/dist/utils/parsing/dateParser.js +6 -6
- package/dist/utils/parsing/frontmatterParser.d.ts +2 -2
- package/dist/utils/parsing/frontmatterParser.js +3 -3
- package/dist/utils/parsing/htmlExtractor.d.ts +3 -3
- package/dist/utils/parsing/htmlExtractor.js +5 -5
- package/dist/utils/parsing/jsonParser.d.ts +4 -4
- package/dist/utils/parsing/jsonParser.js +6 -6
- package/dist/utils/parsing/pdfParser.d.ts +2 -2
- package/dist/utils/parsing/pdfParser.js +4 -4
- package/dist/utils/parsing/xmlParser.d.ts +4 -4
- package/dist/utils/parsing/xmlParser.js +5 -5
- package/dist/utils/parsing/yamlParser.d.ts +4 -4
- package/dist/utils/parsing/yamlParser.js +6 -6
- package/dist/utils/scheduling/scheduler.d.ts +3 -3
- package/dist/utils/scheduling/scheduler.js +5 -5
- package/dist/utils/security/rateLimiter.d.ts +2 -2
- package/dist/utils/security/rateLimiter.js +3 -3
- package/dist/utils/security/rateLimiter.js.map +1 -1
- package/dist/utils/security/sanitization.d.ts +3 -3
- package/dist/utils/security/sanitization.js +7 -7
- package/dist/utils/telemetry/instrumentation.d.ts.map +1 -1
- package/dist/utils/telemetry/instrumentation.js +7 -8
- package/dist/utils/telemetry/instrumentation.js.map +1 -1
- package/dist/utils/telemetry/trace.d.ts +1 -1
- package/dist/utils/telemetry/trace.js +1 -1
- package/package.json +13 -7
- package/scripts/devcheck.ts +6 -4
- package/skills/api-workers/SKILL.md +3 -3
- package/templates/AGENTS.md +2 -2
- package/templates/CLAUDE.md +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RequestContext } from '
|
|
1
|
+
import { type RequestContext } from './requestContext.js';
|
|
2
2
|
/**
|
|
3
3
|
* RFC 5424 severity levels supported by the MCP logger, ordered from least to most severe.
|
|
4
4
|
* These map internally to Pino levels for transport compatibility:
|
|
@@ -68,7 +68,7 @@ export declare class Logger {
|
|
|
68
68
|
* @returns The singleton `Logger` instance.
|
|
69
69
|
* @example
|
|
70
70
|
* ```ts
|
|
71
|
-
* import { Logger } from '
|
|
71
|
+
* import { Logger } from './logger.js';
|
|
72
72
|
* const log = Logger.getInstance();
|
|
73
73
|
* ```
|
|
74
74
|
*/
|
|
@@ -358,7 +358,7 @@ export declare class Logger {
|
|
|
358
358
|
*
|
|
359
359
|
* @example
|
|
360
360
|
* ```ts
|
|
361
|
-
* import { logger } from '
|
|
361
|
+
* import { logger } from './logger.js';
|
|
362
362
|
*
|
|
363
363
|
* // At startup:
|
|
364
364
|
* await logger.initialize('debug', 'http');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pino from 'pino';
|
|
2
2
|
import { config } from '../../config/index.js';
|
|
3
|
-
import { requestContextService, toCanonicalContext, } from '
|
|
4
|
-
import { UNTHROTTLED_MESSAGES } from '
|
|
3
|
+
import { requestContextService, toCanonicalContext, } from './requestContext.js';
|
|
4
|
+
import { UNTHROTTLED_MESSAGES } from './telemetryMessages.js';
|
|
5
5
|
const mcpToPinoLevel = {
|
|
6
6
|
emerg: 'fatal',
|
|
7
7
|
alert: 'fatal',
|
|
@@ -181,7 +181,7 @@ export class Logger {
|
|
|
181
181
|
* @returns The singleton `Logger` instance.
|
|
182
182
|
* @example
|
|
183
183
|
* ```ts
|
|
184
|
-
* import { Logger } from '
|
|
184
|
+
* import { Logger } from './logger.js';
|
|
185
185
|
* const log = Logger.getInstance();
|
|
186
186
|
* ```
|
|
187
187
|
*/
|
|
@@ -823,7 +823,7 @@ export class Logger {
|
|
|
823
823
|
*
|
|
824
824
|
* @example
|
|
825
825
|
* ```ts
|
|
826
|
-
* import { logger } from '
|
|
826
|
+
* import { logger } from './logger.js';
|
|
827
827
|
*
|
|
828
828
|
* // At startup:
|
|
829
829
|
* await logger.initialize('debug', 'http');
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* symmetric instrumentation so dashboards and traces cover the full MCP surface.
|
|
6
6
|
* @module src/utils/internal/performance
|
|
7
7
|
*/
|
|
8
|
-
import { type RequestContext } from '
|
|
8
|
+
import { type RequestContext } from './requestContext.js';
|
|
9
9
|
/** Eagerly creates tool, resource, and prompt metric instruments so series exist from startup. */
|
|
10
10
|
export declare function initHandlerMetrics(): void;
|
|
11
11
|
/**
|
|
@@ -9,12 +9,12 @@ import { SpanStatusCode, trace } from '@opentelemetry/api';
|
|
|
9
9
|
import { config } from '../../config/index.js';
|
|
10
10
|
import { isInputRequiredSignal } from '../../mcp-server/inputRequired.js';
|
|
11
11
|
import { McpError } from '../../types-global/errors.js';
|
|
12
|
-
import { getErrorCategory } from '
|
|
13
|
-
import { logger } from '
|
|
14
|
-
import { withActiveSpan, withExtra } from '
|
|
15
|
-
import { TELEMETRY_LOG_MESSAGES } from '
|
|
16
|
-
import { ATTR_CODE_FUNCTION_NAME, ATTR_CODE_NAMESPACE, ATTR_MCP_PROMPT_DURATION_MS, ATTR_MCP_PROMPT_ERROR_CATEGORY, ATTR_MCP_PROMPT_ERROR_CODE, ATTR_MCP_PROMPT_INPUT_BYTES, ATTR_MCP_PROMPT_INPUT_REQUIRED, ATTR_MCP_PROMPT_MESSAGE_COUNT, ATTR_MCP_PROMPT_NAME, ATTR_MCP_PROMPT_OUTPUT_BYTES, ATTR_MCP_PROMPT_SUCCESS, ATTR_MCP_RESOURCE_DURATION_MS, ATTR_MCP_RESOURCE_ERROR_CODE, ATTR_MCP_RESOURCE_INPUT_REQUIRED, ATTR_MCP_RESOURCE_MIME_TYPE, ATTR_MCP_RESOURCE_NAME, ATTR_MCP_RESOURCE_SIZE_BYTES, ATTR_MCP_RESOURCE_SUCCESS, ATTR_MCP_RESOURCE_URI, ATTR_MCP_TOOL_BATCH_FAILED, ATTR_MCP_TOOL_BATCH_SUCCEEDED, ATTR_MCP_TOOL_DURATION_MS, ATTR_MCP_TOOL_ERROR_CATEGORY, ATTR_MCP_TOOL_ERROR_CODE, ATTR_MCP_TOOL_INPUT_BYTES, ATTR_MCP_TOOL_INPUT_REQUIRED, ATTR_MCP_TOOL_NAME, ATTR_MCP_TOOL_OUTPUT_BYTES, ATTR_MCP_TOOL_PARTIAL_SUCCESS, ATTR_MCP_TOOL_SUCCESS, } from '
|
|
17
|
-
import { createCounter, createHistogram, createUpDownCounter } from '
|
|
12
|
+
import { getErrorCategory } from './error-handler/mappings.js';
|
|
13
|
+
import { logger } from './logger.js';
|
|
14
|
+
import { withActiveSpan, withExtra } from './requestContext.js';
|
|
15
|
+
import { TELEMETRY_LOG_MESSAGES } from './telemetryMessages.js';
|
|
16
|
+
import { ATTR_CODE_FUNCTION_NAME, ATTR_CODE_NAMESPACE, ATTR_MCP_PROMPT_DURATION_MS, ATTR_MCP_PROMPT_ERROR_CATEGORY, ATTR_MCP_PROMPT_ERROR_CODE, ATTR_MCP_PROMPT_INPUT_BYTES, ATTR_MCP_PROMPT_INPUT_REQUIRED, ATTR_MCP_PROMPT_MESSAGE_COUNT, ATTR_MCP_PROMPT_NAME, ATTR_MCP_PROMPT_OUTPUT_BYTES, ATTR_MCP_PROMPT_SUCCESS, ATTR_MCP_RESOURCE_DURATION_MS, ATTR_MCP_RESOURCE_ERROR_CODE, ATTR_MCP_RESOURCE_INPUT_REQUIRED, ATTR_MCP_RESOURCE_MIME_TYPE, ATTR_MCP_RESOURCE_NAME, ATTR_MCP_RESOURCE_SIZE_BYTES, ATTR_MCP_RESOURCE_SUCCESS, ATTR_MCP_RESOURCE_URI, ATTR_MCP_TOOL_BATCH_FAILED, ATTR_MCP_TOOL_BATCH_SUCCEEDED, ATTR_MCP_TOOL_DURATION_MS, ATTR_MCP_TOOL_ERROR_CATEGORY, ATTR_MCP_TOOL_ERROR_CODE, ATTR_MCP_TOOL_INPUT_BYTES, ATTR_MCP_TOOL_INPUT_REQUIRED, ATTR_MCP_TOOL_NAME, ATTR_MCP_TOOL_OUTPUT_BYTES, ATTR_MCP_TOOL_PARTIAL_SUCCESS, ATTR_MCP_TOOL_SUCCESS, } from '../telemetry/attributes.js';
|
|
17
|
+
import { createCounter, createHistogram, createUpDownCounter } from '../telemetry/metrics.js';
|
|
18
18
|
// OTel metric instruments for tool execution (lazy-initialized on first use)
|
|
19
19
|
let toolCallCounter;
|
|
20
20
|
let toolCallDuration;
|
|
@@ -203,7 +203,7 @@ export interface CreateRequestContextParams {
|
|
|
203
203
|
*
|
|
204
204
|
* @example
|
|
205
205
|
* ```typescript
|
|
206
|
-
* import { requestContextService } from '
|
|
206
|
+
* import { requestContextService } from './requestContext.js';
|
|
207
207
|
*
|
|
208
208
|
* // Create a root context for an incoming request
|
|
209
209
|
* const ctx = requestContextService.createRequestContext({ operation: 'handleRequest' });
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { isSpanContextValid, trace } from '@opentelemetry/api';
|
|
24
24
|
import { authContext as alsAuthContext } from '../../mcp-server/transports/auth/lib/authContext.js';
|
|
25
|
-
import { generateRequestContextId } from '
|
|
25
|
+
import { generateRequestContextId } from '../security/idGenerator.js';
|
|
26
26
|
/** Maps validated token info to the context-facing auth shape. */
|
|
27
27
|
function toAuthContext(info) {
|
|
28
28
|
return {
|
|
@@ -243,7 +243,7 @@ const requestContextServiceInstance = {
|
|
|
243
243
|
*
|
|
244
244
|
* @example
|
|
245
245
|
* ```typescript
|
|
246
|
-
* import { requestContextService } from '
|
|
246
|
+
* import { requestContextService } from './requestContext.js';
|
|
247
247
|
*
|
|
248
248
|
* // Create a root context for an incoming request
|
|
249
249
|
* const ctx = requestContextService.createRequestContext({ operation: 'handleRequest' });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RequestContext } from '
|
|
1
|
+
import type { RequestContext } from '../internal/requestContext.js';
|
|
2
2
|
/**
|
|
3
3
|
* Minimal chat message shape used for token counting, intentionally provider-agnostic.
|
|
4
4
|
* Covers the common subset of OpenAI-style chat message fields without depending on
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* @module src/utils/metrics/tokenCounter
|
|
6
6
|
*/
|
|
7
7
|
import { JsonRpcErrorCode } from '../../types-global/errors.js';
|
|
8
|
-
import { ErrorHandler } from '
|
|
9
|
-
import { logger } from '
|
|
8
|
+
import { ErrorHandler } from '../internal/error-handler/errorHandler.js';
|
|
9
|
+
import { logger } from '../internal/logger.js';
|
|
10
10
|
const DEFAULT_MODEL = 'gpt-4o';
|
|
11
11
|
// Known heuristics; tweak as you calibrate
|
|
12
12
|
const HEURISTICS = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RequestContext } from '
|
|
1
|
+
import { type RequestContext } from '../internal/requestContext.js';
|
|
2
2
|
/** Eagerly creates the HTTP client duration histogram so the series exists from startup. */
|
|
3
3
|
export declare function initHttpClientMetrics(): void;
|
|
4
4
|
/**
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* @module src/utils/network/fetchWithTimeout
|
|
5
5
|
*/
|
|
6
6
|
import { JsonRpcErrorCode, McpError, requestCancelled, serviceUnavailable, timeout, validationError, } from '../../types-global/errors.js';
|
|
7
|
-
import { logger } from '
|
|
8
|
-
import { withExtra } from '
|
|
9
|
-
import { runtimeCaps } from '
|
|
10
|
-
import { httpStatusRetryability, httpStatusToErrorCode } from '
|
|
11
|
-
import { readBoundedResponseText } from '
|
|
12
|
-
import { createHistogram } from '
|
|
7
|
+
import { logger } from '../internal/logger.js';
|
|
8
|
+
import { withExtra } from '../internal/requestContext.js';
|
|
9
|
+
import { runtimeCaps } from '../internal/runtime.js';
|
|
10
|
+
import { httpStatusRetryability, httpStatusToErrorCode } from './httpError.js';
|
|
11
|
+
import { readBoundedResponseText } from './responseBody.js';
|
|
12
|
+
import { createHistogram } from '../telemetry/metrics.js';
|
|
13
13
|
/** Default captured bytes of an upstream error response body. Keeps tool errors from poisoning the agent's context. */
|
|
14
14
|
const ERROR_BODY_LIMIT = 500;
|
|
15
15
|
/**
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module src/utils/network/httpError
|
|
6
6
|
*/
|
|
7
7
|
import { JsonRpcErrorCode, McpError } from '../../types-global/errors.js';
|
|
8
|
-
import { readBoundedResponseText } from '
|
|
8
|
+
import { readBoundedResponseText } from './responseBody.js';
|
|
9
9
|
/**
|
|
10
10
|
* Maps an HTTP status code to a `JsonRpcErrorCode`. Covers the full client/server
|
|
11
11
|
* 4xx/5xx range, with specific mappings for the codes most upstream APIs use to
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module src/utils/network/retry
|
|
6
6
|
*/
|
|
7
7
|
import { JsonRpcErrorCode, McpError } from '../../types-global/errors.js';
|
|
8
|
-
import { logger } from '
|
|
8
|
+
import { logger } from '../internal/logger.js';
|
|
9
9
|
/**
|
|
10
10
|
* Error codes considered transient — eligible for retry.
|
|
11
11
|
* Matches the framework's error classification in `mappings.ts`.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @see {@link https://modelcontextprotocol.io/specification/2025-06-18/utils/pagination | MCP Pagination Spec}
|
|
12
12
|
* @module src/utils/pagination/pagination
|
|
13
13
|
*/
|
|
14
|
-
import { type RequestContext } from '
|
|
14
|
+
import { type RequestContext } from '../internal/requestContext.js';
|
|
15
15
|
/**
|
|
16
16
|
* Generic pagination state that can be encoded into a cursor.
|
|
17
17
|
* Implementations can extend this with additional fields as needed.
|
|
@@ -137,7 +137,7 @@ export declare function paginateArray<T>(items: T[], cursorStr: string | undefin
|
|
|
137
137
|
* or defer to environment-variable-driven config parsed in the config module.
|
|
138
138
|
*
|
|
139
139
|
* @example
|
|
140
|
-
* import { DEFAULT_PAGINATION_CONFIG, paginateArray } from '
|
|
140
|
+
* import { DEFAULT_PAGINATION_CONFIG, paginateArray } from './pagination.js';
|
|
141
141
|
* const result = paginateArray(
|
|
142
142
|
* items,
|
|
143
143
|
* cursorStr,
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
* @module src/utils/pagination/pagination
|
|
13
13
|
*/
|
|
14
14
|
import { invalidParams, JsonRpcErrorCode, McpError } from '../../types-global/errors.js';
|
|
15
|
-
import { base64ToString, stringToBase64 } from '
|
|
16
|
-
import { logger } from '
|
|
17
|
-
import { withExtra } from '
|
|
15
|
+
import { base64ToString, stringToBase64 } from '../internal/encoding.js';
|
|
16
|
+
import { logger } from '../internal/logger.js';
|
|
17
|
+
import { withExtra } from '../internal/requestContext.js';
|
|
18
18
|
/**
|
|
19
19
|
* Encodes pagination state into an opaque base64url cursor string.
|
|
20
20
|
* Serializes `state` to JSON, then encodes as base64url (URL-safe, no padding).
|
|
@@ -171,7 +171,7 @@ export function paginateArray(items, cursorStr, defaultPageSize, maxPageSize, co
|
|
|
171
171
|
* or defer to environment-variable-driven config parsed in the config module.
|
|
172
172
|
*
|
|
173
173
|
* @example
|
|
174
|
-
* import { DEFAULT_PAGINATION_CONFIG, paginateArray } from '
|
|
174
|
+
* import { DEFAULT_PAGINATION_CONFIG, paginateArray } from './pagination.js';
|
|
175
175
|
* const result = paginateArray(
|
|
176
176
|
* items,
|
|
177
177
|
* cursorStr,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @module src/utils/parsing/csvParser
|
|
9
9
|
*/
|
|
10
10
|
import type Papa from 'papaparse';
|
|
11
|
-
import { type RequestContext } from '
|
|
11
|
+
import { type RequestContext } from '../internal/requestContext.js';
|
|
12
12
|
/**
|
|
13
13
|
* Utility class for parsing CSV strings.
|
|
14
14
|
*
|
|
@@ -40,7 +40,7 @@ export declare class CsvParser {
|
|
|
40
40
|
* the `<think>` block, or if `papaparse` reports parse errors.
|
|
41
41
|
* @example
|
|
42
42
|
* ```typescript
|
|
43
|
-
* import { csvParser } from '
|
|
43
|
+
* import { csvParser } from './csvParser.js';
|
|
44
44
|
*
|
|
45
45
|
* // Parse with header row — rows typed as objects
|
|
46
46
|
* const result = await csvParser.parse<{ name: string; age: string }>(
|
|
@@ -64,14 +64,14 @@ export declare class CsvParser {
|
|
|
64
64
|
*
|
|
65
65
|
* @example
|
|
66
66
|
* ```typescript
|
|
67
|
-
* import { csvParser } from '
|
|
67
|
+
* import { csvParser } from './csvParser.js';
|
|
68
68
|
*
|
|
69
69
|
* // Parse with header row
|
|
70
70
|
* const result = await csvParser.parse<{ a: string; b: string }>('a,b\n1,2', { header: true });
|
|
71
71
|
* console.log(result.data[0]); // { a: '1', b: '2' }
|
|
72
72
|
*
|
|
73
73
|
* // With request context for correlated logging
|
|
74
|
-
* import { requestContextService } from '
|
|
74
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
75
75
|
* const ctx = requestContextService.createRequestContext({ operation: 'importData' });
|
|
76
76
|
* const imported = await csvParser.parse(rawCsv, { header: true, dynamicTyping: true }, ctx);
|
|
77
77
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { validationError } from '../../types-global/errors.js';
|
|
2
|
-
import { lazyImport } from '
|
|
3
|
-
import { logger } from '
|
|
4
|
-
import { requestContextService, withExtra, } from '
|
|
2
|
+
import { lazyImport } from '../internal/lazyImport.js';
|
|
3
|
+
import { logger } from '../internal/logger.js';
|
|
4
|
+
import { requestContextService, withExtra, } from '../internal/requestContext.js';
|
|
5
5
|
import { thinkBlockRegex } from './thinkBlock.js';
|
|
6
6
|
const importPapa = lazyImport(() => import('papaparse'), 'Install "papaparse" to use CSV parsing: bun add papaparse');
|
|
7
7
|
let _papa;
|
|
@@ -44,7 +44,7 @@ export class CsvParser {
|
|
|
44
44
|
* the `<think>` block, or if `papaparse` reports parse errors.
|
|
45
45
|
* @example
|
|
46
46
|
* ```typescript
|
|
47
|
-
* import { csvParser } from '
|
|
47
|
+
* import { csvParser } from './csvParser.js';
|
|
48
48
|
*
|
|
49
49
|
* // Parse with header row — rows typed as objects
|
|
50
50
|
* const result = await csvParser.parse<{ name: string; age: string }>(
|
|
@@ -108,14 +108,14 @@ export class CsvParser {
|
|
|
108
108
|
*
|
|
109
109
|
* @example
|
|
110
110
|
* ```typescript
|
|
111
|
-
* import { csvParser } from '
|
|
111
|
+
* import { csvParser } from './csvParser.js';
|
|
112
112
|
*
|
|
113
113
|
* // Parse with header row
|
|
114
114
|
* const result = await csvParser.parse<{ a: string; b: string }>('a,b\n1,2', { header: true });
|
|
115
115
|
* console.log(result.data[0]); // { a: '1', b: '2' }
|
|
116
116
|
*
|
|
117
117
|
* // With request context for correlated logging
|
|
118
|
-
* import { requestContextService } from '
|
|
118
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
119
119
|
* const ctx = requestContextService.createRequestContext({ operation: 'importData' });
|
|
120
120
|
* const imported = await csvParser.parse(rawCsv, { header: true, dynamicTyping: true }, ctx);
|
|
121
121
|
*
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module src/utils/parsing/dateParser
|
|
5
5
|
*/
|
|
6
6
|
import type * as chrono from 'chrono-node';
|
|
7
|
-
import { type RequestContext } from '
|
|
7
|
+
import { type RequestContext } from '../internal/requestContext.js';
|
|
8
8
|
/**
|
|
9
9
|
* Parses a natural language date string into a JavaScript `Date` object.
|
|
10
10
|
*
|
|
@@ -57,8 +57,8 @@ export declare function parseDateStringDetailed(text: string, context: RequestCo
|
|
|
57
57
|
*
|
|
58
58
|
* @example
|
|
59
59
|
* ```typescript
|
|
60
|
-
* import { dateParser } from '
|
|
61
|
-
* import { requestContextService } from '
|
|
60
|
+
* import { dateParser } from './dateParser.js';
|
|
61
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
62
62
|
*
|
|
63
63
|
* const ctx = requestContextService.createRequestContext({ operation: 'myOp' });
|
|
64
64
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { JsonRpcErrorCode } from '../../types-global/errors.js';
|
|
2
|
-
import { ErrorHandler } from '
|
|
3
|
-
import { lazyImport } from '
|
|
4
|
-
import { logger } from '
|
|
5
|
-
import { withExtra } from '
|
|
2
|
+
import { ErrorHandler } from '../internal/error-handler/errorHandler.js';
|
|
3
|
+
import { lazyImport } from '../internal/lazyImport.js';
|
|
4
|
+
import { logger } from '../internal/logger.js';
|
|
5
|
+
import { withExtra } from '../internal/requestContext.js';
|
|
6
6
|
const getChrono = lazyImport(() => import('chrono-node'), 'Install "chrono-node" to use date parsing: bun add chrono-node');
|
|
7
7
|
/**
|
|
8
8
|
* Parses a natural language date string into a JavaScript `Date` object.
|
|
@@ -95,8 +95,8 @@ export async function parseDateStringDetailed(text, context, refDate) {
|
|
|
95
95
|
*
|
|
96
96
|
* @example
|
|
97
97
|
* ```typescript
|
|
98
|
-
* import { dateParser } from '
|
|
99
|
-
* import { requestContextService } from '
|
|
98
|
+
* import { dateParser } from './dateParser.js';
|
|
99
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
100
100
|
*
|
|
101
101
|
* const ctx = requestContextService.createRequestContext({ operation: 'myOp' });
|
|
102
102
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RequestContext } from '
|
|
1
|
+
import { type RequestContext } from '../internal/requestContext.js';
|
|
2
2
|
import { type ParserInputBudgetOptions } from './inputBudget.js';
|
|
3
3
|
/**
|
|
4
4
|
* Result of parsing markdown with frontmatter.
|
|
@@ -63,7 +63,7 @@ export declare class FrontmatterParser {
|
|
|
63
63
|
* @example
|
|
64
64
|
* ```typescript
|
|
65
65
|
* import { frontmatterParser } from './frontmatterParser.js';
|
|
66
|
-
* import { requestContextService } from '
|
|
66
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
67
67
|
*
|
|
68
68
|
* const context = requestContextService.createRequestContext({ operation: 'ParseObsidianNote' });
|
|
69
69
|
*
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* @module src/utils/parsing/frontmatterParser
|
|
6
6
|
*/
|
|
7
7
|
import { McpError, validationError } from '../../types-global/errors.js';
|
|
8
|
-
import { logger } from '
|
|
9
|
-
import { requestContextService, withExtra, } from '
|
|
8
|
+
import { logger } from '../internal/logger.js';
|
|
9
|
+
import { requestContextService, withExtra, } from '../internal/requestContext.js';
|
|
10
10
|
import { assertTextInputBudget } from './inputBudget.js';
|
|
11
11
|
import { yamlParser } from './yamlParser.js';
|
|
12
12
|
/**
|
|
@@ -129,7 +129,7 @@ export class FrontmatterParser {
|
|
|
129
129
|
* @example
|
|
130
130
|
* ```typescript
|
|
131
131
|
* import { frontmatterParser } from './frontmatterParser.js';
|
|
132
|
-
* import { requestContextService } from '
|
|
132
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
133
133
|
*
|
|
134
134
|
* const context = requestContextService.createRequestContext({ operation: 'ParseObsidianNote' });
|
|
135
135
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RequestContext } from '
|
|
1
|
+
import { type RequestContext } from '../internal/requestContext.js';
|
|
2
2
|
/**
|
|
3
3
|
* Options for HTML article extraction.
|
|
4
4
|
*/
|
|
@@ -113,7 +113,7 @@ export declare class HtmlExtractor {
|
|
|
113
113
|
*
|
|
114
114
|
* @example
|
|
115
115
|
* ```typescript
|
|
116
|
-
* import { htmlExtractor } from '
|
|
116
|
+
* import { htmlExtractor } from './htmlExtractor.js';
|
|
117
117
|
*
|
|
118
118
|
* const html = await fetch('https://example.com/article').then((r) => r.text());
|
|
119
119
|
* const result = await htmlExtractor.extract(html, {
|
|
@@ -136,7 +136,7 @@ export declare class HtmlExtractor {
|
|
|
136
136
|
*
|
|
137
137
|
* @example
|
|
138
138
|
* ```typescript
|
|
139
|
-
* import { htmlExtractor } from '
|
|
139
|
+
* import { htmlExtractor } from './htmlExtractor.js';
|
|
140
140
|
*
|
|
141
141
|
* const article = await htmlExtractor.extract(rawHtml, {
|
|
142
142
|
* url: 'https://example.com/post',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpError, validationError } from '../../types-global/errors.js';
|
|
2
|
-
import { lazyImport } from '
|
|
3
|
-
import { logger } from '
|
|
4
|
-
import { requestContextService, withExtra, } from '
|
|
2
|
+
import { lazyImport } from '../internal/lazyImport.js';
|
|
3
|
+
import { logger } from '../internal/logger.js';
|
|
4
|
+
import { requestContextService, withExtra, } from '../internal/requestContext.js';
|
|
5
5
|
import { assertTextInputBudget } from './inputBudget.js';
|
|
6
6
|
const getDefuddle = lazyImport(() => import('defuddle/node'), 'Install "defuddle" to use HTML article extraction: bun add defuddle linkedom');
|
|
7
7
|
const getLinkedom = lazyImport(() => import('linkedom'), 'Install "linkedom" to use HTML article extraction: bun add defuddle linkedom');
|
|
@@ -53,7 +53,7 @@ export class HtmlExtractor {
|
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
55
55
|
* ```typescript
|
|
56
|
-
* import { htmlExtractor } from '
|
|
56
|
+
* import { htmlExtractor } from './htmlExtractor.js';
|
|
57
57
|
*
|
|
58
58
|
* const html = await fetch('https://example.com/article').then((r) => r.text());
|
|
59
59
|
* const result = await htmlExtractor.extract(html, {
|
|
@@ -151,7 +151,7 @@ export class HtmlExtractor {
|
|
|
151
151
|
*
|
|
152
152
|
* @example
|
|
153
153
|
* ```typescript
|
|
154
|
-
* import { htmlExtractor } from '
|
|
154
|
+
* import { htmlExtractor } from './htmlExtractor.js';
|
|
155
155
|
*
|
|
156
156
|
* const article = await htmlExtractor.extract(rawHtml, {
|
|
157
157
|
* url: 'https://example.com/post',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RequestContext } from '
|
|
1
|
+
import { type RequestContext } from '../internal/requestContext.js';
|
|
2
2
|
import { type ParserInputBudgetOptions } from './inputBudget.js';
|
|
3
3
|
/**
|
|
4
4
|
* Bit flags specifying which partial JSON types are permissible during parsing.
|
|
@@ -77,7 +77,7 @@ export declare class JsonParser {
|
|
|
77
77
|
* @throws {McpError} With `ConfigurationError` if the `partial-json` package is not installed.
|
|
78
78
|
* @example
|
|
79
79
|
* ```typescript
|
|
80
|
-
* import { jsonParser, Allow } from '
|
|
80
|
+
* import { jsonParser, Allow } from './jsonParser.js';
|
|
81
81
|
*
|
|
82
82
|
* // Parse complete JSON
|
|
83
83
|
* const obj = await jsonParser.parse<{ key: string }>('{"key": "value"}');
|
|
@@ -99,8 +99,8 @@ export declare class JsonParser {
|
|
|
99
99
|
*
|
|
100
100
|
* @example
|
|
101
101
|
* ```typescript
|
|
102
|
-
* import { jsonParser, Allow } from '
|
|
103
|
-
* import { requestContextService } from '
|
|
102
|
+
* import { jsonParser, Allow } from './jsonParser.js';
|
|
103
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
104
104
|
*
|
|
105
105
|
* const ctx = requestContextService.createRequestContext({ operation: 'myOp' });
|
|
106
106
|
*
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* @module src/utils/parsing/jsonParser
|
|
6
6
|
*/
|
|
7
7
|
import { validationError } from '../../types-global/errors.js';
|
|
8
|
-
import { lazyImport } from '
|
|
9
|
-
import { logger } from '
|
|
10
|
-
import { requestContextService, withExtra, } from '
|
|
8
|
+
import { lazyImport } from '../internal/lazyImport.js';
|
|
9
|
+
import { logger } from '../internal/logger.js';
|
|
10
|
+
import { requestContextService, withExtra, } from '../internal/requestContext.js';
|
|
11
11
|
import { assertTextInputBudget } from './inputBudget.js';
|
|
12
12
|
import { thinkBlockRegex } from './thinkBlock.js';
|
|
13
13
|
const getPartialJson = lazyImport(() => import('partial-json'), 'Install "partial-json" to use partial JSON parsing: bun add partial-json');
|
|
@@ -88,7 +88,7 @@ export class JsonParser {
|
|
|
88
88
|
* @throws {McpError} With `ConfigurationError` if the `partial-json` package is not installed.
|
|
89
89
|
* @example
|
|
90
90
|
* ```typescript
|
|
91
|
-
* import { jsonParser, Allow } from '
|
|
91
|
+
* import { jsonParser, Allow } from './jsonParser.js';
|
|
92
92
|
*
|
|
93
93
|
* // Parse complete JSON
|
|
94
94
|
* const obj = await jsonParser.parse<{ key: string }>('{"key": "value"}');
|
|
@@ -149,8 +149,8 @@ export class JsonParser {
|
|
|
149
149
|
*
|
|
150
150
|
* @example
|
|
151
151
|
* ```typescript
|
|
152
|
-
* import { jsonParser, Allow } from '
|
|
153
|
-
* import { requestContextService } from '
|
|
152
|
+
* import { jsonParser, Allow } from './jsonParser.js';
|
|
153
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
154
154
|
*
|
|
155
155
|
* const ctx = requestContextService.createRequestContext({ operation: 'myOp' });
|
|
156
156
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @module src/utils/parsing/pdfParser
|
|
6
6
|
*/
|
|
7
7
|
import type { PDFDocument, PDFFont, PDFImage, PDFPage, RGB } from 'pdf-lib';
|
|
8
|
-
import { type RequestContext } from '
|
|
8
|
+
import { type RequestContext } from '../internal/requestContext.js';
|
|
9
9
|
import { type ParserInputBudgetOptions } from './inputBudget.js';
|
|
10
10
|
/**
|
|
11
11
|
* Options for adding a new page to a PDF document.
|
|
@@ -564,7 +564,7 @@ export declare class PdfParser {
|
|
|
564
564
|
*
|
|
565
565
|
* @example
|
|
566
566
|
* ```typescript
|
|
567
|
-
* import { pdfParser } from '
|
|
567
|
+
* import { pdfParser } from './pdfParser.js';
|
|
568
568
|
* import { writeFile } from 'node:fs/promises';
|
|
569
569
|
*
|
|
570
570
|
* const doc = await pdfParser.createDocument();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JsonRpcErrorCode, McpError } from '../../types-global/errors.js';
|
|
2
|
-
import { lazyImport } from '
|
|
3
|
-
import { logger } from '
|
|
4
|
-
import { requestContextService, withExtra, } from '
|
|
2
|
+
import { lazyImport } from '../internal/lazyImport.js';
|
|
3
|
+
import { logger } from '../internal/logger.js';
|
|
4
|
+
import { requestContextService, withExtra, } from '../internal/requestContext.js';
|
|
5
5
|
import { assertBinaryInputBudget, assertBinaryInputsBudget, } from './inputBudget.js';
|
|
6
6
|
const getPdfLib = lazyImport(() => import('pdf-lib'), 'Install "pdf-lib" to use PDF operations: bun add pdf-lib');
|
|
7
7
|
const getUnpdf = lazyImport(() => import('unpdf'), 'Install "unpdf" to use PDF text extraction: bun add unpdf');
|
|
@@ -694,7 +694,7 @@ export class PdfParser {
|
|
|
694
694
|
*
|
|
695
695
|
* @example
|
|
696
696
|
* ```typescript
|
|
697
|
-
* import { pdfParser } from '
|
|
697
|
+
* import { pdfParser } from './pdfParser.js';
|
|
698
698
|
* import { writeFile } from 'node:fs/promises';
|
|
699
699
|
*
|
|
700
700
|
* const doc = await pdfParser.createDocument();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RequestContext } from '
|
|
1
|
+
import { type RequestContext } from '../internal/requestContext.js';
|
|
2
2
|
import { type ParserInputBudgetOptions } from './inputBudget.js';
|
|
3
3
|
/**
|
|
4
4
|
* Utility class for parsing XML strings.
|
|
@@ -30,7 +30,7 @@ export declare class XmlParser {
|
|
|
30
30
|
* the `<think>` block, or if `fast-xml-parser` throws during parsing.
|
|
31
31
|
* @example
|
|
32
32
|
* ```typescript
|
|
33
|
-
* import { xmlParser } from '
|
|
33
|
+
* import { xmlParser } from './xmlParser.js';
|
|
34
34
|
*
|
|
35
35
|
* const result = await xmlParser.parse<{ root: { key: string } }>('<root><key>value</key></root>');
|
|
36
36
|
* console.log(result.root.key); // 'value'
|
|
@@ -51,14 +51,14 @@ export declare class XmlParser {
|
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
53
|
* ```typescript
|
|
54
|
-
* import { xmlParser } from '
|
|
54
|
+
* import { xmlParser } from './xmlParser.js';
|
|
55
55
|
*
|
|
56
56
|
* // Basic parse
|
|
57
57
|
* const result = await xmlParser.parse<{ root: { id: string } }>('<root><id>42</id></root>');
|
|
58
58
|
* console.log(result.root.id); // '42'
|
|
59
59
|
*
|
|
60
60
|
* // With request context for correlated logging
|
|
61
|
-
* import { requestContextService } from '
|
|
61
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
62
62
|
* const ctx = requestContextService.createRequestContext({ operation: 'parseResponse' });
|
|
63
63
|
* const data = await xmlParser.parse<ApiResponse>(rawXml, ctx);
|
|
64
64
|
*
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* @module src/utils/parsing/xmlParser
|
|
10
10
|
*/
|
|
11
11
|
import { configurationError, validationError } from '../../types-global/errors.js';
|
|
12
|
-
import { logger } from '
|
|
13
|
-
import { requestContextService, withExtra, } from '
|
|
12
|
+
import { logger } from '../internal/logger.js';
|
|
13
|
+
import { requestContextService, withExtra, } from '../internal/requestContext.js';
|
|
14
14
|
import { assertTextInputBudget } from './inputBudget.js';
|
|
15
15
|
import { thinkBlockRegex } from './thinkBlock.js';
|
|
16
16
|
let _fxp;
|
|
@@ -54,7 +54,7 @@ export class XmlParser {
|
|
|
54
54
|
* the `<think>` block, or if `fast-xml-parser` throws during parsing.
|
|
55
55
|
* @example
|
|
56
56
|
* ```typescript
|
|
57
|
-
* import { xmlParser } from '
|
|
57
|
+
* import { xmlParser } from './xmlParser.js';
|
|
58
58
|
*
|
|
59
59
|
* const result = await xmlParser.parse<{ root: { key: string } }>('<root><key>value</key></root>');
|
|
60
60
|
* console.log(result.root.key); // 'value'
|
|
@@ -118,14 +118,14 @@ export class XmlParser {
|
|
|
118
118
|
*
|
|
119
119
|
* @example
|
|
120
120
|
* ```typescript
|
|
121
|
-
* import { xmlParser } from '
|
|
121
|
+
* import { xmlParser } from './xmlParser.js';
|
|
122
122
|
*
|
|
123
123
|
* // Basic parse
|
|
124
124
|
* const result = await xmlParser.parse<{ root: { id: string } }>('<root><id>42</id></root>');
|
|
125
125
|
* console.log(result.root.id); // '42'
|
|
126
126
|
*
|
|
127
127
|
* // With request context for correlated logging
|
|
128
|
-
* import { requestContextService } from '
|
|
128
|
+
* import { requestContextService } from '../internal/requestContext.js';
|
|
129
129
|
* const ctx = requestContextService.createRequestContext({ operation: 'parseResponse' });
|
|
130
130
|
* const data = await xmlParser.parse<ApiResponse>(rawXml, ctx);
|
|
131
131
|
*
|