@j0hanz/superfetch 2.1.4 → 2.1.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/dist/cache.d.ts +1 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +2 -1
- package/dist/cache.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -0
- package/dist/crypto.d.ts +1 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/crypto.js +1 -0
- package/dist/crypto.js.map +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +1 -0
- package/dist/errors.js.map +1 -0
- package/dist/fetch.d.ts +1 -0
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +2 -1
- package/dist/fetch.js.map +1 -0
- package/dist/http.d.ts +1 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +2 -1
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +1 -0
- package/dist/mcp.js.map +1 -0
- package/dist/observability.d.ts +1 -0
- package/dist/observability.d.ts.map +1 -0
- package/dist/observability.js +1 -0
- package/dist/observability.js.map +1 -0
- package/dist/tools.d.ts +1 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +2 -1
- package/dist/tools.js.map +1 -0
- package/dist/transform.d.ts +1 -0
- package/dist/transform.d.ts.map +1 -0
- package/dist/transform.js +2 -5
- package/dist/transform.js.map +1 -0
- package/dist/{utils.d.ts → type-guards.d.ts} +1 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/{utils.js → type-guards.js} +1 -0
- package/dist/type-guards.js.map +1 -0
- package/dist/workers/transform-worker.d.ts +1 -0
- package/dist/workers/transform-worker.d.ts.map +1 -0
- package/dist/workers/transform-worker.js +2 -1
- package/dist/workers/transform-worker.js.map +1 -0
- package/package.json +7 -4
- package/dist/config/auth-config.d.ts +0 -16
- package/dist/config/auth-config.js +0 -53
- package/dist/config/constants.d.ts +0 -17
- package/dist/config/constants.d.ts.map +0 -1
- package/dist/config/constants.js +0 -22
- package/dist/config/constants.js.map +0 -1
- package/dist/config/env-parsers.d.ts +0 -8
- package/dist/config/env-parsers.js +0 -96
- package/dist/config/formatting.d.ts +0 -7
- package/dist/config/formatting.d.ts.map +0 -1
- package/dist/config/formatting.js +0 -9
- package/dist/config/formatting.js.map +0 -1
- package/dist/config/index.d.ts +0 -61
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -107
- package/dist/config/index.js.map +0 -1
- package/dist/config/types/content.d.ts +0 -41
- package/dist/config/types/content.d.ts.map +0 -1
- package/dist/config/types/content.js +0 -1
- package/dist/config/types/content.js.map +0 -1
- package/dist/config/types/runtime.d.ts +0 -72
- package/dist/config/types/runtime.d.ts.map +0 -1
- package/dist/config/types/runtime.js +0 -1
- package/dist/config/types/runtime.js.map +0 -1
- package/dist/config/types/tools.d.ts +0 -28
- package/dist/config/types/tools.d.ts.map +0 -1
- package/dist/config/types/tools.js +0 -1
- package/dist/config/types/tools.js.map +0 -1
- package/dist/config/types.d.ts +0 -4
- package/dist/config/types.d.ts.map +0 -1
- package/dist/config/types.js +0 -2
- package/dist/config/types.js.map +0 -1
- package/dist/errors/app-error.d.ts +0 -7
- package/dist/errors/app-error.d.ts.map +0 -1
- package/dist/errors/app-error.js +0 -16
- package/dist/errors/app-error.js.map +0 -1
- package/dist/errors/index.d.ts +0 -2
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js +0 -2
- package/dist/errors/index.js.map +0 -1
- package/dist/http/accept-policy.d.ts +0 -3
- package/dist/http/accept-policy.js +0 -45
- package/dist/http/async-handler.d.ts +0 -2
- package/dist/http/async-handler.js +0 -5
- package/dist/http/auth-introspection.d.ts +0 -2
- package/dist/http/auth-introspection.js +0 -141
- package/dist/http/auth-static.d.ts +0 -2
- package/dist/http/auth-static.js +0 -23
- package/dist/http/auth.d.ts +0 -3
- package/dist/http/auth.d.ts.map +0 -1
- package/dist/http/auth.js +0 -269
- package/dist/http/auth.js.map +0 -1
- package/dist/http/base-middleware.d.ts +0 -7
- package/dist/http/base-middleware.js +0 -143
- package/dist/http/cors.d.ts +0 -2
- package/dist/http/cors.d.ts.map +0 -1
- package/dist/http/cors.js +0 -9
- package/dist/http/cors.js.map +0 -1
- package/dist/http/download-routes.d.ts +0 -2
- package/dist/http/download-routes.d.ts.map +0 -1
- package/dist/http/download-routes.js +0 -104
- package/dist/http/download-routes.js.map +0 -1
- package/dist/http/error-handler.d.ts +0 -2
- package/dist/http/error-handler.js +0 -55
- package/dist/http/host-allowlist.d.ts +0 -3
- package/dist/http/host-allowlist.js +0 -117
- package/dist/http/jsonrpc-http.d.ts +0 -2
- package/dist/http/jsonrpc-http.js +0 -10
- package/dist/http/mcp-routes.d.ts +0 -9
- package/dist/http/mcp-routes.d.ts.map +0 -1
- package/dist/http/mcp-routes.js +0 -204
- package/dist/http/mcp-routes.js.map +0 -1
- package/dist/http/mcp-session-eviction.d.ts +0 -3
- package/dist/http/mcp-session-eviction.js +0 -24
- package/dist/http/mcp-session-helpers.d.ts +0 -12
- package/dist/http/mcp-session-helpers.d.ts.map +0 -1
- package/dist/http/mcp-session-helpers.js +0 -64
- package/dist/http/mcp-session-helpers.js.map +0 -1
- package/dist/http/mcp-session-init.d.ts +0 -7
- package/dist/http/mcp-session-init.js +0 -94
- package/dist/http/mcp-session-slots.d.ts +0 -17
- package/dist/http/mcp-session-slots.js +0 -55
- package/dist/http/mcp-session-transport-init.d.ts +0 -7
- package/dist/http/mcp-session-transport-init.js +0 -41
- package/dist/http/mcp-session-transport.d.ts +0 -7
- package/dist/http/mcp-session-transport.js +0 -57
- package/dist/http/mcp-session-types.d.ts +0 -5
- package/dist/http/mcp-session-types.js +0 -1
- package/dist/http/mcp-session.d.ts +0 -10
- package/dist/http/mcp-session.d.ts.map +0 -1
- package/dist/http/mcp-session.js +0 -23
- package/dist/http/mcp-session.js.map +0 -1
- package/dist/http/mcp-sessions.d.ts +0 -41
- package/dist/http/mcp-sessions.js +0 -392
- package/dist/http/mcp-validation.d.ts +0 -3
- package/dist/http/mcp-validation.d.ts.map +0 -1
- package/dist/http/mcp-validation.js +0 -14
- package/dist/http/mcp-validation.js.map +0 -1
- package/dist/http/protocol-policy.d.ts +0 -2
- package/dist/http/protocol-policy.js +0 -31
- package/dist/http/rate-limit.d.ts +0 -12
- package/dist/http/rate-limit.d.ts.map +0 -1
- package/dist/http/rate-limit.js +0 -93
- package/dist/http/rate-limit.js.map +0 -1
- package/dist/http/server-config.d.ts +0 -1
- package/dist/http/server-config.js +0 -40
- package/dist/http/server-middleware.d.ts +0 -7
- package/dist/http/server-middleware.d.ts.map +0 -1
- package/dist/http/server-middleware.js +0 -52
- package/dist/http/server-middleware.js.map +0 -1
- package/dist/http/server-shutdown.d.ts +0 -4
- package/dist/http/server-shutdown.js +0 -43
- package/dist/http/server-tuning.d.ts +0 -9
- package/dist/http/server-tuning.js +0 -45
- package/dist/http/server.d.ts +0 -3
- package/dist/http/server.d.ts.map +0 -1
- package/dist/http/server.js +0 -291
- package/dist/http/server.js.map +0 -1
- package/dist/http/session-cleanup.d.ts +0 -2
- package/dist/http/session-cleanup.d.ts.map +0 -1
- package/dist/http/session-cleanup.js +0 -40
- package/dist/http/session-cleanup.js.map +0 -1
- package/dist/http/sessions.d.ts +0 -14
- package/dist/http/sessions.d.ts.map +0 -1
- package/dist/http/sessions.js +0 -63
- package/dist/http/sessions.js.map +0 -1
- package/dist/middleware/error-handler.d.ts +0 -2
- package/dist/middleware/error-handler.d.ts.map +0 -1
- package/dist/middleware/error-handler.js +0 -56
- package/dist/middleware/error-handler.js.map +0 -1
- package/dist/middleware/rate-limiter.d.ts +0 -16
- package/dist/middleware/rate-limiter.d.ts.map +0 -1
- package/dist/middleware/rate-limiter.js +0 -111
- package/dist/middleware/rate-limiter.js.map +0 -1
- package/dist/parsers/base-html-element-parser.d.ts +0 -43
- package/dist/parsers/base-html-element-parser.d.ts.map +0 -1
- package/dist/parsers/base-html-element-parser.js +0 -59
- package/dist/parsers/base-html-element-parser.js.map +0 -1
- package/dist/parsers/heading-element-parser.d.ts +0 -14
- package/dist/parsers/heading-element-parser.d.ts.map +0 -1
- package/dist/parsers/heading-element-parser.js +0 -26
- package/dist/parsers/heading-element-parser.js.map +0 -1
- package/dist/parsers/image-element-parser.d.ts +0 -16
- package/dist/parsers/image-element-parser.d.ts.map +0 -1
- package/dist/parsers/image-element-parser.js +0 -33
- package/dist/parsers/image-element-parser.js.map +0 -1
- package/dist/parsers/link-element-parser.d.ts +0 -15
- package/dist/parsers/link-element-parser.d.ts.map +0 -1
- package/dist/parsers/link-element-parser.js +0 -28
- package/dist/parsers/link-element-parser.js.map +0 -1
- package/dist/parsers/open-graph-parser.d.ts +0 -17
- package/dist/parsers/open-graph-parser.d.ts.map +0 -1
- package/dist/parsers/open-graph-parser.js +0 -41
- package/dist/parsers/open-graph-parser.js.map +0 -1
- package/dist/parsers/schema-org-parser.d.ts +0 -17
- package/dist/parsers/schema-org-parser.d.ts.map +0 -1
- package/dist/parsers/schema-org-parser.js +0 -32
- package/dist/parsers/schema-org-parser.js.map +0 -1
- package/dist/parsers/standard-meta-parser.d.ts +0 -18
- package/dist/parsers/standard-meta-parser.d.ts.map +0 -1
- package/dist/parsers/standard-meta-parser.js +0 -32
- package/dist/parsers/standard-meta-parser.js.map +0 -1
- package/dist/parsers/twitter-card-parser.d.ts +0 -17
- package/dist/parsers/twitter-card-parser.d.ts.map +0 -1
- package/dist/parsers/twitter-card-parser.js +0 -41
- package/dist/parsers/twitter-card-parser.js.map +0 -1
- package/dist/prompts/index.d.ts +0 -3
- package/dist/prompts/index.d.ts.map +0 -1
- package/dist/prompts/index.js +0 -73
- package/dist/prompts/index.js.map +0 -1
- package/dist/resources/cached-content-params.d.ts +0 -5
- package/dist/resources/cached-content-params.js +0 -36
- package/dist/resources/cached-content.d.ts +0 -2
- package/dist/resources/cached-content.d.ts.map +0 -1
- package/dist/resources/cached-content.js +0 -132
- package/dist/resources/cached-content.js.map +0 -1
- package/dist/resources/index.d.ts +0 -2
- package/dist/resources/index.d.ts.map +0 -1
- package/dist/resources/index.js +0 -4
- package/dist/resources/index.js.map +0 -1
- package/dist/server.d.ts +0 -3
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -94
- package/dist/server.js.map +0 -1
- package/dist/services/cache-events.d.ts +0 -8
- package/dist/services/cache-events.js +0 -19
- package/dist/services/cache-keys.d.ts +0 -7
- package/dist/services/cache-keys.js +0 -57
- package/dist/services/cache.d.ts +0 -17
- package/dist/services/cache.d.ts.map +0 -1
- package/dist/services/cache.js +0 -145
- package/dist/services/cache.js.map +0 -1
- package/dist/services/cache.service.d.ts +0 -52
- package/dist/services/cache.service.d.ts.map +0 -1
- package/dist/services/cache.service.js +0 -113
- package/dist/services/cache.service.js.map +0 -1
- package/dist/services/card-extractor.d.ts +0 -6
- package/dist/services/card-extractor.d.ts.map +0 -1
- package/dist/services/card-extractor.js +0 -199
- package/dist/services/card-extractor.js.map +0 -1
- package/dist/services/context.d.ts +0 -10
- package/dist/services/context.d.ts.map +0 -1
- package/dist/services/context.js +0 -14
- package/dist/services/context.js.map +0 -1
- package/dist/services/extractor.d.ts +0 -5
- package/dist/services/extractor.d.ts.map +0 -1
- package/dist/services/extractor.js +0 -142
- package/dist/services/extractor.js.map +0 -1
- package/dist/services/extractor.service.d.ts +0 -18
- package/dist/services/extractor.service.d.ts.map +0 -1
- package/dist/services/extractor.service.js +0 -75
- package/dist/services/extractor.service.js.map +0 -1
- package/dist/services/fetcher/agents.d.ts +0 -3
- package/dist/services/fetcher/agents.d.ts.map +0 -1
- package/dist/services/fetcher/agents.js +0 -100
- package/dist/services/fetcher/agents.js.map +0 -1
- package/dist/services/fetcher/dns-selection.d.ts +0 -2
- package/dist/services/fetcher/dns-selection.js +0 -72
- package/dist/services/fetcher/errors.d.ts +0 -4
- package/dist/services/fetcher/errors.d.ts.map +0 -1
- package/dist/services/fetcher/errors.js +0 -70
- package/dist/services/fetcher/errors.js.map +0 -1
- package/dist/services/fetcher/headers.d.ts +0 -2
- package/dist/services/fetcher/headers.d.ts.map +0 -1
- package/dist/services/fetcher/headers.js +0 -6
- package/dist/services/fetcher/headers.js.map +0 -1
- package/dist/services/fetcher/interceptors.d.ts +0 -10
- package/dist/services/fetcher/interceptors.d.ts.map +0 -1
- package/dist/services/fetcher/interceptors.js +0 -108
- package/dist/services/fetcher/interceptors.js.map +0 -1
- package/dist/services/fetcher/redirects.d.ts +0 -4
- package/dist/services/fetcher/redirects.d.ts.map +0 -1
- package/dist/services/fetcher/redirects.js +0 -78
- package/dist/services/fetcher/redirects.js.map +0 -1
- package/dist/services/fetcher/response.d.ts +0 -4
- package/dist/services/fetcher/response.d.ts.map +0 -1
- package/dist/services/fetcher/response.js +0 -104
- package/dist/services/fetcher/response.js.map +0 -1
- package/dist/services/fetcher/retry-policy.d.ts +0 -1
- package/dist/services/fetcher/retry-policy.d.ts.map +0 -1
- package/dist/services/fetcher/retry-policy.js +0 -131
- package/dist/services/fetcher/retry-policy.js.map +0 -1
- package/dist/services/fetcher.d.ts +0 -25
- package/dist/services/fetcher.d.ts.map +0 -1
- package/dist/services/fetcher.js +0 -607
- package/dist/services/fetcher.js.map +0 -1
- package/dist/services/fetcher.service.d.ts +0 -18
- package/dist/services/fetcher.service.d.ts.map +0 -1
- package/dist/services/fetcher.service.js +0 -122
- package/dist/services/fetcher.service.js.map +0 -1
- package/dist/services/fifo-queue.d.ts +0 -8
- package/dist/services/fifo-queue.js +0 -25
- package/dist/services/logger.d.ts +0 -5
- package/dist/services/logger.d.ts.map +0 -1
- package/dist/services/logger.js +0 -52
- package/dist/services/logger.js.map +0 -1
- package/dist/services/logger.service.d.ts +0 -5
- package/dist/services/logger.service.d.ts.map +0 -1
- package/dist/services/logger.service.js +0 -57
- package/dist/services/logger.service.js.map +0 -1
- package/dist/services/metadata-collector.d.ts +0 -2
- package/dist/services/metadata-collector.js +0 -80
- package/dist/services/parser.d.ts +0 -6
- package/dist/services/parser.d.ts.map +0 -1
- package/dist/services/parser.js +0 -278
- package/dist/services/parser.js.map +0 -1
- package/dist/services/parser.service.d.ts +0 -42
- package/dist/services/parser.service.d.ts.map +0 -1
- package/dist/services/parser.service.js +0 -209
- package/dist/services/parser.service.js.map +0 -1
- package/dist/services/session-manager.d.ts +0 -18
- package/dist/services/session-manager.d.ts.map +0 -1
- package/dist/services/session-manager.js +0 -73
- package/dist/services/session-manager.js.map +0 -1
- package/dist/services/telemetry.d.ts +0 -19
- package/dist/services/telemetry.js +0 -43
- package/dist/services/transform-worker-pool.d.ts +0 -11
- package/dist/services/transform-worker-pool.js +0 -244
- package/dist/services/transform-worker-types.d.ts +0 -32
- package/dist/services/transform-worker-types.js +0 -14
- package/dist/strategies/exponential-backoff-strategy.d.ts +0 -13
- package/dist/strategies/exponential-backoff-strategy.d.ts.map +0 -1
- package/dist/strategies/exponential-backoff-strategy.js +0 -32
- package/dist/strategies/exponential-backoff-strategy.js.map +0 -1
- package/dist/tools/handlers/fetch-links/link-extractor.d.ts +0 -4
- package/dist/tools/handlers/fetch-links/link-extractor.d.ts.map +0 -1
- package/dist/tools/handlers/fetch-links/link-extractor.js +0 -159
- package/dist/tools/handlers/fetch-links/link-extractor.js.map +0 -1
- package/dist/tools/handlers/fetch-links.tool.d.ts +0 -5
- package/dist/tools/handlers/fetch-links.tool.d.ts.map +0 -1
- package/dist/tools/handlers/fetch-links.tool.js +0 -98
- package/dist/tools/handlers/fetch-links.tool.js.map +0 -1
- package/dist/tools/handlers/fetch-markdown.tool.d.ts +0 -11
- package/dist/tools/handlers/fetch-markdown.tool.d.ts.map +0 -1
- package/dist/tools/handlers/fetch-markdown.tool.js +0 -97
- package/dist/tools/handlers/fetch-markdown.tool.js.map +0 -1
- package/dist/tools/handlers/fetch-single.shared.d.ts +0 -31
- package/dist/tools/handlers/fetch-single.shared.d.ts.map +0 -1
- package/dist/tools/handlers/fetch-single.shared.js +0 -223
- package/dist/tools/handlers/fetch-single.shared.js.map +0 -1
- package/dist/tools/handlers/fetch-url.tool.d.ts +0 -10
- package/dist/tools/handlers/fetch-url.tool.d.ts.map +0 -1
- package/dist/tools/handlers/fetch-url.tool.js +0 -119
- package/dist/tools/handlers/fetch-url.tool.js.map +0 -1
- package/dist/tools/handlers/fetch-urls/processor.d.ts +0 -13
- package/dist/tools/handlers/fetch-urls/processor.d.ts.map +0 -1
- package/dist/tools/handlers/fetch-urls/processor.js +0 -153
- package/dist/tools/handlers/fetch-urls/processor.js.map +0 -1
- package/dist/tools/handlers/fetch-urls/response.d.ts +0 -3
- package/dist/tools/handlers/fetch-urls/response.d.ts.map +0 -1
- package/dist/tools/handlers/fetch-urls/response.js +0 -79
- package/dist/tools/handlers/fetch-urls/response.js.map +0 -1
- package/dist/tools/handlers/fetch-urls/validation.d.ts +0 -5
- package/dist/tools/handlers/fetch-urls/validation.d.ts.map +0 -1
- package/dist/tools/handlers/fetch-urls/validation.js +0 -18
- package/dist/tools/handlers/fetch-urls/validation.js.map +0 -1
- package/dist/tools/handlers/fetch-urls.tool.d.ts +0 -5
- package/dist/tools/handlers/fetch-urls.tool.d.ts.map +0 -1
- package/dist/tools/handlers/fetch-urls.tool.js +0 -124
- package/dist/tools/handlers/fetch-urls.tool.js.map +0 -1
- package/dist/tools/index.d.ts +0 -3
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -37
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/schemas.d.ts +0 -12
- package/dist/tools/schemas.d.ts.map +0 -1
- package/dist/tools/schemas.js +0 -21
- package/dist/tools/schemas.js.map +0 -1
- package/dist/tools/utils/cache-vary.d.ts +0 -1
- package/dist/tools/utils/cache-vary.d.ts.map +0 -1
- package/dist/tools/utils/cache-vary.js +0 -12
- package/dist/tools/utils/cache-vary.js.map +0 -1
- package/dist/tools/utils/cached-markdown.d.ts +0 -5
- package/dist/tools/utils/cached-markdown.js +0 -46
- package/dist/tools/utils/common.d.ts +0 -5
- package/dist/tools/utils/common.d.ts.map +0 -1
- package/dist/tools/utils/common.js +0 -42
- package/dist/tools/utils/common.js.map +0 -1
- package/dist/tools/utils/content-shaping.d.ts +0 -4
- package/dist/tools/utils/content-shaping.js +0 -67
- package/dist/tools/utils/content-transform-async.d.ts +0 -6
- package/dist/tools/utils/content-transform-async.js +0 -33
- package/dist/tools/utils/content-transform-core.d.ts +0 -5
- package/dist/tools/utils/content-transform-core.js +0 -180
- package/dist/tools/utils/content-transform-workers.d.ts +0 -1
- package/dist/tools/utils/content-transform-workers.js +0 -1
- package/dist/tools/utils/content-transform.d.ts +0 -3
- package/dist/tools/utils/content-transform.d.ts.map +0 -1
- package/dist/tools/utils/content-transform.js +0 -41
- package/dist/tools/utils/content-transform.js.map +0 -1
- package/dist/tools/utils/fetch-pipeline.d.ts +0 -2
- package/dist/tools/utils/fetch-pipeline.d.ts.map +0 -1
- package/dist/tools/utils/fetch-pipeline.js +0 -98
- package/dist/tools/utils/fetch-pipeline.js.map +0 -1
- package/dist/tools/utils/frontmatter.d.ts +0 -3
- package/dist/tools/utils/frontmatter.js +0 -73
- package/dist/tools/utils/index.d.ts +0 -4
- package/dist/tools/utils/index.d.ts.map +0 -1
- package/dist/tools/utils/index.js +0 -3
- package/dist/tools/utils/index.js.map +0 -1
- package/dist/tools/utils/inline-content.d.ts +0 -10
- package/dist/tools/utils/inline-content.d.ts.map +0 -1
- package/dist/tools/utils/inline-content.js +0 -35
- package/dist/tools/utils/inline-content.js.map +0 -1
- package/dist/tools/utils/markdown-heuristics.d.ts +0 -1
- package/dist/tools/utils/markdown-heuristics.js +0 -19
- package/dist/tools/utils/markdown-signals.d.ts +0 -1
- package/dist/tools/utils/markdown-signals.js +0 -19
- package/dist/tools/utils/markdown-toc.d.ts +0 -3
- package/dist/tools/utils/markdown-toc.d.ts.map +0 -1
- package/dist/tools/utils/markdown-toc.js +0 -35
- package/dist/tools/utils/markdown-toc.js.map +0 -1
- package/dist/tools/utils/raw-markdown-frontmatter.d.ts +0 -3
- package/dist/tools/utils/raw-markdown-frontmatter.js +0 -73
- package/dist/tools/utils/raw-markdown.d.ts +0 -6
- package/dist/tools/utils/raw-markdown.js +0 -149
- package/dist/tools/utils/response-builder.d.ts +0 -3
- package/dist/tools/utils/response-builder.d.ts.map +0 -1
- package/dist/tools/utils/response-builder.js +0 -24
- package/dist/tools/utils/response-builder.js.map +0 -1
- package/dist/tools/utils/tool-response.d.ts +0 -9
- package/dist/tools/utils/tool-response.d.ts.map +0 -1
- package/dist/tools/utils/tool-response.js +0 -19
- package/dist/tools/utils/tool-response.js.map +0 -1
- package/dist/transformers/jsonl.transformer.d.ts +0 -2
- package/dist/transformers/jsonl.transformer.d.ts.map +0 -1
- package/dist/transformers/jsonl.transformer.js +0 -75
- package/dist/transformers/jsonl.transformer.js.map +0 -1
- package/dist/transformers/markdown/fenced-code-rule.d.ts +0 -2
- package/dist/transformers/markdown/fenced-code-rule.js +0 -38
- package/dist/transformers/markdown/frontmatter.d.ts +0 -2
- package/dist/transformers/markdown/frontmatter.js +0 -45
- package/dist/transformers/markdown/noise-rule.d.ts +0 -2
- package/dist/transformers/markdown/noise-rule.js +0 -80
- package/dist/transformers/markdown/turndown-instance.d.ts +0 -2
- package/dist/transformers/markdown/turndown-instance.js +0 -19
- package/dist/transformers/markdown.d.ts +0 -5
- package/dist/transformers/markdown.js +0 -314
- package/dist/transformers/markdown.transformer.d.ts +0 -2
- package/dist/transformers/markdown.transformer.d.ts.map +0 -1
- package/dist/transformers/markdown.transformer.js +0 -14
- package/dist/transformers/markdown.transformer.js.map +0 -1
- package/dist/types/content.types.d.ts +0 -63
- package/dist/types/content.types.d.ts.map +0 -1
- package/dist/types/content.types.js +0 -2
- package/dist/types/content.types.js.map +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/types/schemas.d.ts +0 -49
- package/dist/types/schemas.d.ts.map +0 -1
- package/dist/types/schemas.js +0 -5
- package/dist/types/schemas.js.map +0 -1
- package/dist/utils/cached-payload.d.ts +0 -7
- package/dist/utils/cached-payload.js +0 -36
- package/dist/utils/cancellation.d.ts +0 -1
- package/dist/utils/cancellation.js +0 -18
- package/dist/utils/code-language-bash.d.ts +0 -1
- package/dist/utils/code-language-bash.js +0 -48
- package/dist/utils/code-language-core.d.ts +0 -2
- package/dist/utils/code-language-core.js +0 -13
- package/dist/utils/code-language-detectors.d.ts +0 -5
- package/dist/utils/code-language-detectors.js +0 -142
- package/dist/utils/code-language-helpers.d.ts +0 -5
- package/dist/utils/code-language-helpers.js +0 -62
- package/dist/utils/code-language-parsing.d.ts +0 -5
- package/dist/utils/code-language-parsing.js +0 -62
- package/dist/utils/code-language.d.ts +0 -2
- package/dist/utils/code-language.d.ts.map +0 -1
- package/dist/utils/code-language.js +0 -260
- package/dist/utils/code-language.js.map +0 -1
- package/dist/utils/concurrency.d.ts +0 -3
- package/dist/utils/concurrency.d.ts.map +0 -1
- package/dist/utils/concurrency.js +0 -38
- package/dist/utils/concurrency.js.map +0 -1
- package/dist/utils/content-cleaner.d.ts +0 -5
- package/dist/utils/content-cleaner.d.ts.map +0 -1
- package/dist/utils/content-cleaner.js +0 -77
- package/dist/utils/content-cleaner.js.map +0 -1
- package/dist/utils/crypto.d.ts +0 -2
- package/dist/utils/crypto.d.ts.map +0 -1
- package/dist/utils/crypto.js +0 -32
- package/dist/utils/crypto.js.map +0 -1
- package/dist/utils/download-url.d.ts +0 -16
- package/dist/utils/download-url.d.ts.map +0 -1
- package/dist/utils/download-url.js +0 -30
- package/dist/utils/download-url.js.map +0 -1
- package/dist/utils/error-details.d.ts +0 -3
- package/dist/utils/error-details.js +0 -12
- package/dist/utils/error-utils.d.ts +0 -3
- package/dist/utils/error-utils.d.ts.map +0 -1
- package/dist/utils/error-utils.js +0 -12
- package/dist/utils/error-utils.js.map +0 -1
- package/dist/utils/filename-generator.d.ts +0 -1
- package/dist/utils/filename-generator.d.ts.map +0 -1
- package/dist/utils/filename-generator.js +0 -81
- package/dist/utils/filename-generator.js.map +0 -1
- package/dist/utils/guards.d.ts +0 -1
- package/dist/utils/guards.js +0 -3
- package/dist/utils/header-normalizer.d.ts +0 -5
- package/dist/utils/header-normalizer.d.ts.map +0 -1
- package/dist/utils/header-normalizer.js +0 -31
- package/dist/utils/header-normalizer.js.map +0 -1
- package/dist/utils/host-normalizer.d.ts +0 -1
- package/dist/utils/host-normalizer.js +0 -37
- package/dist/utils/html-truncator.d.ts +0 -1
- package/dist/utils/html-truncator.d.ts.map +0 -1
- package/dist/utils/html-truncator.js +0 -13
- package/dist/utils/html-truncator.js.map +0 -1
- package/dist/utils/ip-address.d.ts +0 -4
- package/dist/utils/ip-address.js +0 -6
- package/dist/utils/language-detector.d.ts +0 -2
- package/dist/utils/language-detector.d.ts.map +0 -1
- package/dist/utils/language-detector.js +0 -39
- package/dist/utils/language-detector.js.map +0 -1
- package/dist/utils/sanitizer.d.ts +0 -2
- package/dist/utils/sanitizer.d.ts.map +0 -1
- package/dist/utils/sanitizer.js +0 -20
- package/dist/utils/sanitizer.js.map +0 -1
- package/dist/utils/tool-error-handler.d.ts +0 -3
- package/dist/utils/tool-error-handler.d.ts.map +0 -1
- package/dist/utils/tool-error-handler.js +0 -31
- package/dist/utils/tool-error-handler.js.map +0 -1
- package/dist/utils/url-redactor.d.ts +0 -1
- package/dist/utils/url-redactor.js +0 -13
- package/dist/utils/url-sanitizer.d.ts +0 -2
- package/dist/utils/url-sanitizer.d.ts.map +0 -1
- package/dist/utils/url-sanitizer.js +0 -12
- package/dist/utils/url-sanitizer.js.map +0 -1
- package/dist/utils/url-transformer.d.ts +0 -7
- package/dist/utils/url-transformer.js +0 -147
- package/dist/utils/url-validator.d.ts +0 -6
- package/dist/utils/url-validator.d.ts.map +0 -1
- package/dist/utils/url-validator.js +0 -156
- package/dist/utils/url-validator.js.map +0 -1
- package/dist/workers/content-transform.worker.d.ts +0 -1
- package/dist/workers/content-transform.worker.js +0 -40
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { TRUNCATION_MARKER } from '../../config/formatting.js';
|
|
2
|
-
import { config } from '../../config/index.js';
|
|
3
|
-
import { toResourceUri } from '../../services/cache-keys.js';
|
|
4
|
-
export function applyInlineContentLimit(content, cacheKey) {
|
|
5
|
-
const contentSize = content.length;
|
|
6
|
-
const inlineLimit = config.constants.maxInlineContentChars;
|
|
7
|
-
if (contentSize <= inlineLimit) {
|
|
8
|
-
return { content, contentSize };
|
|
9
|
-
}
|
|
10
|
-
const resourceUri = resolveResourceUri(cacheKey);
|
|
11
|
-
if (!resourceUri) {
|
|
12
|
-
return buildTruncatedFallback(content, contentSize, inlineLimit);
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
contentSize,
|
|
16
|
-
resourceUri,
|
|
17
|
-
resourceMimeType: 'text/markdown',
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function resolveResourceUri(cacheKey) {
|
|
21
|
-
if (!config.cache.enabled || !cacheKey)
|
|
22
|
-
return null;
|
|
23
|
-
return toResourceUri(cacheKey);
|
|
24
|
-
}
|
|
25
|
-
function buildTruncatedFallback(content, contentSize, inlineLimit) {
|
|
26
|
-
const maxContentLength = Math.max(0, inlineLimit - TRUNCATION_MARKER.length);
|
|
27
|
-
const truncatedContent = content.length > inlineLimit
|
|
28
|
-
? `${content.substring(0, maxContentLength)}${TRUNCATION_MARKER}`
|
|
29
|
-
: content;
|
|
30
|
-
return {
|
|
31
|
-
content: truncatedContent,
|
|
32
|
-
contentSize,
|
|
33
|
-
truncated: true,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inline-content.js","sourceRoot":"","sources":["../../../src/tools/utils/inline-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,KAAK,KAAK,MAAM,yBAAyB,CAAC;AAajD,MAAM,UAAU,uBAAuB,CACrC,OAAe,EACf,QAAuB,EACvB,MAA2B;IAE3B,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IACnC,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC;IAE3D,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;QAC/B,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IAClC,CAAC;IAED,MAAM,WAAW,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,sBAAsB,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IACnE,CAAC;IAED,OAAO;QACL,WAAW;QACX,WAAW;QACX,gBAAgB,EAAE,uBAAuB,CAAC,MAAM,CAAC;KAClD,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAuB;IACjD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IACpD,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,uBAAuB,CAAC,MAA2B;IAC1D,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,mBAAmB,CAAC;AACvE,CAAC;AAED,SAAS,sBAAsB,CAC7B,OAAe,EACf,WAAmB,EACnB,WAAmB;IAEnB,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC7E,MAAM,gBAAgB,GACpB,OAAO,CAAC,MAAM,GAAG,WAAW;QAC1B,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB,CAAC,GAAG,iBAAiB,EAAE;QACjE,CAAC,CAAC,OAAO,CAAC;IAEd,OAAO;QACL,OAAO,EAAE,gBAAgB;QACzB,WAAW;QACX,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function looksLikeMarkdown(content: string): boolean;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const HEADING_PATTERN = /^#{1,6}\s/m;
|
|
2
|
-
const LIST_PATTERN = /^(?:[-*+])\s/m;
|
|
3
|
-
export function looksLikeMarkdown(content) {
|
|
4
|
-
return (containsMarkdownHeading(content) ||
|
|
5
|
-
containsMarkdownList(content) ||
|
|
6
|
-
containsFencedCodeBlock(content));
|
|
7
|
-
}
|
|
8
|
-
function containsMarkdownHeading(content) {
|
|
9
|
-
return HEADING_PATTERN.test(content);
|
|
10
|
-
}
|
|
11
|
-
function containsMarkdownList(content) {
|
|
12
|
-
return LIST_PATTERN.test(content);
|
|
13
|
-
}
|
|
14
|
-
function containsFencedCodeBlock(content) {
|
|
15
|
-
const first = content.indexOf('```');
|
|
16
|
-
if (first === -1)
|
|
17
|
-
return false;
|
|
18
|
-
return content.includes('```', first + 3);
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function looksLikeMarkdown(content: string): boolean;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const HEADING_PATTERN = /^#{1,6}\s/m;
|
|
2
|
-
const LIST_PATTERN = /^(?:[-*+])\s/m;
|
|
3
|
-
export function looksLikeMarkdown(content) {
|
|
4
|
-
return (containsMarkdownHeading(content) ||
|
|
5
|
-
containsMarkdownList(content) ||
|
|
6
|
-
containsFencedCodeBlock(content));
|
|
7
|
-
}
|
|
8
|
-
function containsMarkdownHeading(content) {
|
|
9
|
-
return HEADING_PATTERN.test(content);
|
|
10
|
-
}
|
|
11
|
-
function containsMarkdownList(content) {
|
|
12
|
-
return LIST_PATTERN.test(content);
|
|
13
|
-
}
|
|
14
|
-
function containsFencedCodeBlock(content) {
|
|
15
|
-
const first = content.indexOf('```');
|
|
16
|
-
if (first === -1)
|
|
17
|
-
return false;
|
|
18
|
-
return content.includes('```', first + 3);
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-toc.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/markdown-toc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAetD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,CAYvD"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { stripMarkdownLinks } from '../../utils/content-cleaner.js';
|
|
2
|
-
function slugify(text) {
|
|
3
|
-
const cleanText = stripMarkdownLinks(text);
|
|
4
|
-
return cleanText
|
|
5
|
-
.toLowerCase()
|
|
6
|
-
.replace(/[^\w\s-]/g, '')
|
|
7
|
-
.replace(/\s+/g, '-')
|
|
8
|
-
.replace(/--+/g, '-')
|
|
9
|
-
.trim();
|
|
10
|
-
}
|
|
11
|
-
export function extractToc(markdown) {
|
|
12
|
-
const headingRegex = /^(#{1,6})\s+(.+)$/gm;
|
|
13
|
-
const toc = [];
|
|
14
|
-
for (const match of markdown.matchAll(headingRegex)) {
|
|
15
|
-
const entry = buildTocEntry(match);
|
|
16
|
-
if (entry) {
|
|
17
|
-
toc.push(entry);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return toc;
|
|
21
|
-
}
|
|
22
|
-
function buildTocEntry(match) {
|
|
23
|
-
const hashMarks = match[1];
|
|
24
|
-
const rawText = match[2];
|
|
25
|
-
if (!hashMarks || !rawText) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
const text = stripMarkdownLinks(rawText.trim());
|
|
29
|
-
return {
|
|
30
|
-
level: hashMarks.length,
|
|
31
|
-
text,
|
|
32
|
-
slug: slugify(rawText),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=markdown-toc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-toc.js","sourceRoot":"","sources":["../../../src/tools/utils/markdown-toc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,SAAS,OAAO,CAAC,IAAY;IAC3B,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAE3C,OAAO,SAAS;SACb,WAAW,EAAE;SACb,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;SACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,MAAM,YAAY,GAAG,qBAAqB,CAAC;IAC3C,MAAM,GAAG,GAAe,EAAE,CAAC;IAE3B,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,EAAE,CAAC;YACV,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,aAAa,CAAC,KAAsB;IAC3C,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAEzB,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAChD,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,MAAM;QACvB,IAAI;QACJ,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC;KACvB,CAAC;AACJ,CAAC"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
function detectLineEnding(content) {
|
|
2
|
-
return content.includes('\r\n') ? '\r\n' : '\n';
|
|
3
|
-
}
|
|
4
|
-
function findFrontmatterLines(content) {
|
|
5
|
-
const lineEnding = detectLineEnding(content);
|
|
6
|
-
const lines = content.split(lineEnding);
|
|
7
|
-
if (lines[0] !== '---')
|
|
8
|
-
return null;
|
|
9
|
-
const endIndex = lines.indexOf('---', 1);
|
|
10
|
-
if (endIndex === -1)
|
|
11
|
-
return null;
|
|
12
|
-
return { lineEnding, lines, endIndex };
|
|
13
|
-
}
|
|
14
|
-
function stripOptionalQuotes(value) {
|
|
15
|
-
const trimmed = value.trim();
|
|
16
|
-
if (trimmed.length < 2)
|
|
17
|
-
return trimmed;
|
|
18
|
-
const first = trimmed[0];
|
|
19
|
-
const last = trimmed[trimmed.length - 1];
|
|
20
|
-
if ((first === '"' && last === '"') || (first === "'" && last === "'")) {
|
|
21
|
-
return trimmed.slice(1, -1).trim();
|
|
22
|
-
}
|
|
23
|
-
return trimmed;
|
|
24
|
-
}
|
|
25
|
-
function parseFrontmatterEntry(line) {
|
|
26
|
-
const trimmed = line.trim();
|
|
27
|
-
if (!trimmed)
|
|
28
|
-
return null;
|
|
29
|
-
const separatorIndex = trimmed.indexOf(':');
|
|
30
|
-
if (separatorIndex <= 0)
|
|
31
|
-
return null;
|
|
32
|
-
const key = trimmed.slice(0, separatorIndex).trim().toLowerCase();
|
|
33
|
-
const value = trimmed.slice(separatorIndex + 1);
|
|
34
|
-
return { key, value };
|
|
35
|
-
}
|
|
36
|
-
function isTitleKey(key) {
|
|
37
|
-
return key === 'title' || key === 'name';
|
|
38
|
-
}
|
|
39
|
-
export function extractTitleFromRawMarkdown(content) {
|
|
40
|
-
const frontmatter = findFrontmatterLines(content);
|
|
41
|
-
if (!frontmatter)
|
|
42
|
-
return undefined;
|
|
43
|
-
const { lines, endIndex } = frontmatter;
|
|
44
|
-
const entry = lines
|
|
45
|
-
.slice(1, endIndex)
|
|
46
|
-
.map((line) => parseFrontmatterEntry(line))
|
|
47
|
-
.find((parsed) => parsed !== null && isTitleKey(parsed.key));
|
|
48
|
-
if (!entry)
|
|
49
|
-
return undefined;
|
|
50
|
-
const value = stripOptionalQuotes(entry.value);
|
|
51
|
-
return value || undefined;
|
|
52
|
-
}
|
|
53
|
-
export function addSourceToMarkdown(content, url) {
|
|
54
|
-
const frontmatter = findFrontmatterLines(content);
|
|
55
|
-
if (!frontmatter) {
|
|
56
|
-
return `---\nsource: "${url}"\n---\n\n${content}`;
|
|
57
|
-
}
|
|
58
|
-
const { lineEnding, lines, endIndex } = frontmatter;
|
|
59
|
-
const bodyLines = lines.slice(1, endIndex);
|
|
60
|
-
const hasSource = bodyLines.some((line) => line.trimStart().toLowerCase().startsWith('source:'));
|
|
61
|
-
if (hasSource)
|
|
62
|
-
return content;
|
|
63
|
-
const updatedLines = [
|
|
64
|
-
lines[0],
|
|
65
|
-
...bodyLines,
|
|
66
|
-
`source: "${url}"`,
|
|
67
|
-
...lines.slice(endIndex),
|
|
68
|
-
];
|
|
69
|
-
return updatedLines.join(lineEnding);
|
|
70
|
-
}
|
|
71
|
-
export function hasFrontmatter(trimmed) {
|
|
72
|
-
return trimmed.startsWith('---\n') || trimmed.startsWith('---\r\n');
|
|
73
|
-
}
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { logDebug } from '../../services/logger.js';
|
|
2
|
-
import { isRawTextContentUrl } from '../../utils/url-transformer.js';
|
|
3
|
-
const HEADING_PATTERN = /^#{1,6}\s/m;
|
|
4
|
-
const LIST_PATTERN = /^(?:[-*+])\s/m;
|
|
5
|
-
const HTML_DOCUMENT_PATTERN = /^(<!doctype|<html)/i;
|
|
6
|
-
function containsMarkdownHeading(content) {
|
|
7
|
-
return HEADING_PATTERN.test(content);
|
|
8
|
-
}
|
|
9
|
-
function containsMarkdownList(content) {
|
|
10
|
-
return LIST_PATTERN.test(content);
|
|
11
|
-
}
|
|
12
|
-
function containsFencedCodeBlock(content) {
|
|
13
|
-
const first = content.indexOf('```');
|
|
14
|
-
if (first === -1)
|
|
15
|
-
return false;
|
|
16
|
-
return content.includes('```', first + 3);
|
|
17
|
-
}
|
|
18
|
-
function looksLikeMarkdown(content) {
|
|
19
|
-
return (containsMarkdownHeading(content) ||
|
|
20
|
-
containsMarkdownList(content) ||
|
|
21
|
-
containsFencedCodeBlock(content));
|
|
22
|
-
}
|
|
23
|
-
function detectLineEnding(content) {
|
|
24
|
-
return content.includes('\r\n') ? '\r\n' : '\n';
|
|
25
|
-
}
|
|
26
|
-
function findFrontmatterLines(content) {
|
|
27
|
-
const lineEnding = detectLineEnding(content);
|
|
28
|
-
const lines = content.split(lineEnding);
|
|
29
|
-
if (lines[0] !== '---')
|
|
30
|
-
return null;
|
|
31
|
-
const endIndex = lines.indexOf('---', 1);
|
|
32
|
-
if (endIndex === -1)
|
|
33
|
-
return null;
|
|
34
|
-
return { lineEnding, lines, endIndex };
|
|
35
|
-
}
|
|
36
|
-
function stripOptionalQuotes(value) {
|
|
37
|
-
const trimmed = value.trim();
|
|
38
|
-
if (trimmed.length < 2)
|
|
39
|
-
return trimmed;
|
|
40
|
-
const first = trimmed[0];
|
|
41
|
-
const last = trimmed[trimmed.length - 1];
|
|
42
|
-
if ((first === '"' && last === '"') || (first === "'" && last === "'")) {
|
|
43
|
-
return trimmed.slice(1, -1).trim();
|
|
44
|
-
}
|
|
45
|
-
return trimmed;
|
|
46
|
-
}
|
|
47
|
-
function parseFrontmatterEntry(line) {
|
|
48
|
-
const trimmed = line.trim();
|
|
49
|
-
if (!trimmed)
|
|
50
|
-
return null;
|
|
51
|
-
const separatorIndex = trimmed.indexOf(':');
|
|
52
|
-
if (separatorIndex <= 0)
|
|
53
|
-
return null;
|
|
54
|
-
const key = trimmed.slice(0, separatorIndex).trim().toLowerCase();
|
|
55
|
-
const value = trimmed.slice(separatorIndex + 1);
|
|
56
|
-
return { key, value };
|
|
57
|
-
}
|
|
58
|
-
function isTitleKey(key) {
|
|
59
|
-
return key === 'title' || key === 'name';
|
|
60
|
-
}
|
|
61
|
-
function extractTitleFromRawMarkdown(content) {
|
|
62
|
-
const frontmatter = findFrontmatterLines(content);
|
|
63
|
-
if (!frontmatter)
|
|
64
|
-
return undefined;
|
|
65
|
-
const { lines, endIndex } = frontmatter;
|
|
66
|
-
const entry = lines
|
|
67
|
-
.slice(1, endIndex)
|
|
68
|
-
.map((line) => parseFrontmatterEntry(line))
|
|
69
|
-
.find((parsed) => parsed !== null && isTitleKey(parsed.key));
|
|
70
|
-
if (!entry)
|
|
71
|
-
return undefined;
|
|
72
|
-
const value = stripOptionalQuotes(entry.value);
|
|
73
|
-
return value || undefined;
|
|
74
|
-
}
|
|
75
|
-
function addSourceToMarkdown(content, url) {
|
|
76
|
-
const frontmatter = findFrontmatterLines(content);
|
|
77
|
-
if (!frontmatter) {
|
|
78
|
-
return `---\nsource: "${url}"\n---\n\n${content}`;
|
|
79
|
-
}
|
|
80
|
-
const { lineEnding, lines, endIndex } = frontmatter;
|
|
81
|
-
const bodyLines = lines.slice(1, endIndex);
|
|
82
|
-
const hasSource = bodyLines.some((line) => line.trimStart().toLowerCase().startsWith('source:'));
|
|
83
|
-
if (hasSource)
|
|
84
|
-
return content;
|
|
85
|
-
const updatedLines = [
|
|
86
|
-
lines[0],
|
|
87
|
-
...bodyLines,
|
|
88
|
-
`source: "${url}"`,
|
|
89
|
-
...lines.slice(endIndex),
|
|
90
|
-
];
|
|
91
|
-
return updatedLines.join(lineEnding);
|
|
92
|
-
}
|
|
93
|
-
function hasFrontmatter(trimmed) {
|
|
94
|
-
return trimmed.startsWith('---\n') || trimmed.startsWith('---\r\n');
|
|
95
|
-
}
|
|
96
|
-
function looksLikeHtmlDocument(trimmed) {
|
|
97
|
-
return HTML_DOCUMENT_PATTERN.test(trimmed);
|
|
98
|
-
}
|
|
99
|
-
function countCommonHtmlTags(content) {
|
|
100
|
-
const matches = content.match(/<(html|head|body|div|span|script|style|meta|link)\b/gi) ??
|
|
101
|
-
[];
|
|
102
|
-
return matches.length;
|
|
103
|
-
}
|
|
104
|
-
function isRawTextContent(content) {
|
|
105
|
-
const trimmed = content.trim();
|
|
106
|
-
const isHtmlDocument = looksLikeHtmlDocument(trimmed);
|
|
107
|
-
const hasMarkdownFrontmatter = hasFrontmatter(trimmed);
|
|
108
|
-
const hasTooManyHtmlTags = countCommonHtmlTags(content) > 2;
|
|
109
|
-
const isMarkdown = looksLikeMarkdown(content);
|
|
110
|
-
return (!isHtmlDocument &&
|
|
111
|
-
(hasMarkdownFrontmatter || (!hasTooManyHtmlTags && isMarkdown)));
|
|
112
|
-
}
|
|
113
|
-
function isLikelyHtmlContent(content) {
|
|
114
|
-
const trimmed = content.trim();
|
|
115
|
-
if (!trimmed)
|
|
116
|
-
return false;
|
|
117
|
-
if (looksLikeHtmlDocument(trimmed))
|
|
118
|
-
return true;
|
|
119
|
-
return countCommonHtmlTags(content) > 2;
|
|
120
|
-
}
|
|
121
|
-
function shouldPreserveRawContent(url, content) {
|
|
122
|
-
if (isRawTextContentUrl(url)) {
|
|
123
|
-
return !isLikelyHtmlContent(content);
|
|
124
|
-
}
|
|
125
|
-
return isRawTextContent(content);
|
|
126
|
-
}
|
|
127
|
-
function buildRawMarkdownPayload({ rawContent, url, includeMetadata, }) {
|
|
128
|
-
const title = extractTitleFromRawMarkdown(rawContent);
|
|
129
|
-
const content = includeMetadata
|
|
130
|
-
? addSourceToMarkdown(rawContent, url)
|
|
131
|
-
: rawContent;
|
|
132
|
-
return { content, title };
|
|
133
|
-
}
|
|
134
|
-
export function tryTransformRawContent({ html, url, includeMetadata, }) {
|
|
135
|
-
if (!shouldPreserveRawContent(url, html)) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
logDebug('Preserving raw markdown content', { url: url.substring(0, 80) });
|
|
139
|
-
const { content, title } = buildRawMarkdownPayload({
|
|
140
|
-
rawContent: html,
|
|
141
|
-
url,
|
|
142
|
-
includeMetadata,
|
|
143
|
-
});
|
|
144
|
-
return {
|
|
145
|
-
markdown: content,
|
|
146
|
-
title,
|
|
147
|
-
truncated: false,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-builder.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/response-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,cAAc,EACd,YAAY,EACb,MAAM,uBAAuB,CAAC;AAE/B,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,cAAc,EAAE,GACxB,YAAY,CAAC,oBAAoB,CAAC,CA2BpC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export function createBatchResponse(results) {
|
|
2
|
-
const summary = {
|
|
3
|
-
total: results.length,
|
|
4
|
-
successful: results.filter((r) => r.success).length,
|
|
5
|
-
failed: results.filter((r) => !r.success).length,
|
|
6
|
-
cached: results.filter((r) => r.cached).length,
|
|
7
|
-
totalContentBlocks: results.reduce((sum, r) => sum + (r.contentBlocks ?? 0), 0),
|
|
8
|
-
};
|
|
9
|
-
const structuredContent = {
|
|
10
|
-
results,
|
|
11
|
-
summary,
|
|
12
|
-
fetchedAt: new Date().toISOString(),
|
|
13
|
-
};
|
|
14
|
-
return {
|
|
15
|
-
content: [
|
|
16
|
-
{
|
|
17
|
-
type: 'text',
|
|
18
|
-
text: JSON.stringify(structuredContent, null, 2),
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
structuredContent,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=response-builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"response-builder.js","sourceRoot":"","sources":["../../../src/tools/utils/response-builder.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,mBAAmB,CACjC,OAAyB;IAEzB,MAAM,OAAO,GAAiB;QAC5B,KAAK,EAAE,OAAO,CAAC,MAAM;QACrB,UAAU,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM;QACnD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM;QAChD,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM;QAC9C,kBAAkB,EAAE,OAAO,CAAC,MAAM,CAChC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,EACxC,CAAC,CACF;KACF,CAAC;IAEF,MAAM,iBAAiB,GAAyB;QAC9C,OAAO;QACP,OAAO;QACP,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;IAEF,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;aACjD;SACF;QACD,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ToolResponseBase } from '../../config/types.js';
|
|
2
|
-
export interface ResourceLinkDetails {
|
|
3
|
-
readonly uri: string;
|
|
4
|
-
readonly name: string;
|
|
5
|
-
readonly mimeType?: string;
|
|
6
|
-
readonly description?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function buildJsonToolResponse<T extends Record<string, unknown>>(structuredContent: T, fromCache: boolean, resourceLink?: ResourceLinkDetails): ToolResponseBase;
|
|
9
|
-
//# sourceMappingURL=tool-response.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-response.d.ts","sourceRoot":"","sources":["../../../src/tools/utils/tool-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrE,iBAAiB,EAAE,CAAC,EACpB,SAAS,EAAE,OAAO,EAClB,YAAY,CAAC,EAAE,mBAAmB,GACjC,gBAAgB,CAuBlB"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export function buildJsonToolResponse(structuredContent, fromCache, resourceLink) {
|
|
2
|
-
const jsonOutput = JSON.stringify(structuredContent, fromCache ? undefined : null, fromCache ? undefined : 2);
|
|
3
|
-
const content = [
|
|
4
|
-
{ type: 'text', text: jsonOutput },
|
|
5
|
-
...(resourceLink
|
|
6
|
-
? [
|
|
7
|
-
{
|
|
8
|
-
type: 'resource_link',
|
|
9
|
-
uri: resourceLink.uri,
|
|
10
|
-
name: resourceLink.name,
|
|
11
|
-
mimeType: resourceLink.mimeType,
|
|
12
|
-
description: resourceLink.description,
|
|
13
|
-
},
|
|
14
|
-
]
|
|
15
|
-
: []),
|
|
16
|
-
];
|
|
17
|
-
return { content, structuredContent };
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=tool-response.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool-response.js","sourceRoot":"","sources":["../../../src/tools/utils/tool-response.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,qBAAqB,CACnC,iBAAoB,EACpB,SAAkB,EAClB,YAAkC;IAElC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAC/B,iBAAiB,EACjB,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAC5B,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAC1B,CAAC;IAEF,MAAM,OAAO,GAAG;QACd,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,UAAU,EAAE;QAC3C,GAAG,CAAC,YAAY;YACd,CAAC,CAAC;gBACE;oBACE,IAAI,EAAE,eAAwB;oBAC9B,GAAG,EAAE,YAAY,CAAC,GAAG;oBACrB,IAAI,EAAE,YAAY,CAAC,IAAI;oBACvB,QAAQ,EAAE,YAAY,CAAC,QAAQ;oBAC/B,WAAW,EAAE,YAAY,CAAC,WAAW;iBACtC;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl.transformer.d.ts","sourceRoot":"","sources":["../../src/transformers/jsonl.transformer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACd,MAAM,4BAA4B,CAAC;AAkEpC,wBAAgB,OAAO,CACrB,MAAM,EAAE,SAAS,iBAAiB,EAAE,EACpC,QAAQ,CAAC,EAAE,aAAa,GACvB,MAAM,CAGR"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { joinLines } from '../config/formatting.js';
|
|
2
|
-
import { config } from '../config/index.js';
|
|
3
|
-
import { truncateText } from '../utils/sanitizer.js';
|
|
4
|
-
const TEXT_BLOCK_TYPES = new Set([
|
|
5
|
-
'paragraph',
|
|
6
|
-
'heading',
|
|
7
|
-
'code',
|
|
8
|
-
'blockquote',
|
|
9
|
-
]);
|
|
10
|
-
function isTextBlock(block) {
|
|
11
|
-
return 'text' in block;
|
|
12
|
-
}
|
|
13
|
-
function isListBlock(block) {
|
|
14
|
-
return block.type === 'list';
|
|
15
|
-
}
|
|
16
|
-
function truncateTextBlock(block, maxLength) {
|
|
17
|
-
const truncated = truncateText(block.text, maxLength);
|
|
18
|
-
return truncated === block.text ? block : { ...block, text: truncated };
|
|
19
|
-
}
|
|
20
|
-
function truncateListBlock(block, maxLength) {
|
|
21
|
-
const truncatedItems = block.items.map((item) => truncateText(item, maxLength));
|
|
22
|
-
const hasChanges = truncatedItems.some((item, index) => item !== block.items[index]);
|
|
23
|
-
return hasChanges ? { ...block, items: truncatedItems } : block;
|
|
24
|
-
}
|
|
25
|
-
function truncateBlock(block) {
|
|
26
|
-
const maxLength = config.extraction.maxBlockLength;
|
|
27
|
-
if (TEXT_BLOCK_TYPES.has(block.type) && isTextBlock(block)) {
|
|
28
|
-
return truncateTextBlock(block, maxLength);
|
|
29
|
-
}
|
|
30
|
-
if (isListBlock(block)) {
|
|
31
|
-
return truncateListBlock(block, maxLength);
|
|
32
|
-
}
|
|
33
|
-
return block;
|
|
34
|
-
}
|
|
35
|
-
function serializeBlock(block) {
|
|
36
|
-
try {
|
|
37
|
-
return JSON.stringify(truncateBlock(block));
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export function toJsonl(blocks, metadata) {
|
|
44
|
-
const lines = collectJsonlLines(blocks, metadata);
|
|
45
|
-
return joinLines(lines);
|
|
46
|
-
}
|
|
47
|
-
function collectJsonlLines(blocks, metadata) {
|
|
48
|
-
const lines = [];
|
|
49
|
-
const header = serializeMetadata(metadata);
|
|
50
|
-
if (header) {
|
|
51
|
-
lines.push(header);
|
|
52
|
-
}
|
|
53
|
-
for (const block of blocks) {
|
|
54
|
-
const serialized = serializeBlock(block);
|
|
55
|
-
if (serialized) {
|
|
56
|
-
lines.push(serialized);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return lines;
|
|
60
|
-
}
|
|
61
|
-
function serializeMetadata(metadata) {
|
|
62
|
-
if (!metadata)
|
|
63
|
-
return null;
|
|
64
|
-
try {
|
|
65
|
-
const minimalMetadata = {
|
|
66
|
-
type: metadata.type,
|
|
67
|
-
title: metadata.title,
|
|
68
|
-
url: metadata.url,
|
|
69
|
-
};
|
|
70
|
-
return JSON.stringify(minimalMetadata);
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl.transformer.js","sourceRoot":"","sources":["../../src/transformers/jsonl.transformer.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { CODE_BLOCK } from '../../config/formatting.js';
|
|
2
|
-
import { detectLanguageFromCode, resolveLanguageFromAttributes, } from '../../utils/code-language.js';
|
|
3
|
-
import { isRecord } from '../../utils/guards.js';
|
|
4
|
-
function isElement(node) {
|
|
5
|
-
return (isRecord(node) &&
|
|
6
|
-
'getAttribute' in node &&
|
|
7
|
-
typeof node.getAttribute === 'function');
|
|
8
|
-
}
|
|
9
|
-
function isFencedCodeBlock(node, options) {
|
|
10
|
-
return (options.codeBlockStyle === 'fenced' &&
|
|
11
|
-
node.nodeName === 'PRE' &&
|
|
12
|
-
node.firstChild?.nodeName === 'CODE');
|
|
13
|
-
}
|
|
14
|
-
function formatFencedCodeBlock(node) {
|
|
15
|
-
const codeNode = node.firstChild;
|
|
16
|
-
if (!isElement(codeNode))
|
|
17
|
-
return '';
|
|
18
|
-
const code = codeNode.textContent || '';
|
|
19
|
-
const language = resolveCodeLanguage(codeNode, code);
|
|
20
|
-
return CODE_BLOCK.format(code, language);
|
|
21
|
-
}
|
|
22
|
-
function resolveCodeLanguage(codeNode, code) {
|
|
23
|
-
const { className, dataLanguage } = readCodeAttributes(codeNode);
|
|
24
|
-
const attributeLanguage = resolveLanguageFromAttributes(className, dataLanguage);
|
|
25
|
-
return attributeLanguage ?? detectLanguageFromCode(code) ?? '';
|
|
26
|
-
}
|
|
27
|
-
function readCodeAttributes(codeNode) {
|
|
28
|
-
return {
|
|
29
|
-
className: codeNode.getAttribute('class') ?? '',
|
|
30
|
-
dataLanguage: codeNode.getAttribute('data-language') ?? '',
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export function addFencedCodeRule(instance) {
|
|
34
|
-
instance.addRule('fencedCodeBlockWithLanguage', {
|
|
35
|
-
filter: (node, options) => isFencedCodeBlock(node, options),
|
|
36
|
-
replacement: (_content, node) => formatFencedCodeBlock(node),
|
|
37
|
-
});
|
|
38
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { FRONTMATTER_DELIMITER, joinLines } from '../../config/formatting.js';
|
|
2
|
-
const YAML_SPECIAL_CHARS = /[:[\]{}"\r\t'|>&*!?,#]|\n/;
|
|
3
|
-
const YAML_NUMERIC = /^[\d.]+$/;
|
|
4
|
-
const YAML_RESERVED_WORDS = /^(true|false|null|yes|no|on|off)$/i;
|
|
5
|
-
const ESCAPE_PATTERNS = {
|
|
6
|
-
backslash: /\\/g,
|
|
7
|
-
quote: /"/g,
|
|
8
|
-
newline: /\n/g,
|
|
9
|
-
tab: /\t/g,
|
|
10
|
-
};
|
|
11
|
-
const YAML_QUOTE_CHECKS = [
|
|
12
|
-
(input) => YAML_SPECIAL_CHARS.test(input),
|
|
13
|
-
(input) => input.startsWith(' ') || input.endsWith(' '),
|
|
14
|
-
(input) => input === '',
|
|
15
|
-
(input) => YAML_NUMERIC.test(input),
|
|
16
|
-
(input) => YAML_RESERVED_WORDS.test(input),
|
|
17
|
-
];
|
|
18
|
-
function needsYamlQuotes(value) {
|
|
19
|
-
return YAML_QUOTE_CHECKS.some((check) => check(value));
|
|
20
|
-
}
|
|
21
|
-
function escapeYamlValue(value) {
|
|
22
|
-
if (!needsYamlQuotes(value)) {
|
|
23
|
-
return value;
|
|
24
|
-
}
|
|
25
|
-
const escaped = value
|
|
26
|
-
.replace(ESCAPE_PATTERNS.backslash, '\\\\')
|
|
27
|
-
.replace(ESCAPE_PATTERNS.quote, '\\"')
|
|
28
|
-
.replace(ESCAPE_PATTERNS.newline, '\\n')
|
|
29
|
-
.replace(ESCAPE_PATTERNS.tab, '\\t');
|
|
30
|
-
return `"${escaped}"`;
|
|
31
|
-
}
|
|
32
|
-
function appendFrontmatterField(lines, key, value) {
|
|
33
|
-
if (!value)
|
|
34
|
-
return;
|
|
35
|
-
lines.push(`${key}: ${escapeYamlValue(value)}`);
|
|
36
|
-
}
|
|
37
|
-
export function buildFrontmatter(metadata) {
|
|
38
|
-
if (!metadata)
|
|
39
|
-
return '';
|
|
40
|
-
const lines = [FRONTMATTER_DELIMITER];
|
|
41
|
-
appendFrontmatterField(lines, 'title', metadata.title);
|
|
42
|
-
appendFrontmatterField(lines, 'source', metadata.url);
|
|
43
|
-
lines.push(FRONTMATTER_DELIMITER);
|
|
44
|
-
return joinLines(lines);
|
|
45
|
-
}
|