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
|
@@ -12,6 +12,7 @@ const logger = serverLogger.component("timeout");
|
|
|
12
12
|
|
|
13
13
|
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
14
14
|
const TIMEOUT_SENTINEL = Symbol("timeout");
|
|
15
|
+
const DEFAULT_EXCLUDE_PATHS = ["/healthz", "/readyz", "/_health"];
|
|
15
16
|
|
|
16
17
|
export interface TimeoutOptions {
|
|
17
18
|
/** Timeout in milliseconds (default: 60000) */
|
|
@@ -24,6 +25,24 @@ export interface TimeoutOptions {
|
|
|
24
25
|
exclude?: string[];
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
function isExcludedPath(pathname: string, exclude: string[]): boolean {
|
|
29
|
+
return exclude.some((path) => pathname === path || pathname.startsWith(path));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function timeoutResponse(pathname: string, timeoutMs: number, message: string): dntShim.Response {
|
|
33
|
+
return new dntShim.Response(
|
|
34
|
+
JSON.stringify({
|
|
35
|
+
error: message,
|
|
36
|
+
timeoutMs,
|
|
37
|
+
path: pathname,
|
|
38
|
+
}),
|
|
39
|
+
{
|
|
40
|
+
status: HTTP_GATEWAY_TIMEOUT,
|
|
41
|
+
headers: { "Content-Type": "application/json" },
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
27
46
|
/**
|
|
28
47
|
* Creates a middleware that enforces request timeouts.
|
|
29
48
|
*
|
|
@@ -33,13 +52,13 @@ export interface TimeoutOptions {
|
|
|
33
52
|
export function timeout(options?: TimeoutOptions): Middleware {
|
|
34
53
|
const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
35
54
|
const message = options?.message ?? "Request timeout";
|
|
36
|
-
const exclude = options?.exclude ??
|
|
55
|
+
const exclude = options?.exclude ?? DEFAULT_EXCLUDE_PATHS;
|
|
37
56
|
|
|
38
57
|
return async (ctx, next) => {
|
|
39
58
|
const req = getRequest(ctx);
|
|
40
59
|
const { pathname } = new URL(req.url);
|
|
41
60
|
|
|
42
|
-
if (
|
|
61
|
+
if (isExcludedPath(pathname, exclude)) {
|
|
43
62
|
return next();
|
|
44
63
|
}
|
|
45
64
|
|
|
@@ -60,17 +79,7 @@ export function timeout(options?: TimeoutOptions): Middleware {
|
|
|
60
79
|
timeoutMs,
|
|
61
80
|
});
|
|
62
81
|
|
|
63
|
-
return
|
|
64
|
-
JSON.stringify({
|
|
65
|
-
error: message,
|
|
66
|
-
timeoutMs,
|
|
67
|
-
path: pathname,
|
|
68
|
-
}),
|
|
69
|
-
{
|
|
70
|
-
status: HTTP_GATEWAY_TIMEOUT,
|
|
71
|
-
headers: { "Content-Type": "application/json" },
|
|
72
|
-
},
|
|
73
|
-
);
|
|
82
|
+
return timeoutResponse(pathname, timeoutMs, message);
|
|
74
83
|
} finally {
|
|
75
84
|
if (timeoutId) clearTimeout(timeoutId);
|
|
76
85
|
}
|
|
@@ -12,10 +12,11 @@ import { getReactImportMap } from "../../transforms/esm/package-registry.js";
|
|
|
12
12
|
function getVeryfrontSsrImportMap(): Record<string, string> {
|
|
13
13
|
const base = "/_vf_modules/_veryfront";
|
|
14
14
|
const ssr = "?ssr=true";
|
|
15
|
+
const coreReact = `${base}/react/runtime/core.js${ssr}`;
|
|
15
16
|
|
|
16
|
-
const head =
|
|
17
|
-
const router =
|
|
18
|
-
const context =
|
|
17
|
+
const head = coreReact;
|
|
18
|
+
const router = coreReact;
|
|
19
|
+
const context = coreReact;
|
|
19
20
|
const fonts = `${base}/react/fonts/index.js${ssr}`;
|
|
20
21
|
|
|
21
22
|
const markdown = `${base}/markdown/index.js${ssr}`;
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**************************************************
|
|
2
|
-
* OAuth Callback Handler
|
|
3
|
-
*
|
|
4
|
-
* Reusable handler for OAuth callback routes.
|
|
5
|
-
**************************************************/
|
|
6
1
|
import * as dntShim from "../../../_dnt.shims.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
2
|
import { logger as baseLogger } from "../../utils/index.js";
|
|
10
3
|
import { getEnv } from "../../platform/compat/process.js";
|
|
11
4
|
import {
|
|
@@ -93,24 +86,24 @@ export function createOAuthCallbackHandler(
|
|
|
93
86
|
const url = new URL(request.url);
|
|
94
87
|
const code = url.searchParams.get("code");
|
|
95
88
|
const state = url.searchParams.get("state");
|
|
96
|
-
const
|
|
89
|
+
const providerError = url.searchParams.get("error");
|
|
97
90
|
const errorDescription = url.searchParams.get("error_description");
|
|
98
91
|
|
|
99
92
|
const appUrl = getAppUrl();
|
|
100
93
|
|
|
101
|
-
if (
|
|
94
|
+
if (providerError) {
|
|
102
95
|
logger.error("Callback error", {
|
|
103
96
|
serviceId: config.serviceId,
|
|
104
|
-
error:
|
|
97
|
+
error: providerError,
|
|
105
98
|
description: errorDescription,
|
|
106
99
|
});
|
|
107
|
-
await onError?.(config.serviceId,
|
|
108
|
-
return redirectWithError(appUrl,
|
|
100
|
+
await onError?.(config.serviceId, providerError);
|
|
101
|
+
return redirectWithError(appUrl, providerError, errorDescription);
|
|
109
102
|
}
|
|
110
103
|
|
|
111
104
|
if (!code) return handleError(appUrl, "no_code");
|
|
112
105
|
|
|
113
|
-
let
|
|
106
|
+
let storedState: OAuthState | null = null;
|
|
114
107
|
|
|
115
108
|
if (!skipStateValidation && !state) {
|
|
116
109
|
return handleError(appUrl, "invalid_state", "Missing state parameter", {
|
|
@@ -119,8 +112,8 @@ export function createOAuthCallbackHandler(
|
|
|
119
112
|
}
|
|
120
113
|
|
|
121
114
|
if (state) {
|
|
122
|
-
|
|
123
|
-
if (!skipStateValidation && !
|
|
115
|
+
storedState = await tokenStore.getState(state);
|
|
116
|
+
if (!skipStateValidation && !storedState) {
|
|
124
117
|
return handleError(appUrl, "invalid_state", "Invalid or expired state", {
|
|
125
118
|
serviceId: config.serviceId,
|
|
126
119
|
});
|
|
@@ -134,7 +127,7 @@ export function createOAuthCallbackHandler(
|
|
|
134
127
|
const result = await service.exchangeCode({
|
|
135
128
|
code,
|
|
136
129
|
redirectUri,
|
|
137
|
-
codeVerifier:
|
|
130
|
+
codeVerifier: storedState?.codeVerifier,
|
|
138
131
|
});
|
|
139
132
|
|
|
140
133
|
if (!result.success || !result.tokens) {
|
|
@@ -10,6 +10,42 @@ import type { AuthorizationUrlOptions, OAuthServiceConfig, TokenStore } from "..
|
|
|
10
10
|
import { memoryTokenStore } from "../token-store/memory.js";
|
|
11
11
|
|
|
12
12
|
const logger = baseLogger.component("o-auth");
|
|
13
|
+
const DEFAULT_APP_URL = "http://localhost:3000";
|
|
14
|
+
|
|
15
|
+
function createUnauthorizedResponse(): dntShim.Response {
|
|
16
|
+
return dntShim.Response.json({ error: "Unauthorized" }, { status: 401 });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function isRequestUnauthorized(
|
|
20
|
+
req: dntShim.Request,
|
|
21
|
+
isAuthenticated?: (req: dntShim.Request) => boolean | Promise<boolean>,
|
|
22
|
+
): Promise<boolean> {
|
|
23
|
+
return isAuthenticated ? !(await isAuthenticated(req)) : false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function resolveAppUrl(baseUrl: string | undefined, env: EnvironmentConfig): string {
|
|
27
|
+
return baseUrl ?? env.appUrl ?? DEFAULT_APP_URL;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function createNotConfiguredResponse(config: OAuthServiceConfig): dntShim.Response {
|
|
31
|
+
return dntShim.Response.json(
|
|
32
|
+
{
|
|
33
|
+
error: `${config.displayName} OAuth not configured`,
|
|
34
|
+
details: `Missing ${config.clientIdEnvVar} or ${config.clientSecretEnvVar}`,
|
|
35
|
+
},
|
|
36
|
+
{ status: 500 },
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createInitErrorResponse(error: unknown): dntShim.Response {
|
|
41
|
+
return dntShim.Response.json(
|
|
42
|
+
{
|
|
43
|
+
error: "Failed to initiate OAuth flow",
|
|
44
|
+
details: error instanceof Error ? error.message : "Unknown error",
|
|
45
|
+
},
|
|
46
|
+
{ status: 500 },
|
|
47
|
+
);
|
|
48
|
+
}
|
|
13
49
|
|
|
14
50
|
export interface OAuthInitHandlerOptions {
|
|
15
51
|
/** Token store to use (defaults to memory store) */
|
|
@@ -32,25 +68,22 @@ export function createOAuthInitHandler(
|
|
|
32
68
|
config: OAuthServiceConfig,
|
|
33
69
|
options: OAuthInitHandlerOptions = {},
|
|
34
70
|
): () => Promise<dntShim.Response> {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
71
|
+
const {
|
|
72
|
+
tokenStore = memoryTokenStore,
|
|
73
|
+
baseUrl,
|
|
74
|
+
authOptions = {},
|
|
75
|
+
env = getEnvironmentConfig(),
|
|
76
|
+
envReader = getEnv,
|
|
77
|
+
} = options;
|
|
39
78
|
|
|
40
79
|
return async function handler(): Promise<dntShim.Response> {
|
|
41
80
|
const service = new OAuthService(config, tokenStore, envReader);
|
|
42
81
|
|
|
43
82
|
if (!service.isConfigured()) {
|
|
44
|
-
return
|
|
45
|
-
{
|
|
46
|
-
error: `${config.displayName} OAuth not configured`,
|
|
47
|
-
details: `Missing ${config.clientIdEnvVar} or ${config.clientSecretEnvVar}`,
|
|
48
|
-
},
|
|
49
|
-
{ status: 500 },
|
|
50
|
-
);
|
|
83
|
+
return createNotConfiguredResponse(config);
|
|
51
84
|
}
|
|
52
85
|
|
|
53
|
-
const appUrl =
|
|
86
|
+
const appUrl = resolveAppUrl(baseUrl, env);
|
|
54
87
|
const redirectUri = `${appUrl}/api/auth/${config.serviceId}/callback`;
|
|
55
88
|
|
|
56
89
|
try {
|
|
@@ -59,14 +92,7 @@ export function createOAuthInitHandler(
|
|
|
59
92
|
return dntShim.Response.redirect(url);
|
|
60
93
|
} catch (error) {
|
|
61
94
|
logger.error("Init error", { serviceId: config.serviceId }, error);
|
|
62
|
-
|
|
63
|
-
return dntShim.Response.json(
|
|
64
|
-
{
|
|
65
|
-
error: "Failed to initiate OAuth flow",
|
|
66
|
-
details: error instanceof Error ? error.message : "Unknown error",
|
|
67
|
-
},
|
|
68
|
-
{ status: 500 },
|
|
69
|
-
);
|
|
95
|
+
return createInitErrorResponse(error);
|
|
70
96
|
}
|
|
71
97
|
};
|
|
72
98
|
}
|
|
@@ -86,12 +112,15 @@ export function createOAuthStatusHandler(
|
|
|
86
112
|
config: OAuthServiceConfig,
|
|
87
113
|
options: OAuthStatusHandlerOptions = {},
|
|
88
114
|
): (req: dntShim.Request) => Promise<dntShim.Response> {
|
|
89
|
-
const
|
|
90
|
-
|
|
115
|
+
const {
|
|
116
|
+
tokenStore = memoryTokenStore,
|
|
117
|
+
envReader = getEnv,
|
|
118
|
+
isAuthenticated,
|
|
119
|
+
} = options;
|
|
91
120
|
|
|
92
121
|
return async function handler(req: dntShim.Request): Promise<dntShim.Response> {
|
|
93
|
-
if (
|
|
94
|
-
return
|
|
122
|
+
if (await isRequestUnauthorized(req, isAuthenticated)) {
|
|
123
|
+
return createUnauthorizedResponse();
|
|
95
124
|
}
|
|
96
125
|
|
|
97
126
|
const tokens = await tokenStore.getTokens(config.serviceId);
|
|
@@ -119,11 +148,11 @@ export function createOAuthDisconnectHandler(
|
|
|
119
148
|
isAuthenticated?: (req: dntShim.Request) => boolean | Promise<boolean>;
|
|
120
149
|
} = {},
|
|
121
150
|
): (req: dntShim.Request) => Promise<dntShim.Response> {
|
|
122
|
-
const tokenStore =
|
|
151
|
+
const { tokenStore = memoryTokenStore, isAuthenticated } = options;
|
|
123
152
|
|
|
124
153
|
return async function handler(req: dntShim.Request): Promise<dntShim.Response> {
|
|
125
|
-
if (
|
|
126
|
-
return
|
|
154
|
+
if (await isRequestUnauthorized(req, isAuthenticated)) {
|
|
155
|
+
return createUnauthorizedResponse();
|
|
127
156
|
}
|
|
128
157
|
|
|
129
158
|
await tokenStore.clearTokens(config.serviceId);
|
|
@@ -29,19 +29,19 @@ export class MemoryTokenStore implements TokenStore {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
async getState(state: string): Promise<OAuthState | null> {
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
32
|
+
const storedState = this.states.get(state);
|
|
33
|
+
if (!storedState) return null;
|
|
34
34
|
|
|
35
|
-
if (Date.now() -
|
|
35
|
+
if (Date.now() - storedState.createdAt > STATE_EXPIRATION_MS) {
|
|
36
36
|
this.states.delete(state);
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
return
|
|
40
|
+
return storedState;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
async setState(
|
|
44
|
-
this.states.set(
|
|
43
|
+
async setState(storedState: OAuthState): Promise<void> {
|
|
44
|
+
this.states.set(storedState.state, storedState);
|
|
45
45
|
this.cleanupExpiredStates();
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -51,8 +51,8 @@ export class MemoryTokenStore implements TokenStore {
|
|
|
51
51
|
|
|
52
52
|
private cleanupExpiredStates(): void {
|
|
53
53
|
const now = Date.now();
|
|
54
|
-
for (const [state,
|
|
55
|
-
if (now -
|
|
54
|
+
for (const [state, storedState] of this.states) {
|
|
55
|
+
if (now - storedState.createdAt > STATE_EXPIRATION_MS) {
|
|
56
56
|
this.states.delete(state);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import * as dntShim from "../../_dnt.shims.js";
|
|
2
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
+
|
|
4
|
+
export interface RequestProfileRecord {
|
|
5
|
+
sequence: number;
|
|
6
|
+
category: string;
|
|
7
|
+
method: string;
|
|
8
|
+
pathname: string;
|
|
9
|
+
projectSlug?: string;
|
|
10
|
+
requestMode?: string;
|
|
11
|
+
status?: number;
|
|
12
|
+
startedAt: string;
|
|
13
|
+
completedAt: string;
|
|
14
|
+
totalMs: number;
|
|
15
|
+
phases: Record<string, number>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface RequestProfileSession {
|
|
19
|
+
category: string;
|
|
20
|
+
method: string;
|
|
21
|
+
pathname: string;
|
|
22
|
+
projectSlug?: string;
|
|
23
|
+
requestMode?: string;
|
|
24
|
+
startedAt: number;
|
|
25
|
+
phases: Map<string, number>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const storage = new AsyncLocalStorage<RequestProfileSession>();
|
|
29
|
+
const records: RequestProfileRecord[] = [];
|
|
30
|
+
const MAX_RECORDS = 200;
|
|
31
|
+
let sequence = 0;
|
|
32
|
+
|
|
33
|
+
function roundMs(value: number): number {
|
|
34
|
+
return Math.round(value * 100) / 100;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function shouldEnableProfiling(): boolean {
|
|
38
|
+
return dntShim.Deno.env.get("VERYFRONT_ENABLE_PERF_PROFILING") === "1";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function shouldProfilePath(pathname: string): boolean {
|
|
42
|
+
return pathname.startsWith("/bench/") ||
|
|
43
|
+
pathname.startsWith("/api/bench/") ||
|
|
44
|
+
pathname.startsWith("/_vf_styles/") ||
|
|
45
|
+
pathname.startsWith("/_vf_modules/");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function isRequestProfilingEnabled(pathname?: string): boolean {
|
|
49
|
+
if (!shouldEnableProfiling()) return false;
|
|
50
|
+
if (!pathname) return true;
|
|
51
|
+
return shouldProfilePath(pathname);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export async function runWithRequestProfiling<T>(
|
|
55
|
+
options: {
|
|
56
|
+
category: string;
|
|
57
|
+
method: string;
|
|
58
|
+
pathname: string;
|
|
59
|
+
projectSlug?: string;
|
|
60
|
+
requestMode?: string;
|
|
61
|
+
},
|
|
62
|
+
fn: () => Promise<T>,
|
|
63
|
+
): Promise<T> {
|
|
64
|
+
if (!isRequestProfilingEnabled(options.pathname)) {
|
|
65
|
+
return await fn();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const session: RequestProfileSession = {
|
|
69
|
+
...options,
|
|
70
|
+
startedAt: performance.now(),
|
|
71
|
+
phases: new Map(),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return await storage.run(session, fn);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function profilePhase<T>(name: string, fn: () => Promise<T>): Promise<T> {
|
|
78
|
+
const session = storage.getStore();
|
|
79
|
+
if (!session) return await fn();
|
|
80
|
+
|
|
81
|
+
const startedAt = performance.now();
|
|
82
|
+
try {
|
|
83
|
+
return await fn();
|
|
84
|
+
} finally {
|
|
85
|
+
const duration = performance.now() - startedAt;
|
|
86
|
+
session.phases.set(name, roundMs((session.phases.get(name) ?? 0) + duration));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function profileSyncPhase<T>(name: string, fn: () => T): T {
|
|
91
|
+
const session = storage.getStore();
|
|
92
|
+
if (!session) return fn();
|
|
93
|
+
|
|
94
|
+
const startedAt = performance.now();
|
|
95
|
+
try {
|
|
96
|
+
return fn();
|
|
97
|
+
} finally {
|
|
98
|
+
const duration = performance.now() - startedAt;
|
|
99
|
+
session.phases.set(name, roundMs((session.phases.get(name) ?? 0) + duration));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function finalizeRequestProfiling(status?: number): void {
|
|
104
|
+
const session = storage.getStore();
|
|
105
|
+
if (!session) return;
|
|
106
|
+
|
|
107
|
+
const record: RequestProfileRecord = {
|
|
108
|
+
sequence: ++sequence,
|
|
109
|
+
category: session.category,
|
|
110
|
+
method: session.method,
|
|
111
|
+
pathname: session.pathname,
|
|
112
|
+
projectSlug: session.projectSlug,
|
|
113
|
+
requestMode: session.requestMode,
|
|
114
|
+
status,
|
|
115
|
+
startedAt: new Date(Date.now() - (performance.now() - session.startedAt)).toISOString(),
|
|
116
|
+
completedAt: new Date().toISOString(),
|
|
117
|
+
totalMs: roundMs(performance.now() - session.startedAt),
|
|
118
|
+
phases: Object.fromEntries(session.phases.entries()),
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
records.push(record);
|
|
122
|
+
while (records.length > MAX_RECORDS) records.shift();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function snapshotRequestProfiles(): {
|
|
126
|
+
enabled: boolean;
|
|
127
|
+
last_sequence: number;
|
|
128
|
+
records: RequestProfileRecord[];
|
|
129
|
+
} {
|
|
130
|
+
return {
|
|
131
|
+
enabled: shouldEnableProfiling(),
|
|
132
|
+
last_sequence: sequence,
|
|
133
|
+
records: [...records],
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function resetRequestProfiles(): void {
|
|
138
|
+
records.length = 0;
|
|
139
|
+
sequence = 0;
|
|
140
|
+
}
|
|
@@ -69,11 +69,6 @@ async function ensureApis(): Promise<void> {
|
|
|
69
69
|
propagationApi = await import("@opentelemetry/core");
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function getServiceName(): string {
|
|
73
|
-
const tracingConfig = getOtelTracingConfig();
|
|
74
|
-
return tracingConfig.serviceName || "veryfront";
|
|
75
|
-
}
|
|
76
|
-
|
|
77
72
|
function setSpanErrorStatus(span: import("@opentelemetry/api").Span, error: unknown): void {
|
|
78
73
|
if (!traceApi) return;
|
|
79
74
|
|
|
@@ -183,9 +178,9 @@ export async function withSpan<T>(
|
|
|
183
178
|
fn: () => Promise<T>,
|
|
184
179
|
attributes?: Record<string, string | number | boolean>,
|
|
185
180
|
): Promise<T> {
|
|
186
|
-
if (!traceApi || !isOTLPEnabled()) return
|
|
181
|
+
if (!traceApi || !isOTLPEnabled()) return fn();
|
|
187
182
|
|
|
188
|
-
const tracer = traceApi.trace.getTracer(
|
|
183
|
+
const tracer = traceApi.trace.getTracer(getConfig().serviceName);
|
|
189
184
|
const parentContext = traceApi.context.active();
|
|
190
185
|
|
|
191
186
|
const span = tracer.startSpan(
|
|
@@ -215,7 +210,7 @@ export function withSpanSync<T>(
|
|
|
215
210
|
): T {
|
|
216
211
|
if (!traceApi || !isOTLPEnabled()) return fn();
|
|
217
212
|
|
|
218
|
-
const tracer = traceApi.trace.getTracer(
|
|
213
|
+
const tracer = traceApi.trace.getTracer(getConfig().serviceName);
|
|
219
214
|
const parentContext = traceApi.context.active();
|
|
220
215
|
|
|
221
216
|
const span = tracer.startSpan(
|
|
@@ -271,7 +266,7 @@ export function startServerSpan(
|
|
|
271
266
|
): { span: unknown; context: unknown } | null {
|
|
272
267
|
if (!traceApi || !isOTLPEnabled()) return null;
|
|
273
268
|
|
|
274
|
-
const tracer = traceApi.trace.getTracer(
|
|
269
|
+
const tracer = traceApi.trace.getTracer(getConfig().serviceName);
|
|
275
270
|
const ctx = (parentContext || traceApi.context.active()) as import("@opentelemetry/api").Context;
|
|
276
271
|
|
|
277
272
|
const span = tracer.startSpan(`${method} ${path}`, { kind: traceApi.SpanKind.SERVER }, ctx);
|
|
@@ -284,24 +279,23 @@ export function startServerSpan(
|
|
|
284
279
|
export function endServerSpan(span: unknown, statusCode: number, error?: Error): void {
|
|
285
280
|
if (!span || !traceApi) return;
|
|
286
281
|
|
|
287
|
-
const
|
|
288
|
-
|
|
282
|
+
const otelSpan = span as import("@opentelemetry/api").Span;
|
|
283
|
+
otelSpan.setAttribute("http.status_code", statusCode);
|
|
289
284
|
|
|
290
285
|
if (error) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
s.end();
|
|
286
|
+
setSpanErrorStatus(otelSpan, error);
|
|
287
|
+
otelSpan.end();
|
|
294
288
|
return;
|
|
295
289
|
}
|
|
296
290
|
|
|
297
291
|
if (statusCode >= 400) {
|
|
298
|
-
|
|
299
|
-
|
|
292
|
+
otelSpan.setStatus({ code: traceApi.SpanStatusCode.ERROR });
|
|
293
|
+
otelSpan.end();
|
|
300
294
|
return;
|
|
301
295
|
}
|
|
302
296
|
|
|
303
|
-
|
|
304
|
-
|
|
297
|
+
otelSpan.setStatus({ code: traceApi.SpanStatusCode.OK });
|
|
298
|
+
otelSpan.end();
|
|
305
299
|
}
|
|
306
300
|
|
|
307
301
|
export function setSpanAttributes(
|
|
@@ -310,8 +304,8 @@ export function setSpanAttributes(
|
|
|
310
304
|
): void {
|
|
311
305
|
if (!span || !traceApi) return;
|
|
312
306
|
|
|
313
|
-
const
|
|
314
|
-
for (const [key, value] of Object.entries(attributes))
|
|
307
|
+
const otelSpan = span as import("@opentelemetry/api").Span;
|
|
308
|
+
for (const [key, value] of Object.entries(attributes)) otelSpan.setAttribute(key, value);
|
|
315
309
|
}
|
|
316
310
|
|
|
317
311
|
export function setActiveSpanAttributes(
|
|
@@ -326,8 +320,8 @@ export function setActiveSpanAttributes(
|
|
|
326
320
|
}
|
|
327
321
|
|
|
328
322
|
export async function withContext<T>(spanContext: unknown, fn: () => Promise<T>): Promise<T> {
|
|
329
|
-
if (!traceApi) return
|
|
330
|
-
return
|
|
323
|
+
if (!traceApi) return fn();
|
|
324
|
+
return traceApi.context.with(spanContext as import("@opentelemetry/api").Context, fn);
|
|
331
325
|
}
|
|
332
326
|
|
|
333
327
|
export function getTraceContext(): { traceId?: string; spanId?: string } {
|
|
@@ -2,24 +2,27 @@ import type { Prompt, PromptConfig } from "./types.js";
|
|
|
2
2
|
import { createError, toError } from "../errors/veryfront-error.js";
|
|
3
3
|
import { COMMON_BLOCKED_PATTERNS } from "../agent/middleware/security/validator.js";
|
|
4
4
|
|
|
5
|
+
type PromptGenerateFn = (variables: Record<string, unknown>) => string | Promise<string>;
|
|
6
|
+
|
|
7
|
+
const BLOCKED_PROMPT_PATTERNS = COMMON_BLOCKED_PATTERNS.promptInjection;
|
|
8
|
+
|
|
5
9
|
export function prompt(config: PromptConfig): Prompt {
|
|
10
|
+
const { content, description, generate, suggestion } = config;
|
|
6
11
|
const id = config.id ?? generatePromptId();
|
|
7
12
|
|
|
8
13
|
return {
|
|
9
14
|
id,
|
|
10
|
-
description
|
|
11
|
-
suggestion
|
|
15
|
+
description,
|
|
16
|
+
suggestion,
|
|
12
17
|
async getContent(variables?: Record<string, unknown>): Promise<string> {
|
|
13
|
-
const
|
|
18
|
+
const resolvedVariables = variables ?? {};
|
|
14
19
|
|
|
15
|
-
if (
|
|
16
|
-
return interpolateVariables(
|
|
20
|
+
if (content) {
|
|
21
|
+
return interpolateVariables(content, resolvedVariables);
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
type GenerateFn = (vars: Record<string, unknown>) => string | Promise<string>;
|
|
22
|
-
return (config.generate as GenerateFn)(vars);
|
|
24
|
+
if (generate) {
|
|
25
|
+
return (generate as PromptGenerateFn)(resolvedVariables);
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
throw toError(
|
|
@@ -39,11 +42,10 @@ function generatePromptId(): string {
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
function sanitizeVariableValue(value: string): string {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return sanitized;
|
|
45
|
+
return BLOCKED_PROMPT_PATTERNS.reduce(
|
|
46
|
+
(sanitizedValue, pattern) => sanitizedValue.replace(pattern, ""),
|
|
47
|
+
value,
|
|
48
|
+
);
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
function interpolateVariables(
|
|
@@ -3,21 +3,22 @@ import { createError, toError } from "../errors/veryfront-error.js";
|
|
|
3
3
|
import { ProjectScopedRegistryManager } from "../ai/registry-manager.js";
|
|
4
4
|
import { ScopedRegistryFacade } from "../ai/registry-facade.js";
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const promptRegistryManager = new ProjectScopedRegistryManager<Prompt>("prompt");
|
|
7
|
+
|
|
8
|
+
function createMissingPromptError(id: string): Error {
|
|
9
|
+
return toError(
|
|
10
|
+
createError({
|
|
11
|
+
type: "agent",
|
|
12
|
+
message: `Prompt "${id}" not found`,
|
|
13
|
+
}),
|
|
14
|
+
);
|
|
15
|
+
}
|
|
7
16
|
|
|
8
17
|
class PromptRegistryClass extends ScopedRegistryFacade<Prompt> {
|
|
9
18
|
getContent(id: string, variables?: Record<string, unknown>): Promise<string> {
|
|
10
|
-
const
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
createError({
|
|
14
|
-
type: "agent",
|
|
15
|
-
message: `Prompt "${id}" not found`,
|
|
16
|
-
}),
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return promptInstance.getContent(variables);
|
|
19
|
+
const registeredPrompt = this.get(id);
|
|
20
|
+
if (registeredPrompt) return registeredPrompt.getContent(variables);
|
|
21
|
+
throw createMissingPromptError(id);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
list(): string[] {
|
|
@@ -25,4 +26,4 @@ class PromptRegistryClass extends ScopedRegistryFacade<Prompt> {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
export const promptRegistry = new PromptRegistryClass(
|
|
29
|
+
export const promptRegistry = new PromptRegistryClass(promptRegistryManager);
|
|
@@ -9,8 +9,4 @@ export const PromptConfigSchema = z.object({
|
|
|
9
9
|
suggestion: z.string().optional(),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
// Inferred type
|
|
13
12
|
export type PromptConfig = z.infer<typeof PromptConfigSchema>;
|
|
14
|
-
|
|
15
|
-
// Note: Prompt interface with getContent method stays as TypeScript interface
|
|
16
|
-
// since it includes a method that returns a Promise
|