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
|
@@ -7,14 +7,23 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { serverLogger } from "../../utils/index.js";
|
|
10
|
+
import { join } from "../../platform/compat/path/index.js";
|
|
11
|
+
import { createFileSystem, type FileSystem } from "../../platform/compat/fs.js";
|
|
10
12
|
import { extractCandidatesFromFiles, getProjectCSS } from "./tailwind-compiler.js";
|
|
11
13
|
import {
|
|
12
14
|
createPreparedProjectCSSContext,
|
|
13
15
|
storePreparedProjectCSS,
|
|
16
|
+
tryGetPreparedProjectCSS,
|
|
14
17
|
} from "./prepared-project-css-cache.js";
|
|
15
|
-
import
|
|
18
|
+
import {
|
|
19
|
+
shouldIncludeStylePath,
|
|
20
|
+
shouldTraverseStyleDirectory,
|
|
21
|
+
type StyleScopeProfile,
|
|
22
|
+
} from "./style-scope-profile.js";
|
|
16
23
|
|
|
17
24
|
const logger = serverLogger.component("css-pregeneration");
|
|
25
|
+
const inFlightPreparedCSSBuilds = new Map<string, Promise<void>>();
|
|
26
|
+
const SOURCE_EXTENSIONS = [".tsx", ".jsx", ".mdx", ".ts", ".js"];
|
|
18
27
|
|
|
19
28
|
interface CSSPregenerationOptions {
|
|
20
29
|
/** Project slug for cache keying */
|
|
@@ -47,6 +56,12 @@ export interface PreparedCSSArtifactBuildResult {
|
|
|
47
56
|
context: ReturnType<typeof createPreparedProjectCSSContext>;
|
|
48
57
|
}
|
|
49
58
|
|
|
59
|
+
interface LocalProjectSourceFilesOptions {
|
|
60
|
+
projectDir: string;
|
|
61
|
+
styleProfile: StyleScopeProfile;
|
|
62
|
+
fs?: FileSystem;
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
export async function buildPreparedCSSArtifactFromFiles(
|
|
51
66
|
options: CSSPregenerationOptions,
|
|
52
67
|
): Promise<PreparedCSSArtifactBuildResult> {
|
|
@@ -93,6 +108,123 @@ export async function buildPreparedCSSArtifactFromFiles(
|
|
|
93
108
|
};
|
|
94
109
|
}
|
|
95
110
|
|
|
111
|
+
export async function collectLocalProjectSourceFiles(
|
|
112
|
+
options: LocalProjectSourceFilesOptions,
|
|
113
|
+
): Promise<Array<{ path: string; content?: string }>> {
|
|
114
|
+
const fs = options.fs ?? createFileSystem();
|
|
115
|
+
const files: Array<{ path: string; content?: string }> = [];
|
|
116
|
+
|
|
117
|
+
const scanDir = async (directoryPath: string): Promise<void> => {
|
|
118
|
+
let entries: AsyncIterable<{ name: string; isFile: boolean; isDirectory: boolean }>;
|
|
119
|
+
try {
|
|
120
|
+
entries = fs.readDir(directoryPath);
|
|
121
|
+
} catch {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for await (const entry of entries) {
|
|
126
|
+
const fullPath = join(directoryPath, entry.name);
|
|
127
|
+
|
|
128
|
+
if (entry.isDirectory) {
|
|
129
|
+
if (shouldTraverseStyleDirectory(options.styleProfile, fullPath, options.projectDir)) {
|
|
130
|
+
await scanDir(fullPath);
|
|
131
|
+
}
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!entry.isFile) continue;
|
|
136
|
+
if (!shouldIncludeStylePath(options.styleProfile, fullPath, options.projectDir)) continue;
|
|
137
|
+
if (!SOURCE_EXTENSIONS.some((extension) => entry.name.endsWith(extension))) continue;
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
files.push({
|
|
141
|
+
path: fullPath,
|
|
142
|
+
content: await fs.readTextFile(fullPath),
|
|
143
|
+
});
|
|
144
|
+
} catch {
|
|
145
|
+
// ignore unreadable files during warmup
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
await scanDir(options.projectDir);
|
|
151
|
+
return files;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export async function readLocalProjectStylesheet(
|
|
155
|
+
projectDir: string,
|
|
156
|
+
stylesheetPath?: string,
|
|
157
|
+
fs: FileSystem = createFileSystem(),
|
|
158
|
+
): Promise<string | undefined> {
|
|
159
|
+
const candidatePaths = stylesheetPath ? [stylesheetPath.replace(/^\/+/, "")] : [
|
|
160
|
+
"globals.css",
|
|
161
|
+
"global.css",
|
|
162
|
+
"styles/globals.css",
|
|
163
|
+
"app/globals.css",
|
|
164
|
+
"src/globals.css",
|
|
165
|
+
"src/styles/globals.css",
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
for (const relativePath of candidatePaths) {
|
|
169
|
+
const absolutePath = join(projectDir, relativePath);
|
|
170
|
+
try {
|
|
171
|
+
return await fs.readTextFile(absolutePath);
|
|
172
|
+
} catch {
|
|
173
|
+
// keep searching
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Trigger prepared CSS generation in the background when the artifact is not
|
|
182
|
+
* already cached or currently being built.
|
|
183
|
+
*/
|
|
184
|
+
export async function warmPreparedCSSArtifactFromFiles(
|
|
185
|
+
options: CSSPregenerationOptions,
|
|
186
|
+
): Promise<boolean> {
|
|
187
|
+
const stylesheet = options.stylesheet ??
|
|
188
|
+
findStylesheetFromFiles(options.files, options.stylesheetPath);
|
|
189
|
+
const context = createPreparedProjectCSSContext(
|
|
190
|
+
options.projectSlug,
|
|
191
|
+
options.projectVersion,
|
|
192
|
+
stylesheet,
|
|
193
|
+
options.styleProfile.hash,
|
|
194
|
+
{
|
|
195
|
+
minify: options.minify ?? true,
|
|
196
|
+
environment: options.environment ?? "preview",
|
|
197
|
+
buildMode: options.buildMode ?? "production",
|
|
198
|
+
},
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
if (await tryGetPreparedProjectCSS(context)) return false;
|
|
202
|
+
if (inFlightPreparedCSSBuilds.has(context.cacheKey)) return false;
|
|
203
|
+
|
|
204
|
+
const task = buildPreparedCSSArtifactFromFiles({
|
|
205
|
+
...options,
|
|
206
|
+
stylesheet,
|
|
207
|
+
}).then(() => {
|
|
208
|
+
logger.debug("Warm prepared CSS complete", {
|
|
209
|
+
projectSlug: options.projectSlug,
|
|
210
|
+
projectVersion: options.projectVersion,
|
|
211
|
+
cacheKey: context.cacheKey,
|
|
212
|
+
});
|
|
213
|
+
}).catch((error) => {
|
|
214
|
+
logger.debug("Warm prepared CSS failed", {
|
|
215
|
+
projectSlug: options.projectSlug,
|
|
216
|
+
projectVersion: options.projectVersion,
|
|
217
|
+
cacheKey: context.cacheKey,
|
|
218
|
+
error: error instanceof Error ? error.message : String(error),
|
|
219
|
+
});
|
|
220
|
+
}).finally(() => {
|
|
221
|
+
inFlightPreparedCSSBuilds.delete(context.cacheKey);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
inFlightPreparedCSSBuilds.set(context.cacheKey, task);
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
|
|
96
228
|
/**
|
|
97
229
|
* Pre-generate and cache CSS from file list.
|
|
98
230
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Z_INDEX_ERROR_OVERLAY } from "../../utils/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { buildNonceAttribute } from "../html-escape.js";
|
|
3
3
|
|
|
4
4
|
export function getDevStyles(nonce?: string): string {
|
|
5
|
-
const nonceAttr =
|
|
5
|
+
const nonceAttr = buildNonceAttribute(nonce);
|
|
6
6
|
|
|
7
7
|
return `
|
|
8
8
|
<style${nonceAttr}>
|
package/src/src/html/utils.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { VERYFRONT_VERSION } from "../utils/constants/cdn.js";
|
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_REACT_VERSION,
|
|
6
6
|
esmShReact,
|
|
7
|
+
readProjectDependencyVersions,
|
|
7
8
|
resolveProjectReactVersion,
|
|
8
9
|
stripSemverRange,
|
|
9
10
|
} from "../transforms/esm/package-registry.js";
|
|
@@ -32,21 +33,30 @@ interface DetectedVersions {
|
|
|
32
33
|
veryfront: string;
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
interface CachedImportMapEntry {
|
|
37
|
+
cacheKey: string;
|
|
38
|
+
json: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
const DEFAULT_VERSIONS: DetectedVersions = {
|
|
36
42
|
react: DEFAULT_REACT_VERSION,
|
|
37
43
|
veryfront: VERYFRONT_VERSION,
|
|
38
44
|
};
|
|
39
45
|
|
|
46
|
+
const importMapJsonCache = new Map<string, CachedImportMapEntry>();
|
|
47
|
+
|
|
40
48
|
type CdnProvider = "esm.sh" | "unpkg" | "jsdelivr";
|
|
41
49
|
|
|
42
50
|
// Platform utilities served from local module server to match SSR behavior.
|
|
43
51
|
// This ensures hydration matches (same code on server and client).
|
|
44
52
|
// CRITICAL: veryfront/context must use local module to share React context with SSR.
|
|
45
53
|
// Using esm.sh creates a separate context instance causing usePageContext to return undefined.
|
|
54
|
+
const CORE_REACT_RUNTIME_PATH = "/_vf_modules/_veryfront/react/runtime/core.js";
|
|
55
|
+
|
|
46
56
|
const PLATFORM_UTILITY_PATHS = {
|
|
47
|
-
head:
|
|
48
|
-
router:
|
|
49
|
-
context:
|
|
57
|
+
head: CORE_REACT_RUNTIME_PATH,
|
|
58
|
+
router: CORE_REACT_RUNTIME_PATH,
|
|
59
|
+
context: CORE_REACT_RUNTIME_PATH,
|
|
50
60
|
fonts: "/_vf_modules/_veryfront/react/fonts/index.js",
|
|
51
61
|
// Client-side AI/chat modules - use local module server in dev for faster iteration
|
|
52
62
|
// NOTE: These are NOT available in compiled binaries, so we use CDN URLs there instead
|
|
@@ -201,58 +211,63 @@ async function resolveVersions(
|
|
|
201
211
|
config?: VeryfrontConfig,
|
|
202
212
|
): Promise<DetectedVersions> {
|
|
203
213
|
// Use shared resolver for React (handles config override + package.json + fallback)
|
|
204
|
-
const
|
|
214
|
+
const versionsConfig = config?.client?.cdn?.versions;
|
|
215
|
+
const configuredReactVersion = versionsConfig && versionsConfig !== "auto"
|
|
216
|
+
? versionsConfig.react
|
|
217
|
+
: undefined;
|
|
218
|
+
const configuredVeryfrontVersion = versionsConfig && versionsConfig !== "auto"
|
|
219
|
+
? versionsConfig.veryfront
|
|
220
|
+
: undefined;
|
|
221
|
+
const detected = await readProjectDependencyVersions(projectDir);
|
|
222
|
+
const reactVersion = configuredReactVersion
|
|
223
|
+
? resolveProjectReactVersion({ config })
|
|
224
|
+
: Promise.resolve(detected.react ?? DEFAULT_VERSIONS.react);
|
|
205
225
|
|
|
206
226
|
// Resolve veryfront version separately (config override or detection)
|
|
207
|
-
const versionsConfig = config?.client?.cdn?.versions;
|
|
208
227
|
let veryfrontVersion = DEFAULT_VERSIONS.veryfront;
|
|
209
228
|
|
|
210
|
-
if (
|
|
211
|
-
veryfrontVersion =
|
|
212
|
-
} else {
|
|
213
|
-
|
|
214
|
-
const { createFileSystem } = await import("../platform/compat/fs.js");
|
|
215
|
-
const fs = createFileSystem();
|
|
216
|
-
const content = await fs.readTextFile(`${projectDir}/package.json`);
|
|
217
|
-
const pkg = JSON.parse(content) as {
|
|
218
|
-
dependencies?: Record<string, string>;
|
|
219
|
-
devDependencies?: Record<string, string>;
|
|
220
|
-
};
|
|
221
|
-
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
222
|
-
if (deps.veryfront) {
|
|
223
|
-
veryfrontVersion = stripSemverRange(deps.veryfront);
|
|
224
|
-
}
|
|
225
|
-
} catch (_) {
|
|
226
|
-
/* expected: package.json may not exist or be unreadable */
|
|
227
|
-
}
|
|
229
|
+
if (configuredVeryfrontVersion) {
|
|
230
|
+
veryfrontVersion = stripSemverRange(configuredVeryfrontVersion);
|
|
231
|
+
} else if (detected.veryfront) {
|
|
232
|
+
veryfrontVersion = detected.veryfront;
|
|
228
233
|
}
|
|
229
234
|
|
|
230
|
-
return { react: reactVersion, veryfront: veryfrontVersion };
|
|
235
|
+
return { react: await reactVersion, veryfront: veryfrontVersion };
|
|
231
236
|
}
|
|
232
237
|
|
|
233
238
|
interface BuildImportMapOptions {
|
|
234
239
|
projectDir?: string;
|
|
235
240
|
config?: VeryfrontConfig;
|
|
236
241
|
customImports?: Record<string, string>;
|
|
242
|
+
pretty?: boolean;
|
|
237
243
|
}
|
|
238
244
|
|
|
239
245
|
function isImportMapOnlyOptions(
|
|
240
246
|
options: BuildImportMapOptions | Record<string, string>,
|
|
241
247
|
): options is Record<string, string> {
|
|
242
|
-
return !("projectDir" in options) &&
|
|
248
|
+
return !("projectDir" in options) &&
|
|
249
|
+
!("config" in options) &&
|
|
250
|
+
!("customImports" in options) &&
|
|
251
|
+
!("pretty" in options);
|
|
243
252
|
}
|
|
244
253
|
|
|
245
254
|
export async function buildImportMapJson(
|
|
246
255
|
options?: BuildImportMapOptions | Record<string, string>,
|
|
247
256
|
): Promise<string> {
|
|
257
|
+
const stringifyImportMap = (imports: Record<string, string>, pretty = true) =>
|
|
258
|
+
JSON.stringify({ imports }, null, pretty ? 2 : undefined);
|
|
259
|
+
const stableMapKey = (imports?: Record<string, string>) =>
|
|
260
|
+
imports ? JSON.stringify(Object.entries(imports).sort(([a], [b]) => a.localeCompare(b))) : "";
|
|
261
|
+
|
|
248
262
|
if (options && isImportMapOnlyOptions(options)) {
|
|
249
263
|
const imports = options;
|
|
250
264
|
if (Object.keys(imports).length > 0) {
|
|
251
|
-
return
|
|
265
|
+
return stringifyImportMap(imports);
|
|
252
266
|
}
|
|
253
267
|
}
|
|
254
268
|
|
|
255
|
-
const { projectDir, config, customImports
|
|
269
|
+
const { projectDir, config, customImports, pretty = true } =
|
|
270
|
+
(options ?? {}) as BuildImportMapOptions;
|
|
256
271
|
const mode = config?.client?.moduleResolution ?? "cdn";
|
|
257
272
|
const versions = projectDir ? await resolveVersions(projectDir, config) : DEFAULT_VERSIONS;
|
|
258
273
|
|
|
@@ -267,7 +282,7 @@ export async function buildImportMapJson(
|
|
|
267
282
|
...customImports,
|
|
268
283
|
};
|
|
269
284
|
|
|
270
|
-
return
|
|
285
|
+
return stringifyImportMap(imports, pretty);
|
|
271
286
|
}
|
|
272
287
|
|
|
273
288
|
let imports: Record<string, string>;
|
|
@@ -283,7 +298,25 @@ export async function buildImportMapJson(
|
|
|
283
298
|
imports = { ...imports, ...customImports };
|
|
284
299
|
}
|
|
285
300
|
|
|
286
|
-
|
|
301
|
+
const cacheKey = JSON.stringify({
|
|
302
|
+
projectDir: projectDir ?? "",
|
|
303
|
+
mode,
|
|
304
|
+
provider: config?.client?.cdn?.provider ?? "esm.sh",
|
|
305
|
+
react: versions.react,
|
|
306
|
+
veryfront: versions.veryfront,
|
|
307
|
+
pretty,
|
|
308
|
+
customImports: stableMapKey(customImports),
|
|
309
|
+
});
|
|
310
|
+
const cached = importMapJsonCache.get(cacheKey);
|
|
311
|
+
if (cached) return cached.json;
|
|
312
|
+
|
|
313
|
+
const json = stringifyImportMap(imports, pretty);
|
|
314
|
+
importMapJsonCache.set(cacheKey, { cacheKey, json });
|
|
315
|
+
return json;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export function clearImportMapCache(): void {
|
|
319
|
+
importMapJsonCache.clear();
|
|
287
320
|
}
|
|
288
321
|
|
|
289
322
|
export function shouldDisableLayout(frontmatter?: Record<string, unknown>): boolean {
|
|
@@ -26,6 +26,10 @@ interface RemoteToolDefinition {
|
|
|
26
26
|
inputSchema: Record<string, unknown>;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
interface CallToolTextContent {
|
|
30
|
+
text?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
// ---------------------------------------------------------------------------
|
|
30
34
|
// Per-request token resolution
|
|
31
35
|
// ---------------------------------------------------------------------------
|
|
@@ -50,19 +54,27 @@ function resolveRequestToken(): string | undefined {
|
|
|
50
54
|
return getApiTokenEnv();
|
|
51
55
|
}
|
|
52
56
|
|
|
53
|
-
function resolveApiBaseUrl(): string | undefined {
|
|
54
|
-
return getApiBaseUrlEnv();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
57
|
// ---------------------------------------------------------------------------
|
|
58
58
|
// API communication
|
|
59
59
|
// ---------------------------------------------------------------------------
|
|
60
60
|
|
|
61
|
+
function joinCallToolText(content: CallToolTextContent[]): string {
|
|
62
|
+
return content.map((item) => item.text).join("\n");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function parseJsonText(text: string): unknown | undefined {
|
|
66
|
+
try {
|
|
67
|
+
return JSON.parse(text);
|
|
68
|
+
} catch {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
61
73
|
async function fetchToolList(
|
|
62
74
|
baseUrl: string,
|
|
63
75
|
token: string,
|
|
64
76
|
): Promise<RemoteToolDefinition[]> {
|
|
65
|
-
const
|
|
77
|
+
const response = await dntShim.fetch(`${baseUrl}/integrations/tools/list`, {
|
|
66
78
|
method: "POST",
|
|
67
79
|
headers: {
|
|
68
80
|
Authorization: `Bearer ${token}`,
|
|
@@ -70,14 +82,14 @@ async function fetchToolList(
|
|
|
70
82
|
},
|
|
71
83
|
});
|
|
72
84
|
|
|
73
|
-
if (!
|
|
85
|
+
if (!response.ok) {
|
|
74
86
|
logger.warn("Failed to fetch integration tools from API", {
|
|
75
|
-
status:
|
|
87
|
+
status: response.status,
|
|
76
88
|
});
|
|
77
89
|
return [];
|
|
78
90
|
}
|
|
79
91
|
|
|
80
|
-
const data = (await
|
|
92
|
+
const data = (await response.json()) as { tools: RemoteToolDefinition[] };
|
|
81
93
|
return data.tools ?? [];
|
|
82
94
|
}
|
|
83
95
|
|
|
@@ -88,7 +100,7 @@ async function callRemoteTool(
|
|
|
88
100
|
args: Record<string, unknown>,
|
|
89
101
|
endUserId?: string,
|
|
90
102
|
): Promise<unknown> {
|
|
91
|
-
const
|
|
103
|
+
const response = await dntShim.fetch(`${baseUrl}/integrations/tools/call`, {
|
|
92
104
|
method: "POST",
|
|
93
105
|
headers: {
|
|
94
106
|
Authorization: `Bearer ${token}`,
|
|
@@ -101,37 +113,27 @@ async function callRemoteTool(
|
|
|
101
113
|
}),
|
|
102
114
|
});
|
|
103
115
|
|
|
104
|
-
if (!
|
|
105
|
-
const text = await
|
|
106
|
-
return { error: "api_error", status:
|
|
116
|
+
if (!response.ok) {
|
|
117
|
+
const text = await response.text();
|
|
118
|
+
return { error: "api_error", status: response.status, message: text };
|
|
107
119
|
}
|
|
108
120
|
|
|
109
|
-
const result = await
|
|
121
|
+
const result = await response.json();
|
|
110
122
|
|
|
111
123
|
// If MCP CallToolResult format, extract content
|
|
112
124
|
if (result?.content && Array.isArray(result.content)) {
|
|
125
|
+
const text = joinCallToolText(result.content as CallToolTextContent[]);
|
|
126
|
+
|
|
113
127
|
if (result.isError) {
|
|
114
|
-
const errorText = result.content
|
|
115
|
-
.map((c: { text?: string }) => c.text)
|
|
116
|
-
.join("\n");
|
|
117
128
|
// Try to preserve structured error data (e.g., authentication_required with connectUrl)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
} catch {
|
|
122
|
-
// Not JSON
|
|
123
|
-
}
|
|
124
|
-
return { error: "tool_error", message: errorText };
|
|
129
|
+
const parsed = parseJsonText(text);
|
|
130
|
+
if (parsed && typeof parsed === "object") return parsed;
|
|
131
|
+
return { error: "tool_error", message: text };
|
|
125
132
|
}
|
|
133
|
+
|
|
126
134
|
if (result.structuredContent) return result.structuredContent;
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
.join("\n");
|
|
130
|
-
try {
|
|
131
|
-
return JSON.parse(text);
|
|
132
|
-
} catch {
|
|
133
|
-
return text;
|
|
134
|
-
}
|
|
135
|
+
|
|
136
|
+
return parseJsonText(text) ?? text;
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
return result;
|
|
@@ -152,7 +154,7 @@ async function callRemoteTool(
|
|
|
152
154
|
export async function getRemoteIntegrationToolDefinitions(): Promise<
|
|
153
155
|
ToolDefinition[]
|
|
154
156
|
> {
|
|
155
|
-
const baseUrl =
|
|
157
|
+
const baseUrl = getApiBaseUrlEnv();
|
|
156
158
|
const token = resolveRequestToken();
|
|
157
159
|
if (!baseUrl || !token) return [];
|
|
158
160
|
|
|
@@ -190,7 +192,7 @@ export async function executeRemoteIntegrationTool(
|
|
|
190
192
|
args: Record<string, unknown>,
|
|
191
193
|
endUserId?: string,
|
|
192
194
|
): Promise<unknown> {
|
|
193
|
-
const baseUrl =
|
|
195
|
+
const baseUrl = getApiBaseUrlEnv();
|
|
194
196
|
const token = resolveRequestToken();
|
|
195
197
|
if (!baseUrl || !token) {
|
|
196
198
|
return { error: "no_api_token", message: "No API token available" };
|
|
@@ -210,7 +212,7 @@ export async function syncIntegrationConfig(
|
|
|
210
212
|
integrations: Record<string, { scope?: string; tools?: string[] }>,
|
|
211
213
|
): Promise<void> {
|
|
212
214
|
try {
|
|
213
|
-
const
|
|
215
|
+
const response = await dntShim.fetch(`${apiBaseUrl}/integrations/config`, {
|
|
214
216
|
method: "POST",
|
|
215
217
|
headers: {
|
|
216
218
|
Authorization: `Bearer ${apiToken}`,
|
|
@@ -219,12 +221,12 @@ export async function syncIntegrationConfig(
|
|
|
219
221
|
body: JSON.stringify({ integrations }),
|
|
220
222
|
});
|
|
221
223
|
|
|
222
|
-
if (!
|
|
224
|
+
if (!response.ok) {
|
|
223
225
|
logger.warn("Failed to sync integration config to API", {
|
|
224
|
-
status:
|
|
226
|
+
status: response.status,
|
|
225
227
|
});
|
|
226
228
|
} else {
|
|
227
|
-
const data = (await
|
|
229
|
+
const data = (await response.json()) as { synced: number };
|
|
228
230
|
logger.info("Synced integration config to API", { synced: data.synced });
|
|
229
231
|
}
|
|
230
232
|
} catch (err) {
|
|
@@ -20,7 +20,6 @@ export interface RunFinishedMetadata {
|
|
|
20
20
|
export interface StreamTransformState {
|
|
21
21
|
messageId: string | null;
|
|
22
22
|
textOpen: boolean;
|
|
23
|
-
stepIndex: number;
|
|
24
23
|
sawTerminalError: boolean;
|
|
25
24
|
metadata: RunFinishedMetadata;
|
|
26
25
|
}
|
|
@@ -29,7 +28,6 @@ export function createStreamTransformState(): StreamTransformState {
|
|
|
29
28
|
return {
|
|
30
29
|
messageId: null,
|
|
31
30
|
textOpen: false,
|
|
32
|
-
stepIndex: 0,
|
|
33
31
|
sawTerminalError: false,
|
|
34
32
|
metadata: {},
|
|
35
33
|
};
|
|
@@ -68,12 +66,6 @@ const agUiEventPayloadSchemas = {
|
|
|
68
66
|
result: z.unknown(),
|
|
69
67
|
isError: z.boolean().optional(),
|
|
70
68
|
}),
|
|
71
|
-
StepStarted: z.object({
|
|
72
|
-
stepIndex: z.number().int().positive(),
|
|
73
|
-
}),
|
|
74
|
-
StepFinished: z.object({
|
|
75
|
-
stepIndex: z.number().int().positive(),
|
|
76
|
-
}),
|
|
77
69
|
RunError: z.object({
|
|
78
70
|
code: z.string().min(1).optional(),
|
|
79
71
|
message: z.string().min(1),
|
|
@@ -267,17 +259,10 @@ export function mapRuntimeEventToAgUi(
|
|
|
267
259
|
}];
|
|
268
260
|
|
|
269
261
|
case "step-start":
|
|
270
|
-
|
|
271
|
-
return [{
|
|
272
|
-
event: "StepStarted",
|
|
273
|
-
payload: { stepIndex: state.stepIndex },
|
|
274
|
-
}];
|
|
262
|
+
return [];
|
|
275
263
|
|
|
276
264
|
case "step-end":
|
|
277
|
-
return [
|
|
278
|
-
event: "StepFinished",
|
|
279
|
-
payload: { stepIndex: state.stepIndex },
|
|
280
|
-
}];
|
|
265
|
+
return [];
|
|
281
266
|
|
|
282
267
|
case "data":
|
|
283
268
|
applyDataMetadata(state, event);
|
|
@@ -27,6 +27,13 @@ export function getControlPlaneVerificationPublicKey(ctx: HandlerContext): strin
|
|
|
27
27
|
getHostEnv("CHANNEL_DISPATCH_SIGNING_PUBLIC_KEY");
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
function isControlPlaneVerificationError(error: unknown): boolean {
|
|
31
|
+
return error instanceof Error && (
|
|
32
|
+
error.message.includes("Control-plane") ||
|
|
33
|
+
error.message.includes("Unsupported")
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
export async function verifyControlPlaneRequest(
|
|
31
38
|
req: dntShim.Request,
|
|
32
39
|
ctx: HandlerContext,
|
|
@@ -64,12 +71,7 @@ export async function verifyControlPlaneRequest(
|
|
|
64
71
|
maxAgeSeconds: MAX_CONTROL_PLANE_SIGNATURE_AGE_SECONDS,
|
|
65
72
|
});
|
|
66
73
|
} catch (error) {
|
|
67
|
-
|
|
68
|
-
error.message.includes("Control-plane") ||
|
|
69
|
-
error.message.includes("Unsupported")
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
if (isAuthError) {
|
|
74
|
+
if (isControlPlaneVerificationError(error)) {
|
|
73
75
|
logger.warn("Invalid control-plane signature", {
|
|
74
76
|
error,
|
|
75
77
|
projectSlug,
|
|
@@ -18,6 +18,12 @@ export class InternalAgentRequestBodyTooLargeError extends Error {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
function isRequestBodyTooLargeError(error: unknown): error is VeryfrontError {
|
|
22
|
+
return error instanceof VeryfrontError &&
|
|
23
|
+
error.slug === "input-validation-failed" &&
|
|
24
|
+
error.detail === "Request body exceeds size limit";
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
export async function readInternalAgentRequestBody(
|
|
22
28
|
request: dntShim.Request,
|
|
23
29
|
maxBodyBytes = INTERNAL_AGENT_STREAM_MAX_BODY_BYTES,
|
|
@@ -29,11 +35,7 @@ export async function readInternalAgentRequestBody(
|
|
|
29
35
|
try {
|
|
30
36
|
return await readBodyWithLimit(request, maxBodyBytes);
|
|
31
37
|
} catch (error) {
|
|
32
|
-
if (
|
|
33
|
-
error instanceof VeryfrontError &&
|
|
34
|
-
error.slug === "input-validation-failed" &&
|
|
35
|
-
error.detail === "Request body exceeds size limit"
|
|
36
|
-
) {
|
|
38
|
+
if (isRequestBodyTooLargeError(error)) {
|
|
37
39
|
throw new InternalAgentRequestBodyTooLargeError();
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -66,7 +66,6 @@ const AGENT_RUN_SESSION_MANAGER_GLOBAL_KEY = "__veryfrontAgentRunSessionManager"
|
|
|
66
66
|
type SessionStatus = "running" | "waiting" | "completed" | "cancelled" | "failed";
|
|
67
67
|
|
|
68
68
|
interface SubmittedToolResult {
|
|
69
|
-
toolCallId: string;
|
|
70
69
|
result: unknown;
|
|
71
70
|
isError: boolean;
|
|
72
71
|
key: string;
|
|
@@ -80,7 +79,6 @@ interface WaitingToolState {
|
|
|
80
79
|
|
|
81
80
|
interface AgentRunSession {
|
|
82
81
|
runId: string;
|
|
83
|
-
threadId: string;
|
|
84
82
|
status: SessionStatus;
|
|
85
83
|
abortController: AbortController;
|
|
86
84
|
waitingTool: WaitingToolState | null;
|
|
@@ -167,6 +165,17 @@ export class AgentRunSessionManager {
|
|
|
167
165
|
}
|
|
168
166
|
}
|
|
169
167
|
|
|
168
|
+
private finalizeSession(
|
|
169
|
+
session: AgentRunSession,
|
|
170
|
+
status: Exclude<SessionStatus, "running" | "waiting">,
|
|
171
|
+
): void {
|
|
172
|
+
session.status = status;
|
|
173
|
+
this.clearWaitingTimeout(session);
|
|
174
|
+
this.clearSessionTimeout(session);
|
|
175
|
+
session.waitingTool = null;
|
|
176
|
+
this.sessions.delete(session.runId);
|
|
177
|
+
}
|
|
178
|
+
|
|
170
179
|
private get maxConcurrentSessions(): number {
|
|
171
180
|
return this.options.maxConcurrentSessions ?? DEFAULT_MAX_CONCURRENT_SESSIONS;
|
|
172
181
|
}
|
|
@@ -185,7 +194,6 @@ export class AgentRunSessionManager {
|
|
|
185
194
|
|
|
186
195
|
const session: AgentRunSession = {
|
|
187
196
|
runId: input.runId,
|
|
188
|
-
threadId: input.threadId,
|
|
189
197
|
status: "running",
|
|
190
198
|
abortController: new AbortController(),
|
|
191
199
|
waitingTool: null,
|
|
@@ -266,7 +274,6 @@ export class AgentRunSessionManager {
|
|
|
266
274
|
}
|
|
267
275
|
|
|
268
276
|
const normalized: SubmittedToolResult = {
|
|
269
|
-
toolCallId: input.toolCallId,
|
|
270
277
|
result: input.result,
|
|
271
278
|
isError: Boolean(input.isError),
|
|
272
279
|
key: createToolResultKey(input.result, Boolean(input.isError)),
|
|
@@ -311,34 +318,23 @@ export class AgentRunSessionManager {
|
|
|
311
318
|
return false;
|
|
312
319
|
}
|
|
313
320
|
|
|
314
|
-
|
|
315
|
-
this.clearWaitingTimeout(session);
|
|
316
|
-
this.clearSessionTimeout(session);
|
|
321
|
+
const waitingTool = session.waitingTool;
|
|
317
322
|
session.abortController.abort(new AgentRunCancelledError());
|
|
318
|
-
|
|
319
|
-
session
|
|
320
|
-
this.sessions.delete(runId);
|
|
323
|
+
waitingTool?.reject(new AgentRunCancelledError());
|
|
324
|
+
this.finalizeSession(session, "cancelled");
|
|
321
325
|
return true;
|
|
322
326
|
}
|
|
323
327
|
|
|
324
328
|
completeRun(runId: string): void {
|
|
325
329
|
const session = this.sessions.get(runId);
|
|
326
330
|
if (!session) return;
|
|
327
|
-
session
|
|
328
|
-
this.clearWaitingTimeout(session);
|
|
329
|
-
this.clearSessionTimeout(session);
|
|
330
|
-
session.waitingTool = null;
|
|
331
|
-
this.sessions.delete(runId);
|
|
331
|
+
this.finalizeSession(session, "completed");
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
failRun(runId: string): void {
|
|
335
335
|
const session = this.sessions.get(runId);
|
|
336
336
|
if (!session) return;
|
|
337
|
-
session
|
|
338
|
-
this.clearWaitingTimeout(session);
|
|
339
|
-
this.clearSessionTimeout(session);
|
|
340
|
-
session.waitingTool = null;
|
|
341
|
-
this.sessions.delete(runId);
|
|
337
|
+
this.finalizeSession(session, "failed");
|
|
342
338
|
}
|
|
343
339
|
|
|
344
340
|
getRunStatus(runId: string): SessionStatus | null {
|