veryfront 0.1.128 → 0.1.129
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/esm/cli/router.d.ts +0 -5
- package/esm/cli/router.d.ts.map +1 -1
- package/esm/cli/router.js +30 -2
- package/esm/cli/shared/update-check.d.ts +4 -0
- package/esm/cli/shared/update-check.d.ts.map +1 -0
- package/esm/cli/shared/update-check.js +97 -0
- package/esm/deno.d.ts +5 -0
- package/esm/deno.js +13 -8
- package/esm/src/channels/control-plane.d.ts.map +1 -1
- package/esm/src/channels/control-plane.js +5 -5
- package/esm/src/channels/invoke.d.ts +1 -1
- package/esm/src/channels/invoke.d.ts.map +1 -1
- package/esm/src/channels/invoke.js +6 -6
- package/esm/src/chat/index.d.ts +12 -24
- package/esm/src/chat/index.d.ts.map +1 -1
- package/esm/src/chat/index.js +5 -25
- package/esm/src/config/env.d.ts.map +1 -1
- package/esm/src/config/env.js +18 -10
- package/esm/src/data/static-data-fetcher.d.ts +3 -0
- package/esm/src/data/static-data-fetcher.d.ts.map +1 -1
- package/esm/src/data/static-data-fetcher.js +29 -25
- package/esm/src/data/static-paths-fetcher.d.ts.map +1 -1
- package/esm/src/data/static-paths-fetcher.js +3 -2
- package/esm/src/errors/logging.d.ts.map +1 -1
- package/esm/src/errors/logging.js +16 -7
- package/esm/src/errors/user-friendly/error-formatter.d.ts.map +1 -1
- package/esm/src/errors/user-friendly/error-formatter.js +9 -25
- package/esm/src/fs/index.d.ts +11 -12
- package/esm/src/fs/index.d.ts.map +1 -1
- package/esm/src/fs/index.js +11 -24
- package/esm/src/html/dev-scripts.d.ts.map +1 -1
- package/esm/src/html/dev-scripts.js +5 -8
- package/esm/src/html/html-escape.d.ts +1 -0
- package/esm/src/html/html-escape.d.ts.map +1 -1
- package/esm/src/html/html-escape.js +3 -0
- package/esm/src/html/html-injection.js +2 -2
- package/esm/src/html/html-shell-generator.d.ts +5 -2
- package/esm/src/html/html-shell-generator.d.ts.map +1 -1
- package/esm/src/html/html-shell-generator.js +41 -30
- package/esm/src/html/hydration-script-builder/dev-client-renderer.js +2 -2
- package/esm/src/html/hydration-script-builder/dev-component-manifest.js +2 -2
- package/esm/src/html/hydration-script-builder/dev-error-logger.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/dev-error-logger.js +2 -6
- package/esm/src/html/hydration-script-builder/dev-scripts.js +2 -2
- package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts +3 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/hydration-data-generator.js +2 -2
- package/esm/src/html/hydration-script-builder/index.d.ts +1 -1
- package/esm/src/html/hydration-script-builder/index.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/index.js +1 -1
- package/esm/src/html/hydration-script-builder/prod-hydration.js +2 -2
- package/esm/src/html/hydration-script-builder/prod-scripts.d.ts +2 -0
- package/esm/src/html/hydration-script-builder/prod-scripts.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/prod-scripts.js +14 -14
- package/esm/src/html/schemas/html.schema.d.ts +2 -0
- package/esm/src/html/schemas/html.schema.d.ts.map +1 -1
- package/esm/src/html/schemas/html.schema.js +2 -0
- package/esm/src/html/styles-builder/css-pregeneration.d.ts +17 -1
- package/esm/src/html/styles-builder/css-pregeneration.d.ts.map +1 -1
- package/esm/src/html/styles-builder/css-pregeneration.js +103 -1
- package/esm/src/html/styles-builder/dev-styles.js +2 -2
- package/esm/src/html/utils.d.ts +2 -0
- package/esm/src/html/utils.d.ts.map +1 -1
- package/esm/src/html/utils.js +49 -28
- package/esm/src/integrations/remote-tools.d.ts.map +1 -1
- package/esm/src/integrations/remote-tools.js +32 -39
- package/esm/src/internal-agents/ag-ui-sse.d.ts +0 -1
- package/esm/src/internal-agents/ag-ui-sse.d.ts.map +1 -1
- package/esm/src/internal-agents/ag-ui-sse.js +2 -16
- package/esm/src/internal-agents/control-plane-auth.d.ts.map +1 -1
- package/esm/src/internal-agents/control-plane-auth.js +5 -3
- package/esm/src/internal-agents/request-body.d.ts.map +1 -1
- package/esm/src/internal-agents/request-body.js +6 -3
- package/esm/src/internal-agents/session-manager.d.ts +1 -0
- package/esm/src/internal-agents/session-manager.d.ts.map +1 -1
- package/esm/src/internal-agents/session-manager.js +12 -18
- package/esm/src/issues/core.d.ts.map +1 -1
- package/esm/src/issues/core.js +24 -23
- package/esm/src/issues/schemas/issue.schema.d.ts.map +1 -1
- package/esm/src/issues/schemas/issue.schema.js +2 -1
- package/esm/src/jobs/runtime-env.d.ts.map +1 -1
- package/esm/src/jobs/runtime-env.js +21 -44
- package/esm/src/markdown/index.d.ts +1 -2
- package/esm/src/markdown/index.d.ts.map +1 -1
- package/esm/src/markdown/index.js +1 -6
- package/esm/src/mcp/server.d.ts +0 -1
- package/esm/src/mcp/server.d.ts.map +1 -1
- package/esm/src/mcp/server.js +40 -41
- package/esm/src/mdx/index.d.ts +3 -2
- package/esm/src/mdx/index.d.ts.map +1 -1
- package/esm/src/mdx/index.js +3 -5
- package/esm/src/middleware/builtin/logger.d.ts.map +1 -1
- package/esm/src/middleware/builtin/logger.js +31 -28
- package/esm/src/middleware/builtin/security/rate-limit.d.ts.map +1 -1
- package/esm/src/middleware/builtin/security/rate-limit.js +17 -12
- package/esm/src/middleware/builtin/timeout.d.ts.map +1 -1
- package/esm/src/middleware/builtin/timeout.js +17 -10
- package/esm/src/modules/import-map/default-import-map.d.ts.map +1 -1
- package/esm/src/modules/import-map/default-import-map.js +4 -3
- package/esm/src/oauth/handlers/callback-handler.d.ts +0 -5
- package/esm/src/oauth/handlers/callback-handler.d.ts.map +1 -1
- package/esm/src/oauth/handlers/callback-handler.js +9 -14
- package/esm/src/oauth/handlers/index.d.ts +1 -1
- package/esm/src/oauth/handlers/index.js +1 -1
- package/esm/src/oauth/handlers/init-handler.d.ts.map +1 -1
- package/esm/src/oauth/handlers/init-handler.js +32 -20
- package/esm/src/oauth/providers/index.d.ts +1 -1
- package/esm/src/oauth/providers/index.js +1 -1
- package/esm/src/oauth/schemas/index.d.ts +1 -1
- package/esm/src/oauth/schemas/index.js +1 -1
- package/esm/src/oauth/token-store/index.d.ts +1 -1
- package/esm/src/oauth/token-store/index.js +1 -1
- package/esm/src/oauth/token-store/memory.d.ts +1 -1
- package/esm/src/oauth/token-store/memory.d.ts.map +1 -1
- package/esm/src/oauth/token-store/memory.js +8 -8
- package/esm/src/observability/request-profiler.d.ts +31 -0
- package/esm/src/observability/request-profiler.d.ts.map +1 -0
- package/esm/src/observability/request-profiler.js +94 -0
- package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -1
- package/esm/src/observability/tracing/otlp-setup.js +16 -21
- package/esm/src/prompt/factory.d.ts.map +1 -1
- package/esm/src/prompt/factory.js +10 -12
- package/esm/src/prompt/registry.d.ts.map +1 -1
- package/esm/src/prompt/registry.js +12 -10
- package/esm/src/prompt/schemas/prompt.schema.d.ts.map +1 -1
- package/esm/src/prompt/schemas/prompt.schema.js +0 -2
- package/esm/src/prompt/types.d.ts +1 -1
- package/esm/src/prompt/types.d.ts.map +1 -1
- package/esm/src/provider/local/ai-sdk-adapter.d.ts.map +1 -1
- package/esm/src/provider/local/ai-sdk-adapter.js +3 -8
- package/esm/src/provider/local/env.d.ts +4 -6
- package/esm/src/provider/local/env.d.ts.map +1 -1
- package/esm/src/provider/local/env.js +14 -1
- package/esm/src/provider/local/local-engine.d.ts.map +1 -1
- package/esm/src/provider/local/local-engine.js +2 -7
- package/esm/src/provider/model-registry.d.ts.map +1 -1
- package/esm/src/provider/model-registry.js +2 -7
- package/esm/src/provider/veryfront-cloud/provider.d.ts.map +1 -1
- package/esm/src/provider/veryfront-cloud/provider.js +1 -7
- package/esm/src/provider/veryfront-cloud/shared.d.ts.map +1 -1
- package/esm/src/provider/veryfront-cloud/shared.js +9 -11
- package/esm/src/proxy/handler.d.ts.map +1 -1
- package/esm/src/proxy/handler.js +56 -57
- package/esm/src/react/compat/hooks-adapter.d.ts +1 -7
- package/esm/src/react/compat/hooks-adapter.d.ts.map +1 -1
- package/esm/src/react/compat/hooks-adapter.js +35 -40
- package/esm/src/react/components/Head.d.ts +1 -26
- package/esm/src/react/components/Head.d.ts.map +1 -1
- package/esm/src/react/components/Head.js +1 -172
- package/esm/src/react/context/index.d.ts +2 -46
- package/esm/src/react/context/index.d.ts.map +1 -1
- package/esm/src/react/context/index.js +1 -44
- package/esm/src/react/head-collector.d.ts +1 -10
- package/esm/src/react/head-collector.d.ts.map +1 -1
- package/esm/src/react/head-collector.js +4 -0
- package/esm/src/react/router/index.d.ts +2 -45
- package/esm/src/react/router/index.d.ts.map +1 -1
- package/esm/src/react/router/index.js +1 -49
- package/esm/src/react/runtime/core.d.ts +49 -0
- package/esm/src/react/runtime/core.d.ts.map +1 -0
- package/esm/src/react/runtime/core.js +200 -0
- package/esm/src/rendering/orchestrator/html.d.ts +2 -0
- package/esm/src/rendering/orchestrator/html.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/html.js +69 -12
- package/esm/src/rendering/orchestrator/ssr-orchestrator.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/ssr-orchestrator.js +4 -0
- package/esm/src/rendering/orchestrator/types.d.ts +4 -0
- package/esm/src/rendering/orchestrator/types.d.ts.map +1 -1
- package/esm/src/repositories/types.d.ts.map +1 -1
- package/esm/src/resource/factory.d.ts.map +1 -1
- package/esm/src/resource/factory.js +12 -9
- package/esm/src/resource/registry.d.ts +3 -3
- package/esm/src/resource/registry.d.ts.map +1 -1
- package/esm/src/resource/registry.js +7 -7
- package/esm/src/schemas/common.d.ts.map +1 -1
- package/esm/src/schemas/common.js +7 -4
- package/esm/src/security/http/config.d.ts +0 -1
- package/esm/src/security/http/config.d.ts.map +1 -1
- package/esm/src/security/http/config.js +3 -16
- package/esm/src/security/http/response/security-handler.d.ts +1 -0
- package/esm/src/security/http/response/security-handler.d.ts.map +1 -1
- package/esm/src/security/http/response/security-handler.js +17 -12
- package/esm/src/security/index.d.ts +4 -2
- package/esm/src/security/index.d.ts.map +1 -1
- package/esm/src/security/index.js +3 -1
- package/esm/src/server/handlers/dev/styles-css.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/dev/styles-css.handler.js +8 -7
- package/esm/src/server/handlers/monitoring/metrics.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/monitoring/metrics.handler.js +3 -1
- package/esm/src/server/handlers/request/module/module-server-handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/module/module-server-handler.js +18 -15
- package/esm/src/server/handlers/request/prod-hydration-module.handler.d.ts +8 -0
- package/esm/src/server/handlers/request/prod-hydration-module.handler.d.ts.map +1 -0
- package/esm/src/server/handlers/request/prod-hydration-module.handler.js +41 -0
- package/esm/src/server/handlers/request/ssr/ssr.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/ssr/ssr.handler.js +3 -0
- package/esm/src/server/production-server.d.ts.map +1 -1
- package/esm/src/server/production-server.js +65 -0
- package/esm/src/server/runtime-handler/handler-context-builder.d.ts +1 -1
- package/esm/src/server/runtime-handler/handler-context-builder.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/index.d.ts +1 -1
- package/esm/src/server/runtime-handler/index.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/index.js +36 -11
- package/esm/src/server/runtime-handler/request-utils.d.ts +7 -0
- package/esm/src/server/runtime-handler/request-utils.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/request-utils.js +10 -0
- package/esm/src/server/services/rendering/ssr.service.d.ts +1 -0
- package/esm/src/server/services/rendering/ssr.service.d.ts.map +1 -1
- package/esm/src/server/services/rendering/ssr.service.js +12 -5
- package/esm/src/server/services/rsc/endpoints/rsc-bundles.generated.js +1 -1
- package/esm/src/skill/allowed-tools.d.ts +3 -8
- package/esm/src/skill/allowed-tools.d.ts.map +1 -1
- package/esm/src/skill/executor.js +2 -2
- package/esm/src/skill/parser.d.ts.map +1 -1
- package/esm/src/skill/parser.js +12 -12
- package/esm/src/skill/path-safety.js +1 -1
- package/esm/src/skill/tools.d.ts.map +1 -1
- package/esm/src/skill/tools.js +18 -11
- package/esm/src/studio/bridge/bridge-bundle.generated.d.ts.map +1 -1
- package/esm/src/studio/bridge/bridge-bundle.generated.js +1 -1
- package/esm/src/task/discovery.d.ts.map +1 -1
- package/esm/src/task/discovery.js +73 -95
- package/esm/src/tool/executor.d.ts.map +1 -1
- package/esm/src/tool/executor.js +8 -7
- package/esm/src/tool/factory.d.ts.map +1 -1
- package/esm/src/tool/factory.js +13 -16
- package/esm/src/transforms/esm/package-registry.d.ts +4 -0
- package/esm/src/transforms/esm/package-registry.d.ts.map +1 -1
- package/esm/src/transforms/esm/package-registry.js +34 -17
- package/esm/src/transforms/import-rewriter/strategies/veryfront-strategy.d.ts.map +1 -1
- package/esm/src/transforms/import-rewriter/strategies/veryfront-strategy.js +2 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache-format.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/cache-format.js +26 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/index.js +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.d.ts +1 -0
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.js +3 -0
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/index.d.ts +1 -1
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/index.js +1 -1
- package/esm/src/transforms/veryfront-module-urls.d.ts.map +1 -1
- package/esm/src/transforms/veryfront-module-urls.js +7 -3
- package/esm/src/types/entities/getEntityInfo.d.ts.map +1 -1
- package/esm/src/types/entities/getEntityInfo.js +79 -127
- package/esm/src/utils/path-utils.d.ts +1 -1
- package/esm/src/utils/path-utils.d.ts.map +1 -1
- package/esm/src/utils/path-utils.js +16 -7
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/esm/src/utils/version.d.ts.map +1 -1
- package/esm/src/utils/version.js +0 -1
- package/esm/src/workflow/worker/dynamic-job-entrypoint.d.ts.map +1 -1
- package/esm/src/workflow/worker/dynamic-job-entrypoint.js +5 -72
- package/esm/src/workflow/worker/job-entrypoint.d.ts.map +1 -1
- package/esm/src/workflow/worker/job-entrypoint.js +5 -72
- package/esm/src/workflow/worker/shared.d.ts +18 -0
- package/esm/src/workflow/worker/shared.d.ts.map +1 -0
- package/esm/src/workflow/worker/shared.js +77 -0
- package/package.json +1 -1
- package/src/cli/router.ts +41 -2
- package/src/cli/shared/update-check.ts +110 -0
- package/src/deno.js +13 -8
- package/src/src/channels/control-plane.ts +6 -10
- package/src/src/channels/invoke.ts +7 -7
- package/src/src/chat/index.ts +96 -132
- package/src/src/config/env.ts +24 -11
- package/src/src/data/static-data-fetcher.ts +59 -34
- package/src/src/data/static-paths-fetcher.ts +4 -2
- package/src/src/errors/logging.ts +21 -7
- package/src/src/errors/user-friendly/error-formatter.ts +14 -29
- package/src/src/fs/index.ts +21 -30
- package/src/src/html/dev-scripts.ts +5 -9
- package/src/src/html/html-escape.ts +4 -0
- package/src/src/html/html-injection.ts +2 -2
- package/src/src/html/html-shell-generator.ts +60 -26
- package/src/src/html/hydration-script-builder/dev-client-renderer.ts +2 -2
- package/src/src/html/hydration-script-builder/dev-component-manifest.ts +2 -2
- package/src/src/html/hydration-script-builder/dev-error-logger.ts +2 -8
- package/src/src/html/hydration-script-builder/dev-scripts.ts +2 -2
- package/src/src/html/hydration-script-builder/hydration-data-generator.ts +2 -1
- package/src/src/html/hydration-script-builder/index.ts +5 -1
- package/src/src/html/hydration-script-builder/prod-hydration.ts +2 -2
- package/src/src/html/hydration-script-builder/prod-scripts.ts +16 -15
- package/src/src/html/schemas/html.schema.ts +2 -0
- package/src/src/html/styles-builder/css-pregeneration.ts +133 -1
- package/src/src/html/styles-builder/dev-styles.ts +2 -2
- package/src/src/html/utils.ts +62 -29
- package/src/src/integrations/remote-tools.ts +39 -37
- package/src/src/internal-agents/ag-ui-sse.ts +2 -17
- package/src/src/internal-agents/control-plane-auth.ts +8 -6
- package/src/src/internal-agents/request-body.ts +7 -5
- package/src/src/internal-agents/session-manager.ts +16 -20
- package/src/src/issues/core.ts +24 -27
- package/src/src/issues/schemas/issue.schema.ts +3 -1
- package/src/src/jobs/runtime-env.ts +24 -50
- package/src/src/markdown/index.ts +5 -8
- package/src/src/mcp/server.ts +50 -53
- package/src/src/mdx/index.ts +7 -8
- package/src/src/middleware/builtin/logger.ts +44 -29
- package/src/src/middleware/builtin/security/rate-limit.ts +20 -11
- package/src/src/middleware/builtin/timeout.ts +22 -13
- package/src/src/modules/import-map/default-import-map.ts +4 -3
- package/src/src/oauth/handlers/callback-handler.ts +9 -16
- package/src/src/oauth/handlers/index.ts +1 -1
- package/src/src/oauth/handlers/init-handler.ts +56 -27
- package/src/src/oauth/providers/index.ts +1 -1
- package/src/src/oauth/schemas/index.ts +1 -1
- package/src/src/oauth/token-store/index.ts +1 -1
- package/src/src/oauth/token-store/memory.ts +8 -8
- package/src/src/observability/request-profiler.ts +140 -0
- package/src/src/observability/tracing/otlp-setup.ts +16 -22
- package/src/src/prompt/factory.ts +16 -14
- package/src/src/prompt/registry.ts +14 -13
- package/src/src/prompt/schemas/prompt.schema.ts +0 -4
- package/src/src/prompt/types.ts +1 -2
- package/src/src/provider/local/ai-sdk-adapter.ts +3 -10
- package/src/src/provider/local/env.ts +22 -2
- package/src/src/provider/local/local-engine.ts +2 -9
- package/src/src/provider/model-registry.ts +2 -9
- package/src/src/provider/veryfront-cloud/provider.ts +1 -8
- package/src/src/provider/veryfront-cloud/shared.ts +12 -15
- package/src/src/proxy/handler.ts +90 -74
- package/src/src/react/compat/hooks-adapter.ts +43 -44
- package/src/src/react/components/Head.tsx +1 -181
- package/src/src/react/context/index.tsx +2 -83
- package/src/src/react/head-collector.ts +9 -0
- package/src/src/react/router/index.tsx +2 -100
- package/src/src/react/runtime/core.ts +303 -0
- package/src/src/rendering/orchestrator/html.ts +122 -18
- package/src/src/rendering/orchestrator/ssr-orchestrator.ts +8 -0
- package/src/src/rendering/orchestrator/types.ts +4 -0
- package/src/src/repositories/types.ts +0 -4
- package/src/src/resource/factory.ts +15 -11
- package/src/src/resource/registry.ts +7 -7
- package/src/src/schemas/common.ts +8 -5
- package/src/src/security/http/config.ts +3 -19
- package/src/src/security/http/response/security-handler.ts +22 -13
- package/src/src/security/index.ts +4 -7
- package/src/src/server/handlers/dev/styles-css.handler.ts +32 -14
- package/src/src/server/handlers/monitoring/metrics.handler.ts +3 -1
- package/src/src/server/handlers/request/module/module-server-handler.ts +24 -17
- package/src/src/server/handlers/request/prod-hydration-module.handler.ts +61 -0
- package/src/src/server/handlers/request/ssr/ssr.handler.ts +3 -0
- package/src/src/server/production-server.ts +84 -0
- package/src/src/server/runtime-handler/handler-context-builder.ts +1 -1
- package/src/src/server/runtime-handler/index.ts +44 -13
- package/src/src/server/runtime-handler/request-utils.ts +11 -0
- package/src/src/server/services/rendering/ssr.service.ts +31 -18
- package/src/src/server/services/rsc/endpoints/rsc-bundles.generated.ts +1 -1
- package/src/src/skill/allowed-tools.ts +1 -8
- package/src/src/skill/executor.ts +2 -2
- package/src/src/skill/parser.ts +13 -20
- package/src/src/skill/path-safety.ts +1 -1
- package/src/src/skill/tools.ts +27 -20
- package/src/src/studio/bridge/bridge-bundle.generated.ts +1 -1
- package/src/src/task/discovery.ts +97 -97
- package/src/src/tool/executor.ts +10 -8
- package/src/src/tool/factory.ts +21 -22
- package/src/src/tool/types.ts +0 -17
- package/src/src/transforms/esm/package-registry.ts +52 -20
- package/src/src/transforms/import-rewriter/strategies/veryfront-strategy.ts +2 -1
- package/src/src/transforms/mdx/esm-module-loader/cache-format.ts +34 -1
- package/src/src/transforms/mdx/esm-module-loader/module-fetcher/index.ts +1 -1
- package/src/src/transforms/mdx/esm-module-loader/module-fetcher/render-sessions.ts +4 -0
- package/src/src/transforms/pipeline/stages/ssr-vf-modules/index.ts +1 -1
- package/src/src/transforms/veryfront-module-urls.ts +6 -2
- package/src/src/types/entities/getEntityInfo.ts +131 -152
- package/src/src/utils/path-utils.ts +16 -7
- package/src/src/utils/version-constant.ts +1 -1
- package/src/src/utils/version.ts +0 -1
- package/src/src/workflow/worker/dynamic-job-entrypoint.ts +18 -84
- package/src/src/workflow/worker/job-entrypoint.ts +18 -85
- package/src/src/workflow/worker/shared.ts +127 -0
- package/esm/src/prompt/schemas/index.d.ts +0 -7
- package/esm/src/prompt/schemas/index.d.ts.map +0 -1
- package/esm/src/prompt/schemas/index.js +0 -6
- package/esm/src/security/http/handlers-index.d.ts +0 -5
- package/esm/src/security/http/handlers-index.d.ts.map +0 -1
- package/esm/src/security/http/handlers-index.js +0 -3
- package/src/src/prompt/schemas/index.ts +0 -7
- package/src/src/security/http/handlers-index.ts +0 -4
package/src/src/issues/core.ts
CHANGED
|
@@ -119,19 +119,11 @@ export function serializeYaml(metadata: IssueMetadata): string {
|
|
|
119
119
|
lines.push(`id: ${metadata.id}`);
|
|
120
120
|
lines.push(`title: "${metadata.title.replace(/"/g, '\\"')}"`);
|
|
121
121
|
lines.push(`state: ${metadata.state}`);
|
|
122
|
-
lines.push(
|
|
123
|
-
metadata.labels.length
|
|
124
|
-
? `labels: [${metadata.labels.map((l) => `"${l}"`).join(", ")}]`
|
|
125
|
-
: "labels: []",
|
|
126
|
-
);
|
|
122
|
+
lines.push(serializeYamlStringArray("labels", metadata.labels));
|
|
127
123
|
|
|
128
124
|
if (metadata.milestone) lines.push(`milestone: ${metadata.milestone}`);
|
|
129
125
|
|
|
130
|
-
lines.push(
|
|
131
|
-
metadata.assignees.length
|
|
132
|
-
? `assignees: [${metadata.assignees.map((a) => `"${a}"`).join(", ")}]`
|
|
133
|
-
: "assignees: []",
|
|
134
|
-
);
|
|
126
|
+
lines.push(serializeYamlStringArray("assignees", metadata.assignees));
|
|
135
127
|
|
|
136
128
|
lines.push(`created_at: ${metadata.created_at}`);
|
|
137
129
|
lines.push(`updated_at: ${metadata.updated_at}`);
|
|
@@ -139,6 +131,11 @@ export function serializeYaml(metadata: IssueMetadata): string {
|
|
|
139
131
|
return lines.join("\n");
|
|
140
132
|
}
|
|
141
133
|
|
|
134
|
+
function serializeYamlStringArray(field: string, values: string[]): string {
|
|
135
|
+
if (!values.length) return `${field}: []`;
|
|
136
|
+
return `${field}: [${values.map((value) => `"${value}"`).join(", ")}]`;
|
|
137
|
+
}
|
|
138
|
+
|
|
142
139
|
/**
|
|
143
140
|
* Serialize issue to markdown file content
|
|
144
141
|
*/
|
|
@@ -156,7 +153,7 @@ export function parseIssue(content: string, path: string): Issue | null {
|
|
|
156
153
|
try {
|
|
157
154
|
const metadata = validateMetadata(parseYaml(parsed.frontmatter));
|
|
158
155
|
return { metadata, body: parsed.body, path };
|
|
159
|
-
} catch
|
|
156
|
+
} catch {
|
|
160
157
|
// expected: invalid or unparseable frontmatter metadata
|
|
161
158
|
return null;
|
|
162
159
|
}
|
|
@@ -201,7 +198,7 @@ export class IssuesManager {
|
|
|
201
198
|
const id = entry.name.replace(/\.md$/, "");
|
|
202
199
|
if (ISSUE_ID_PATTERN.test(id)) ids.push(id);
|
|
203
200
|
}
|
|
204
|
-
} catch
|
|
201
|
+
} catch {
|
|
205
202
|
// expected: directory doesn't exist yet
|
|
206
203
|
}
|
|
207
204
|
|
|
@@ -229,10 +226,10 @@ export class IssuesManager {
|
|
|
229
226
|
updated_at: now,
|
|
230
227
|
};
|
|
231
228
|
|
|
232
|
-
const
|
|
233
|
-
const issue: Issue = { metadata, body: validated.body ?? "", path };
|
|
229
|
+
const issuePath = `${ISSUES_DIR}/${id}.md`;
|
|
230
|
+
const issue: Issue = { metadata, body: validated.body ?? "", path: issuePath };
|
|
234
231
|
|
|
235
|
-
await this.fs.writeTextFile(join(this.projectDir,
|
|
232
|
+
await this.fs.writeTextFile(join(this.projectDir, issuePath), serializeIssue(issue));
|
|
236
233
|
return issue;
|
|
237
234
|
}
|
|
238
235
|
|
|
@@ -240,12 +237,12 @@ export class IssuesManager {
|
|
|
240
237
|
* Get an issue by ID
|
|
241
238
|
*/
|
|
242
239
|
async get(id: string): Promise<Issue | null> {
|
|
243
|
-
const
|
|
240
|
+
const issuePath = `${ISSUES_DIR}/${id}.md`;
|
|
244
241
|
|
|
245
242
|
try {
|
|
246
|
-
const content = await this.fs.readTextFile(join(this.projectDir,
|
|
247
|
-
return parseIssue(content,
|
|
248
|
-
} catch
|
|
243
|
+
const content = await this.fs.readTextFile(join(this.projectDir, issuePath));
|
|
244
|
+
return parseIssue(content, issuePath);
|
|
245
|
+
} catch {
|
|
249
246
|
// expected: issue file may not exist
|
|
250
247
|
return null;
|
|
251
248
|
}
|
|
@@ -284,12 +281,12 @@ export class IssuesManager {
|
|
|
284
281
|
* Delete an issue
|
|
285
282
|
*/
|
|
286
283
|
async delete(id: string): Promise<boolean> {
|
|
287
|
-
const
|
|
284
|
+
const issuePath = `${ISSUES_DIR}/${id}.md`;
|
|
288
285
|
|
|
289
286
|
try {
|
|
290
|
-
await this.fs.remove(join(this.projectDir,
|
|
287
|
+
await this.fs.remove(join(this.projectDir, issuePath));
|
|
291
288
|
return true;
|
|
292
|
-
} catch
|
|
289
|
+
} catch {
|
|
293
290
|
// expected: issue file may not exist
|
|
294
291
|
return false;
|
|
295
292
|
}
|
|
@@ -325,16 +322,16 @@ export class IssuesManager {
|
|
|
325
322
|
}
|
|
326
323
|
|
|
327
324
|
const sortKey = validated.sortBy ?? "created_at";
|
|
328
|
-
const
|
|
325
|
+
const sortDirection = validated.sortDirection ?? "desc";
|
|
329
326
|
|
|
330
327
|
issues.sort((a, b) => {
|
|
331
|
-
let
|
|
328
|
+
let comparison: number;
|
|
332
329
|
if (sortKey === "id") {
|
|
333
|
-
|
|
330
|
+
comparison = a.metadata.id.localeCompare(b.metadata.id);
|
|
334
331
|
} else {
|
|
335
|
-
|
|
332
|
+
comparison = String(a.metadata[sortKey]).localeCompare(String(b.metadata[sortKey]));
|
|
336
333
|
}
|
|
337
|
-
return
|
|
334
|
+
return sortDirection === "desc" ? -comparison : comparison;
|
|
338
335
|
});
|
|
339
336
|
|
|
340
337
|
const total = issues.length;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
3
|
export const ISSUE_PREFIXES = ["ISSUE", "TASK", "PLAN"] as const;
|
|
4
|
-
|
|
4
|
+
const ISSUE_ID_BODY = `(${ISSUE_PREFIXES.join("|")})-(\\d{3,})`;
|
|
5
|
+
|
|
6
|
+
export const ISSUE_ID_PATTERN = new RegExp(`^${ISSUE_ID_BODY}$`);
|
|
5
7
|
|
|
6
8
|
export const issueStateSchema = z.enum(["open", "closed"]);
|
|
7
9
|
|
|
@@ -6,7 +6,7 @@ export const INJECTED_TASK_ENV_JSON = "VERYFRONT_TASK_ENV_JSON";
|
|
|
6
6
|
|
|
7
7
|
const UNSAFE_INJECTED_ENV_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const RESERVED_TASK_ENV_KEYS = new Set([
|
|
10
10
|
"VERYFRONT_API_TOKEN",
|
|
11
11
|
"VERYFRONT_API_URL",
|
|
12
12
|
"VERYFRONT_PROJECT_API_URL",
|
|
@@ -20,36 +20,18 @@ const HIDDEN_TASK_CONTEXT_ENV_KEYS = new Set([
|
|
|
20
20
|
INJECTED_TASK_ENV_JSON,
|
|
21
21
|
]);
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"VERYFRONT_API_URL",
|
|
26
|
-
"VERYFRONT_PROJECT_API_URL",
|
|
27
|
-
"VERYFRONT_API_BASE_URL",
|
|
28
|
-
"VERYFRONT_PROJECT_ID",
|
|
29
|
-
"VERYFRONT_PROJECT_SLUG",
|
|
30
|
-
"VERYFRONT_BRANCH_REF",
|
|
31
|
-
"VERYFRONT_API_USER",
|
|
32
|
-
"VERYFRONT_API_PASS",
|
|
33
|
-
"VERYFRONT_JOB_RESULT_PATH",
|
|
34
|
-
INJECTED_TASK_ENV_JSON,
|
|
35
|
-
]);
|
|
36
|
-
|
|
37
|
-
function isHiddenTaskContextEnvKey(key: string): boolean {
|
|
38
|
-
return key.startsWith("TENANT_") || HIDDEN_TASK_CONTEXT_ENV_KEYS.has(key);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function isDisallowedInjectedEnvKey(key: string): boolean {
|
|
42
|
-
return key.startsWith("TENANT_") || DISALLOWED_INJECTED_ENV_KEYS.has(key);
|
|
23
|
+
function isReservedTaskEnvKey(key: string): boolean {
|
|
24
|
+
return key.startsWith("TENANT_") || RESERVED_TASK_ENV_KEYS.has(key);
|
|
43
25
|
}
|
|
44
26
|
|
|
45
|
-
function
|
|
46
|
-
env: Record<string,
|
|
27
|
+
function filterSafeWorkflowEnv(
|
|
28
|
+
env: Record<string, unknown> | undefined,
|
|
47
29
|
): Record<string, string> {
|
|
48
30
|
const filtered: Record<string, string> = {};
|
|
49
31
|
for (const [key, value] of Object.entries(env ?? {})) {
|
|
50
32
|
if (
|
|
51
33
|
UNSAFE_INJECTED_ENV_KEYS.has(key) ||
|
|
52
|
-
|
|
34
|
+
isReservedTaskEnvKey(key) ||
|
|
53
35
|
typeof value !== "string"
|
|
54
36
|
) {
|
|
55
37
|
continue;
|
|
@@ -62,30 +44,22 @@ function filterExistingProjectEnv(
|
|
|
62
44
|
export function readInjectedProjectEnv(
|
|
63
45
|
allEnv: Record<string, string>,
|
|
64
46
|
): Record<string, string> {
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
47
|
+
const rawInjectedEnv = allEnv[INJECTED_TASK_ENV_JSON];
|
|
48
|
+
if (!rawInjectedEnv) {
|
|
67
49
|
return {};
|
|
68
50
|
}
|
|
69
51
|
|
|
70
52
|
try {
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
53
|
+
const parsedInjectedEnv = JSON.parse(rawInjectedEnv);
|
|
54
|
+
if (
|
|
55
|
+
!parsedInjectedEnv ||
|
|
56
|
+
typeof parsedInjectedEnv !== "object" ||
|
|
57
|
+
Array.isArray(parsedInjectedEnv)
|
|
58
|
+
) {
|
|
73
59
|
return {};
|
|
74
60
|
}
|
|
75
61
|
|
|
76
|
-
|
|
77
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
78
|
-
if (
|
|
79
|
-
UNSAFE_INJECTED_ENV_KEYS.has(key) ||
|
|
80
|
-
isDisallowedInjectedEnvKey(key) ||
|
|
81
|
-
typeof value !== "string"
|
|
82
|
-
) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
injectedEnv[key] = value;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return injectedEnv;
|
|
62
|
+
return filterSafeWorkflowEnv(parsedInjectedEnv as Record<string, unknown>);
|
|
89
63
|
} catch {
|
|
90
64
|
logger.warn(`Ignoring invalid ${INJECTED_TASK_ENV_JSON}`);
|
|
91
65
|
return {};
|
|
@@ -96,27 +70,27 @@ export function buildTaskContextEnv(
|
|
|
96
70
|
allEnv: Record<string, string>,
|
|
97
71
|
envAllowlist?: string[],
|
|
98
72
|
): Record<string, string> {
|
|
99
|
-
const
|
|
100
|
-
const
|
|
73
|
+
const allowedEnvKeys = envAllowlist ? new Set(envAllowlist) : null;
|
|
74
|
+
const taskContextEnv: Record<string, string> = {};
|
|
101
75
|
|
|
102
76
|
for (const [key, value] of Object.entries(allEnv)) {
|
|
103
|
-
if (
|
|
77
|
+
if (isReservedTaskEnvKey(key)) {
|
|
104
78
|
continue;
|
|
105
79
|
}
|
|
106
|
-
if (
|
|
80
|
+
if (allowedEnvKeys && !allowedEnvKeys.has(key)) {
|
|
107
81
|
continue;
|
|
108
82
|
}
|
|
109
|
-
|
|
83
|
+
taskContextEnv[key] = value;
|
|
110
84
|
}
|
|
111
85
|
|
|
112
86
|
for (const [key, value] of Object.entries(readInjectedProjectEnv(allEnv))) {
|
|
113
|
-
if (
|
|
87
|
+
if (allowedEnvKeys && !allowedEnvKeys.has(key)) {
|
|
114
88
|
continue;
|
|
115
89
|
}
|
|
116
|
-
|
|
90
|
+
taskContextEnv[key] = value;
|
|
117
91
|
}
|
|
118
92
|
|
|
119
|
-
return
|
|
93
|
+
return taskContextEnv;
|
|
120
94
|
}
|
|
121
95
|
|
|
122
96
|
export function mergeInjectedWorkflowEnv(
|
|
@@ -124,7 +98,7 @@ export function mergeInjectedWorkflowEnv(
|
|
|
124
98
|
allEnv: Record<string, string>,
|
|
125
99
|
): Record<string, string> | undefined {
|
|
126
100
|
const mergedEnv = {
|
|
127
|
-
...
|
|
101
|
+
...filterSafeWorkflowEnv(existingEnv),
|
|
128
102
|
...readInjectedProjectEnv(allEnv),
|
|
129
103
|
};
|
|
130
104
|
|
|
@@ -10,14 +10,11 @@
|
|
|
10
10
|
* <Markdown># Hello{"\n\n"}Some **bold** text with `code`.</Markdown>
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
|
|
14
|
-
// veryfront/markdown — Markdown rendering component
|
|
15
|
-
//
|
|
16
|
-
// Renders markdown strings at runtime with syntax highlighting and
|
|
17
|
-
// Mermaid diagram support. Used for displaying AI-generated content.
|
|
18
|
-
// For MDX page customization, use veryfront/mdx instead.
|
|
19
13
|
import "../../_dnt.polyfills.js";
|
|
20
14
|
|
|
21
15
|
|
|
22
|
-
export {
|
|
23
|
-
|
|
16
|
+
export {
|
|
17
|
+
type CodeBlockProps,
|
|
18
|
+
Markdown,
|
|
19
|
+
type MarkdownProps,
|
|
20
|
+
} from "../react/components/ai/markdown.js";
|
package/src/src/mcp/server.ts
CHANGED
|
@@ -17,14 +17,47 @@ import { logger as baseLogger } from "../utils/index.js";
|
|
|
17
17
|
const logger = baseLogger.component("mcp-server");
|
|
18
18
|
|
|
19
19
|
const MAX_REQUEST_BODY_SIZE = 1_048_576; // 1 MB
|
|
20
|
+
const MAX_CONTEXT_HEADER_LENGTH = 255;
|
|
21
|
+
const JSON_CONTENT_TYPE = "application/json";
|
|
22
|
+
const END_USER_ID_PATTERN = /^[a-zA-Z0-9._@-]+$/;
|
|
23
|
+
const PROJECT_ID_PATTERN = /^[a-zA-Z0-9._-]+$/;
|
|
20
24
|
|
|
21
25
|
type JSONRPCParams = Record<string, unknown> | unknown[];
|
|
22
26
|
|
|
23
|
-
function
|
|
27
|
+
function toParamsRecord(params: JSONRPCParams | undefined): Record<string, unknown> {
|
|
24
28
|
if (!params || Array.isArray(params)) return {};
|
|
25
29
|
return params;
|
|
26
30
|
}
|
|
27
31
|
|
|
32
|
+
function createJSONResponse(body: unknown, init?: dntShim.ResponseInit): dntShim.Response {
|
|
33
|
+
const headers = new dntShim.Headers(init?.headers);
|
|
34
|
+
headers.set("Content-Type", JSON_CONTENT_TYPE);
|
|
35
|
+
return new dntShim.Response(JSON.stringify(body), { ...init, headers });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function createJSONRPCErrorResponse(status: number, code: number, message: string): dntShim.Response {
|
|
39
|
+
return createJSONResponse(
|
|
40
|
+
{
|
|
41
|
+
jsonrpc: "2.0",
|
|
42
|
+
id: null,
|
|
43
|
+
error: { code, message },
|
|
44
|
+
},
|
|
45
|
+
{ status },
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function readAllowedHeader(
|
|
50
|
+
request: dntShim.Request,
|
|
51
|
+
headerName: string,
|
|
52
|
+
pattern: RegExp,
|
|
53
|
+
): string | undefined {
|
|
54
|
+
const value = request.headers.get(headerName);
|
|
55
|
+
if (!value || value.length > MAX_CONTEXT_HEADER_LENGTH || !pattern.test(value)) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
|
|
28
61
|
interface JSONRPCRequest {
|
|
29
62
|
jsonrpc: "2.0";
|
|
30
63
|
id?: string | number;
|
|
@@ -168,7 +201,7 @@ export class MCPServer {
|
|
|
168
201
|
params: JSONRPCParams | undefined,
|
|
169
202
|
context?: ToolExecutionContext,
|
|
170
203
|
): Promise<Record<string, unknown>> {
|
|
171
|
-
const { name, arguments: args } =
|
|
204
|
+
const { name, arguments: args } = toParamsRecord(params);
|
|
172
205
|
|
|
173
206
|
if (!name) {
|
|
174
207
|
throw toError(
|
|
@@ -216,7 +249,7 @@ export class MCPServer {
|
|
|
216
249
|
}
|
|
217
250
|
|
|
218
251
|
private readResource(params: JSONRPCParams | undefined): Promise<Record<string, unknown>> {
|
|
219
|
-
const { uri } =
|
|
252
|
+
const { uri } = toParamsRecord(params);
|
|
220
253
|
|
|
221
254
|
if (!uri) {
|
|
222
255
|
throw toError(
|
|
@@ -275,7 +308,7 @@ export class MCPServer {
|
|
|
275
308
|
}
|
|
276
309
|
|
|
277
310
|
private getPrompt(params: JSONRPCParams | undefined): Promise<Record<string, unknown>> {
|
|
278
|
-
const { name, arguments: args } =
|
|
311
|
+
const { name, arguments: args } = toParamsRecord(params);
|
|
279
312
|
|
|
280
313
|
if (!name) {
|
|
281
314
|
throw toError(
|
|
@@ -316,7 +349,9 @@ export class MCPServer {
|
|
|
316
349
|
createHTTPHandler(): (request: dntShim.Request) => Promise<dntShim.Response> {
|
|
317
350
|
return async (request: dntShim.Request) => {
|
|
318
351
|
const requestOrigin = request.headers.get("Origin");
|
|
319
|
-
if (request.method === "OPTIONS")
|
|
352
|
+
if (request.method === "OPTIONS") {
|
|
353
|
+
return new dntShim.Response(null, { status: 204, headers: this.getCORSHeaders(requestOrigin) });
|
|
354
|
+
}
|
|
320
355
|
|
|
321
356
|
if (this.config.auth?.type && this.config.auth.type !== "none") {
|
|
322
357
|
const authorized = await this.validateAuth(request);
|
|
@@ -326,66 +361,34 @@ export class MCPServer {
|
|
|
326
361
|
// Enforce request body size limit (fast path via Content-Length header)
|
|
327
362
|
const contentLength = request.headers.get("content-length");
|
|
328
363
|
if (contentLength && Number(contentLength) > MAX_REQUEST_BODY_SIZE) {
|
|
329
|
-
return
|
|
330
|
-
JSON.stringify({
|
|
331
|
-
jsonrpc: "2.0",
|
|
332
|
-
id: null,
|
|
333
|
-
error: { code: -32600, message: "Request body too large" },
|
|
334
|
-
}),
|
|
335
|
-
{ status: 413, headers: { "Content-Type": "application/json" } },
|
|
336
|
-
);
|
|
364
|
+
return createJSONRPCErrorResponse(413, -32600, "Request body too large");
|
|
337
365
|
}
|
|
338
366
|
|
|
339
367
|
try {
|
|
340
|
-
validateContentType(request,
|
|
368
|
+
validateContentType(request, JSON_CONTENT_TYPE);
|
|
341
369
|
} catch (error) {
|
|
342
370
|
const message = error instanceof VeryfrontError ? error.message : "Invalid Content-Type";
|
|
343
|
-
return
|
|
344
|
-
JSON.stringify({
|
|
345
|
-
jsonrpc: "2.0",
|
|
346
|
-
id: null,
|
|
347
|
-
error: { code: -32700, message },
|
|
348
|
-
}),
|
|
349
|
-
{ status: 400, headers: { "Content-Type": "application/json" } },
|
|
350
|
-
);
|
|
371
|
+
return createJSONRPCErrorResponse(400, -32700, message);
|
|
351
372
|
}
|
|
352
373
|
|
|
353
374
|
let rpcRequest: JSONRPCRequest;
|
|
354
375
|
try {
|
|
355
376
|
const bodyText = await request.text();
|
|
356
377
|
if (bodyText.length > MAX_REQUEST_BODY_SIZE) {
|
|
357
|
-
return
|
|
358
|
-
JSON.stringify({
|
|
359
|
-
jsonrpc: "2.0",
|
|
360
|
-
id: null,
|
|
361
|
-
error: { code: -32600, message: "Request body too large" },
|
|
362
|
-
}),
|
|
363
|
-
{ status: 413, headers: { "Content-Type": "application/json" } },
|
|
364
|
-
);
|
|
378
|
+
return createJSONRPCErrorResponse(413, -32600, "Request body too large");
|
|
365
379
|
}
|
|
366
380
|
rpcRequest = JSON.parse(bodyText) as JSONRPCRequest;
|
|
367
381
|
} catch (_) {
|
|
368
382
|
// expected: malformed JSON in request body
|
|
369
|
-
return
|
|
370
|
-
JSON.stringify({
|
|
371
|
-
jsonrpc: "2.0",
|
|
372
|
-
id: null,
|
|
373
|
-
error: { code: -32700, message: "Parse error" },
|
|
374
|
-
}),
|
|
375
|
-
{
|
|
376
|
-
status: 400,
|
|
377
|
-
headers: { "Content-Type": "application/json" },
|
|
378
|
-
},
|
|
379
|
-
);
|
|
383
|
+
return createJSONRPCErrorResponse(400, -32700, "Parse error");
|
|
380
384
|
}
|
|
381
385
|
|
|
382
386
|
// Extract end-user identity from request headers for per-user token flows
|
|
383
387
|
const context = this.extractRequestContext(request);
|
|
384
388
|
const rpcResponse = await this.handleRequest(rpcRequest, context);
|
|
385
389
|
|
|
386
|
-
return
|
|
390
|
+
return createJSONResponse(rpcResponse, {
|
|
387
391
|
headers: {
|
|
388
|
-
"Content-Type": "application/json",
|
|
389
392
|
...this.getCORSHeaders(requestOrigin),
|
|
390
393
|
},
|
|
391
394
|
});
|
|
@@ -395,15 +398,13 @@ export class MCPServer {
|
|
|
395
398
|
private extractRequestContext(request: dntShim.Request): ToolExecutionContext | undefined {
|
|
396
399
|
const context: ToolExecutionContext = {};
|
|
397
400
|
|
|
398
|
-
const endUserId = request
|
|
399
|
-
|
|
400
|
-
if (endUserId && endUserId.length <= 255 && /^[a-zA-Z0-9._@-]+$/.test(endUserId)) {
|
|
401
|
+
const endUserId = readAllowedHeader(request, "x-end-user-id", END_USER_ID_PATTERN);
|
|
402
|
+
if (endUserId) {
|
|
401
403
|
context.endUserId = endUserId;
|
|
402
404
|
}
|
|
403
405
|
|
|
404
|
-
const projectId = request
|
|
405
|
-
|
|
406
|
-
if (projectId && projectId.length <= 255 && /^[a-zA-Z0-9._-]+$/.test(projectId)) {
|
|
406
|
+
const projectId = readAllowedHeader(request, "x-project-id", PROJECT_ID_PATTERN);
|
|
407
|
+
if (projectId) {
|
|
407
408
|
context.projectId = projectId;
|
|
408
409
|
}
|
|
409
410
|
|
|
@@ -432,10 +433,6 @@ export class MCPServer {
|
|
|
432
433
|
return await validate(token);
|
|
433
434
|
}
|
|
434
435
|
|
|
435
|
-
private handleCORS(requestOrigin?: string | null): dntShim.Response {
|
|
436
|
-
return new dntShim.Response(null, { status: 204, headers: this.getCORSHeaders(requestOrigin) });
|
|
437
|
-
}
|
|
438
|
-
|
|
439
436
|
private getCORSHeaders(requestOrigin?: string | null): Record<string, string> {
|
|
440
437
|
if (!this.config.cors?.enabled) return {};
|
|
441
438
|
|
package/src/src/mdx/index.ts
CHANGED
|
@@ -11,14 +11,13 @@
|
|
|
11
11
|
* {children}
|
|
12
12
|
* </MDXProvider>
|
|
13
13
|
* ```
|
|
14
|
+
*
|
|
15
|
+
* For runtime markdown string rendering, use `veryfront/markdown` instead.
|
|
14
16
|
*/
|
|
15
|
-
|
|
16
|
-
// veryfront/mdx — MDX provider and component overrides
|
|
17
|
-
//
|
|
18
|
-
// For customizing how .mdx pages render components.
|
|
19
|
-
// For runtime markdown string rendering, use veryfront/markdown instead.
|
|
20
17
|
import "../../_dnt.polyfills.js";
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
export {
|
|
20
|
+
MDXProvider,
|
|
21
|
+
type MDXProviderProps,
|
|
22
|
+
useMDXComponents,
|
|
23
|
+
} from "../react/components/MDXProvider.js";
|
|
@@ -19,6 +19,17 @@ export interface LoggerOptions {
|
|
|
19
19
|
log?: (message: string) => void;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
interface RequestLogDetails {
|
|
23
|
+
method: string;
|
|
24
|
+
pathname: string;
|
|
25
|
+
remoteAddr: string;
|
|
26
|
+
referer?: string;
|
|
27
|
+
requestId?: string;
|
|
28
|
+
traceId?: string;
|
|
29
|
+
projectSlug?: string;
|
|
30
|
+
userAgent?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
const colors = {
|
|
23
34
|
reset: "\x1b[0m",
|
|
24
35
|
red: "\x1b[31m",
|
|
@@ -61,6 +72,19 @@ function getRemoteAddr(req: dntShim.Request): string {
|
|
|
61
72
|
return req.headers.get("x-forwarded-for") ?? req.headers.get("x-real-ip") ?? "-";
|
|
62
73
|
}
|
|
63
74
|
|
|
75
|
+
function getRequestLogDetails(req: dntShim.Request): RequestLogDetails {
|
|
76
|
+
return {
|
|
77
|
+
method: req.method,
|
|
78
|
+
pathname: new URL(req.url).pathname,
|
|
79
|
+
remoteAddr: getRemoteAddr(req),
|
|
80
|
+
referer: req.headers.get("referer") ?? undefined,
|
|
81
|
+
requestId: req.headers.get("x-request-id") ?? undefined,
|
|
82
|
+
traceId: req.headers.get("x-trace-id") ?? req.headers.get("traceparent") ?? undefined,
|
|
83
|
+
projectSlug: req.headers.get("x-project-slug") ?? undefined,
|
|
84
|
+
userAgent: req.headers.get("user-agent") ?? undefined,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
64
88
|
interface HttpLogEntry {
|
|
65
89
|
timestamp: string;
|
|
66
90
|
level: "info" | "warn" | "error";
|
|
@@ -87,30 +111,25 @@ function getLogLevel(status: number): HttpLogEntry["level"] {
|
|
|
87
111
|
}
|
|
88
112
|
|
|
89
113
|
function formatJsonLog(req: dntShim.Request, status: number, duration: number): string {
|
|
90
|
-
const
|
|
91
|
-
const userAgent = req.headers.get("user-agent");
|
|
92
|
-
const referer = req.headers.get("referer");
|
|
93
|
-
const requestId = req.headers.get("x-request-id");
|
|
94
|
-
const traceId = req.headers.get("x-trace-id") ?? req.headers.get("traceparent");
|
|
95
|
-
const projectSlug = req.headers.get("x-project-slug");
|
|
114
|
+
const details = getRequestLogDetails(req);
|
|
96
115
|
|
|
97
116
|
const entry: HttpLogEntry = {
|
|
98
117
|
timestamp: new Date().toISOString(),
|
|
99
118
|
level: getLogLevel(status),
|
|
100
119
|
service: "server",
|
|
101
|
-
message: `${
|
|
120
|
+
message: `${details.method} ${details.pathname} ${status}`,
|
|
102
121
|
http: {
|
|
103
|
-
method:
|
|
104
|
-
path: pathname,
|
|
122
|
+
method: details.method,
|
|
123
|
+
path: details.pathname,
|
|
105
124
|
status,
|
|
106
125
|
durationMs: Math.round(duration),
|
|
107
|
-
remoteAddr:
|
|
108
|
-
...(userAgent && userAgent !== "-" ? { userAgent } : {}),
|
|
109
|
-
...(referer && referer !== "-" ? { referer } : {}),
|
|
126
|
+
remoteAddr: details.remoteAddr,
|
|
127
|
+
...(details.userAgent && details.userAgent !== "-" ? { userAgent: details.userAgent } : {}),
|
|
128
|
+
...(details.referer && details.referer !== "-" ? { referer: details.referer } : {}),
|
|
110
129
|
},
|
|
111
|
-
...(requestId ? { requestId } : {}),
|
|
112
|
-
...(traceId ? { traceId } : {}),
|
|
113
|
-
...(projectSlug ? { projectSlug } : {}),
|
|
130
|
+
...(details.requestId ? { requestId: details.requestId } : {}),
|
|
131
|
+
...(details.traceId ? { traceId: details.traceId } : {}),
|
|
132
|
+
...(details.projectSlug ? { projectSlug: details.projectSlug } : {}),
|
|
114
133
|
};
|
|
115
134
|
|
|
116
135
|
return JSON.stringify(entry);
|
|
@@ -163,22 +182,18 @@ export function logger(options?: LoggerOptions): Middleware {
|
|
|
163
182
|
return;
|
|
164
183
|
}
|
|
165
184
|
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
requestId,
|
|
174
|
-
traceId,
|
|
175
|
-
project_slug: projectSlug,
|
|
176
|
-
request_url: pathname,
|
|
185
|
+
const details = getRequestLogDetails(req);
|
|
186
|
+
|
|
187
|
+
serverLogger.info(`${details.method} ${details.pathname} ${status}`, {
|
|
188
|
+
requestId: details.requestId,
|
|
189
|
+
traceId: details.traceId,
|
|
190
|
+
project_slug: details.projectSlug,
|
|
191
|
+
request_url: details.pathname,
|
|
177
192
|
durationMs: Math.round(duration),
|
|
178
|
-
method:
|
|
193
|
+
method: details.method,
|
|
179
194
|
statusCode: status,
|
|
180
|
-
remoteAddr:
|
|
181
|
-
...(userAgent ? { userAgent } : {}),
|
|
195
|
+
remoteAddr: details.remoteAddr,
|
|
196
|
+
...(details.userAgent ? { userAgent: details.userAgent } : {}),
|
|
182
197
|
});
|
|
183
198
|
}
|
|
184
199
|
|
|
@@ -13,6 +13,22 @@ import { unrefTimer } from "../../../platform/compat/process.js";
|
|
|
13
13
|
const DEFAULT_RATE_LIMIT_REQUESTS = 100;
|
|
14
14
|
const DEFAULT_RATE_LIMIT_WINDOW_MS = MS_PER_MINUTE;
|
|
15
15
|
|
|
16
|
+
function createRateLimitEntry(windowMs: number): RateLimitEntry {
|
|
17
|
+
return { count: 1, resetAt: Date.now() + windowMs };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getRightmostForwardedIp(req: dntShim.Request): string | undefined {
|
|
21
|
+
const forwarded = req.headers.get("x-forwarded-for");
|
|
22
|
+
if (!forwarded) return undefined;
|
|
23
|
+
|
|
24
|
+
const parts = forwarded.split(",").map((value) => value.trim()).filter(Boolean);
|
|
25
|
+
return parts.at(-1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function defaultKeyGenerator(req: dntShim.Request): string {
|
|
29
|
+
return getRightmostForwardedIp(req) ?? "anonymous";
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
export class MemoryRateLimitStore implements RateLimitStore {
|
|
17
33
|
private counts = new Map<string, RateLimitEntry>();
|
|
18
34
|
private cleanupInterval?: ReturnType<typeof dntShim.setInterval>;
|
|
@@ -34,11 +50,11 @@ export class MemoryRateLimitStore implements RateLimitStore {
|
|
|
34
50
|
}
|
|
35
51
|
|
|
36
52
|
increment(key: string, windowMs: number): Promise<RateLimitEntry> {
|
|
37
|
-
const now = Date.now();
|
|
38
53
|
const existing = this.counts.get(key);
|
|
54
|
+
const now = Date.now();
|
|
39
55
|
|
|
40
56
|
if (!existing || existing.resetAt < now) {
|
|
41
|
-
const entry
|
|
57
|
+
const entry = createRateLimitEntry(windowMs);
|
|
42
58
|
this.counts.set(key, entry);
|
|
43
59
|
return Promise.resolve(entry);
|
|
44
60
|
}
|
|
@@ -55,6 +71,7 @@ export class MemoryRateLimitStore implements RateLimitStore {
|
|
|
55
71
|
destroy(): void {
|
|
56
72
|
if (!this.cleanupInterval) return;
|
|
57
73
|
clearInterval(this.cleanupInterval);
|
|
74
|
+
this.cleanupInterval = undefined;
|
|
58
75
|
}
|
|
59
76
|
}
|
|
60
77
|
|
|
@@ -76,15 +93,7 @@ export function rateLimit(
|
|
|
76
93
|
const maxRequests = options.maxRequests ?? DEFAULT_RATE_LIMIT_REQUESTS;
|
|
77
94
|
const windowMs = options.windowMs ?? DEFAULT_RATE_LIMIT_WINDOW_MS;
|
|
78
95
|
const store = options.store ?? new MemoryRateLimitStore(windowMs);
|
|
79
|
-
const keyGenerator = options.keyGenerator ??
|
|
80
|
-
const forwarded = req.headers.get("x-forwarded-for");
|
|
81
|
-
if (forwarded) {
|
|
82
|
-
const parts = forwarded.split(",").map((s) => s.trim()).filter(Boolean);
|
|
83
|
-
// Use rightmost IP — added by nearest trusted proxy, not spoofable by clients
|
|
84
|
-
if (parts.length > 0) return parts[parts.length - 1]!;
|
|
85
|
-
}
|
|
86
|
-
return "anonymous";
|
|
87
|
-
});
|
|
96
|
+
const keyGenerator = options.keyGenerator ?? defaultKeyGenerator;
|
|
88
97
|
|
|
89
98
|
return async (ctx, next) => {
|
|
90
99
|
const req = getRequest(ctx);
|