manifest 5.45.1 → 6.0.0
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/CONTRACT.md +50 -0
- package/README.md +69 -100
- package/dist/index.cjs +472 -0
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +443 -18
- package/docs/guide.md +77 -0
- package/package.json +36 -79
- package/dist/backend/analytics/analytics.module.js +0 -60
- package/dist/backend/analytics/controllers/agent-analytics.controller.js +0 -69
- package/dist/backend/analytics/controllers/agents.controller.js +0 -176
- package/dist/backend/analytics/controllers/costs.controller.js +0 -71
- package/dist/backend/analytics/controllers/messages.controller.js +0 -67
- package/dist/backend/analytics/controllers/overview.controller.js +0 -104
- package/dist/backend/analytics/controllers/tokens.controller.js +0 -74
- package/dist/backend/analytics/dto/messages-query.dto.js +0 -73
- package/dist/backend/analytics/services/agent-analytics.service.js +0 -125
- package/dist/backend/analytics/services/agent-lifecycle.service.js +0 -102
- package/dist/backend/analytics/services/aggregation.service.js +0 -205
- package/dist/backend/analytics/services/message-details.service.js +0 -147
- package/dist/backend/analytics/services/messages-query.service.js +0 -197
- package/dist/backend/analytics/services/query-helpers.js +0 -45
- package/dist/backend/analytics/services/timeseries-queries.service.js +0 -237
- package/dist/backend/app.module.js +0 -94
- package/dist/backend/auth/auth.instance.js +0 -121
- package/dist/backend/auth/auth.module.js +0 -17
- package/dist/backend/auth/current-user.decorator.js +0 -9
- package/dist/backend/auth/local-auth.guard.js +0 -51
- package/dist/backend/auth/session.guard.js +0 -57
- package/dist/backend/common/common.module.js +0 -41
- package/dist/backend/common/constants/api-key.constants.js +0 -6
- package/dist/backend/common/constants/cache.constants.js +0 -8
- package/dist/backend/common/constants/local-mode.constants.js +0 -102
- package/dist/backend/common/constants/ollama.js +0 -5
- package/dist/backend/common/constants/providers.js +0 -134
- package/dist/backend/common/decorators/public.decorator.js +0 -8
- package/dist/backend/common/dto/create-agent.dto.js +0 -26
- package/dist/backend/common/dto/range-query.dto.js +0 -29
- package/dist/backend/common/dto/rename-agent.dto.js +0 -26
- package/dist/backend/common/filters/spa-fallback.filter.js +0 -46
- package/dist/backend/common/guards/api-key.guard.js +0 -89
- package/dist/backend/common/interceptors/agent-cache.interceptor.js +0 -39
- package/dist/backend/common/interceptors/user-cache.interceptor.js +0 -39
- package/dist/backend/common/middleware/http-error-logger.middleware.js +0 -19
- package/dist/backend/common/services/ingest-event-bus.service.js +0 -44
- package/dist/backend/common/services/manifest-runtime.service.js +0 -39
- package/dist/backend/common/services/tenant-cache.service.js +0 -56
- package/dist/backend/common/utils/anthropic-model-id.js +0 -36
- package/dist/backend/common/utils/cost-calculator.js +0 -19
- package/dist/backend/common/utils/crypto.util.js +0 -72
- package/dist/backend/common/utils/frontend-path.js +0 -21
- package/dist/backend/common/utils/hash.util.js +0 -32
- package/dist/backend/common/utils/local-ip.js +0 -33
- package/dist/backend/common/utils/period.util.js +0 -55
- package/dist/backend/common/utils/provider-aliases.js +0 -13
- package/dist/backend/common/utils/provider-inference.js +0 -7
- package/dist/backend/common/utils/range.util.js +0 -29
- package/dist/backend/common/utils/slugify.js +0 -13
- package/dist/backend/common/utils/sql-dialect.js +0 -71
- package/dist/backend/common/utils/subscription-support.js +0 -12
- package/dist/backend/common/utils/ttl-cache.js +0 -59
- package/dist/backend/common/utils/url-validation.js +0 -107
- package/dist/backend/config/app.config.js +0 -48
- package/dist/backend/database/database-seeder.service.js +0 -180
- package/dist/backend/database/database.module.js +0 -201
- package/dist/backend/database/datasource.js +0 -28
- package/dist/backend/database/local-bootstrap.service.js +0 -161
- package/dist/backend/database/migrations/1771464895790-InitialSchema.js +0 -91
- package/dist/backend/database/migrations/1771500000000-HashApiKeys.js +0 -67
- package/dist/backend/database/migrations/1771600000000-AddModelCapabilities.js +0 -27
- package/dist/backend/database/migrations/1771600000000-ModelPricingImprovements.js +0 -60
- package/dist/backend/database/migrations/1771700000000-AddRoutingTables.js +0 -50
- package/dist/backend/database/migrations/1771700000000-EmailProviderConfigs.js +0 -31
- package/dist/backend/database/migrations/1771800000000-AddNotificationEmailAndOptionalDomain.js +0 -16
- package/dist/backend/database/migrations/1771800000000-AddQualityScore.js +0 -50
- package/dist/backend/database/migrations/1771800100000-SeedQualityScores.js +0 -45
- package/dist/backend/database/migrations/1771900000000-EncryptApiKeys.js +0 -34
- package/dist/backend/database/migrations/1772000000000-MakeApiKeyNullable.js +0 -16
- package/dist/backend/database/migrations/1772100000000-AddRoutingTier.js +0 -17
- package/dist/backend/database/migrations/1772200000000-AddLimitAction.js +0 -17
- package/dist/backend/database/migrations/1772300000000-AddRoutingReason.js +0 -17
- package/dist/backend/database/migrations/1772400000000-AddAgentDisplayName.js +0 -13
- package/dist/backend/database/migrations/1772500000000-PerAgentRouting.js +0 -82
- package/dist/backend/database/migrations/1772668898071-AddCustomProviders.js +0 -31
- package/dist/backend/database/migrations/1772682112419-NullablePricing.js +0 -17
- package/dist/backend/database/migrations/1772843035514-AddPerformanceIndexes.js +0 -56
- package/dist/backend/database/migrations/1772900000000-AddProviderAuthType.js +0 -13
- package/dist/backend/database/migrations/1772905146384-AddDashboardIndexes.js +0 -24
- package/dist/backend/database/migrations/1772905260464-AddFallbacks.js +0 -18
- package/dist/backend/database/migrations/1772920000000-AddModelDisplayName.js +0 -14
- package/dist/backend/database/migrations/1772940000000-DropRedundantIndexes.js +0 -39
- package/dist/backend/database/migrations/1772948502780-BackfillTenantId.js +0 -20
- package/dist/backend/database/migrations/1772960000000-DropUnusedIndexes.js +0 -19
- package/dist/backend/database/migrations/1772960000000-PurgeNonCuratedModels.js +0 -86
- package/dist/backend/database/migrations/1773000000000-ExpandProviderUniqueKey.js +0 -19
- package/dist/backend/database/migrations/1773100000000-AddOverrideAuthType.js +0 -18
- package/dist/backend/database/migrations/1773200000000-AddMessageAuthType.js +0 -18
- package/dist/backend/database/migrations/1773202787708-AddModelsAgentIndex.js +0 -16
- package/dist/backend/database/migrations/1773300000000-AddEmailProviderKeyPrefix.js +0 -13
- package/dist/backend/database/migrations/1773400000000-AddProviderModelCache.js +0 -15
- package/dist/backend/database/migrations/1773500000000-DropModelPricingTables.js +0 -51
- package/dist/backend/database/migrations/1773600000000-AddOverrideProvider.js +0 -18
- package/dist/backend/database/migrations/1773650000000-AddProviderRegion.js +0 -13
- package/dist/backend/database/migrations/1773700000000-DropSecurityEventTable.js +0 -24
- package/dist/backend/database/migrations/1773800000000-FixNegativeCosts.js +0 -12
- package/dist/backend/database/migrations/1773900000000-AddKeyPrefixIndex.js +0 -15
- package/dist/backend/database/migrations/1774000000000-WidenKeyHashColumn.js +0 -15
- package/dist/backend/database/migrations/1774896789000-WidenApiKeyColumn.js +0 -14
- package/dist/backend/database/migrations/1775000000000-AddErrorHttpStatus.js +0 -18
- package/dist/backend/database/models-dev-sync.service.js +0 -238
- package/dist/backend/database/ollama-sync.service.js +0 -70
- package/dist/backend/database/pricing-sync.service.js +0 -116
- package/dist/backend/database/quality-score.util.js +0 -76
- package/dist/backend/database/seed-messages.js +0 -66
- package/dist/backend/entities/agent-api-key.entity.js +0 -91
- package/dist/backend/entities/agent-log.entity.js +0 -71
- package/dist/backend/entities/agent-message.entity.js +0 -163
- package/dist/backend/entities/agent.entity.js +0 -75
- package/dist/backend/entities/api-key.entity.js +0 -62
- package/dist/backend/entities/cost-snapshot.entity.js +0 -56
- package/dist/backend/entities/custom-provider.entity.js +0 -64
- package/dist/backend/entities/email-provider-config.entity.js +0 -72
- package/dist/backend/entities/llm-call.entity.js +0 -106
- package/dist/backend/entities/notification-log.entity.js +0 -67
- package/dist/backend/entities/notification-rule.entity.js +0 -84
- package/dist/backend/entities/tenant.entity.js +0 -62
- package/dist/backend/entities/tier-assignment.entity.js +0 -72
- package/dist/backend/entities/token-usage-snapshot.entity.js +0 -71
- package/dist/backend/entities/tool-execution.entity.js +0 -60
- package/dist/backend/entities/user-provider.entity.js +0 -87
- package/dist/backend/github/github.controller.js +0 -53
- package/dist/backend/github/github.module.js +0 -20
- package/dist/backend/health/health.controller.js +0 -51
- package/dist/backend/health/health.module.js +0 -22
- package/dist/backend/health/version-check.service.js +0 -95
- package/dist/backend/main.js +0 -154
- package/dist/backend/model-discovery/anthropic-subscription-probe.js +0 -87
- package/dist/backend/model-discovery/known-model-prices.js +0 -18
- package/dist/backend/model-discovery/model-discovery.module.js +0 -28
- package/dist/backend/model-discovery/model-discovery.service.js +0 -309
- package/dist/backend/model-discovery/model-fallback.js +0 -234
- package/dist/backend/model-discovery/model-fetcher.js +0 -3
- package/dist/backend/model-discovery/provider-model-fetcher.service.js +0 -376
- package/dist/backend/model-discovery/provider-model-registry.service.js +0 -84
- package/dist/backend/model-prices/model-name-normalizer.js +0 -129
- package/dist/backend/model-prices/model-prices.controller.js +0 -39
- package/dist/backend/model-prices/model-prices.module.js +0 -41
- package/dist/backend/model-prices/model-prices.service.js +0 -45
- package/dist/backend/model-prices/model-pricing-cache.service.js +0 -171
- package/dist/backend/notifications/dto/notification-rule.dto.js +0 -82
- package/dist/backend/notifications/dto/set-email-provider.dto.js +0 -86
- package/dist/backend/notifications/dto/set-notification-email.dto.js +0 -24
- package/dist/backend/notifications/emails/reset-password.js +0 -108
- package/dist/backend/notifications/emails/test-email.js +0 -91
- package/dist/backend/notifications/emails/threshold-alert.js +0 -187
- package/dist/backend/notifications/emails/verify-email.js +0 -108
- package/dist/backend/notifications/notifications.controller.js +0 -208
- package/dist/backend/notifications/notifications.module.js +0 -35
- package/dist/backend/notifications/services/email-provider-config.service.js +0 -184
- package/dist/backend/notifications/services/email-provider-validation.js +0 -47
- package/dist/backend/notifications/services/email-providers/email-provider.interface.js +0 -3
- package/dist/backend/notifications/services/email-providers/mailgun.provider.js +0 -62
- package/dist/backend/notifications/services/email-providers/resend.provider.js +0 -51
- package/dist/backend/notifications/services/email-providers/resolve-provider.js +0 -19
- package/dist/backend/notifications/services/email-providers/send-email.js +0 -34
- package/dist/backend/notifications/services/email-providers/sendgrid.provider.js +0 -59
- package/dist/backend/notifications/services/limit-check.service.js +0 -160
- package/dist/backend/notifications/services/notification-cron.service.js +0 -151
- package/dist/backend/notifications/services/notification-email.service.js +0 -65
- package/dist/backend/notifications/services/notification-log.service.js +0 -84
- package/dist/backend/notifications/services/notification-rules.service.js +0 -156
- package/dist/backend/otlp/guards/agent-key-auth.guard.js +0 -226
- package/dist/backend/otlp/interfaces/ingestion-context.interface.js +0 -3
- package/dist/backend/otlp/otlp-deprecated.controller.js +0 -61
- package/dist/backend/otlp/otlp.module.js +0 -30
- package/dist/backend/otlp/services/api-key.service.js +0 -143
- package/dist/backend/public-stats/public-stats.controller.js +0 -141
- package/dist/backend/public-stats/public-stats.module.js +0 -26
- package/dist/backend/public-stats/public-stats.service.js +0 -226
- package/dist/backend/routing/copilot.controller.js +0 -79
- package/dist/backend/routing/custom-provider/custom-provider.controller.js +0 -131
- package/dist/backend/routing/custom-provider/custom-provider.module.js +0 -27
- package/dist/backend/routing/custom-provider/custom-provider.service.js +0 -161
- package/dist/backend/routing/dto/custom-provider.dto.js +0 -124
- package/dist/backend/routing/dto/resolve-request.dto.js +0 -63
- package/dist/backend/routing/dto/resolve-response.js +0 -3
- package/dist/backend/routing/dto/routing.dto.js +0 -136
- package/dist/backend/routing/model.controller.js +0 -105
- package/dist/backend/routing/oauth/copilot-device-auth.service.js +0 -77
- package/dist/backend/routing/oauth/minimax-oauth-helpers.js +0 -70
- package/dist/backend/routing/oauth/minimax-oauth.controller.js +0 -80
- package/dist/backend/routing/oauth/minimax-oauth.service.js +0 -252
- package/dist/backend/routing/oauth/oauth.module.js +0 -29
- package/dist/backend/routing/oauth/openai-oauth.controller.js +0 -138
- package/dist/backend/routing/oauth/openai-oauth.service.js +0 -273
- package/dist/backend/routing/oauth/openai-oauth.types.js +0 -45
- package/dist/backend/routing/provider-base-url.js +0 -25
- package/dist/backend/routing/provider.controller.js +0 -152
- package/dist/backend/routing/proxy/anthropic-adapter.js +0 -295
- package/dist/backend/routing/proxy/cache-injection.js +0 -33
- package/dist/backend/routing/proxy/chatgpt-adapter.js +0 -272
- package/dist/backend/routing/proxy/chatgpt-helpers.js +0 -108
- package/dist/backend/routing/proxy/copilot-token.service.js +0 -63
- package/dist/backend/routing/proxy/fallback-status-codes.js +0 -7
- package/dist/backend/routing/proxy/google-adapter.js +0 -314
- package/dist/backend/routing/proxy/provider-client-converters.js +0 -190
- package/dist/backend/routing/proxy/provider-client.js +0 -130
- package/dist/backend/routing/proxy/provider-endpoints.js +0 -182
- package/dist/backend/routing/proxy/proxy-error-sanitizer.js +0 -40
- package/dist/backend/routing/proxy/proxy-exception.filter.js +0 -67
- package/dist/backend/routing/proxy/proxy-fallback.service.js +0 -227
- package/dist/backend/routing/proxy/proxy-friendly-response.js +0 -115
- package/dist/backend/routing/proxy/proxy-message-dedup.js +0 -121
- package/dist/backend/routing/proxy/proxy-message-recorder.js +0 -264
- package/dist/backend/routing/proxy/proxy-rate-limiter.js +0 -81
- package/dist/backend/routing/proxy/proxy-response-handler.js +0 -202
- package/dist/backend/routing/proxy/proxy-transport.js +0 -90
- package/dist/backend/routing/proxy/proxy-types.js +0 -3
- package/dist/backend/routing/proxy/proxy.controller.js +0 -174
- package/dist/backend/routing/proxy/proxy.module.js +0 -62
- package/dist/backend/routing/proxy/proxy.service.js +0 -227
- package/dist/backend/routing/proxy/session-momentum.service.js +0 -66
- package/dist/backend/routing/proxy/stream-writer.js +0 -147
- package/dist/backend/routing/proxy/thought-signature-cache.js +0 -45
- package/dist/backend/routing/qwen-region.js +0 -51
- package/dist/backend/routing/resolve/resolve.controller.js +0 -106
- package/dist/backend/routing/resolve/resolve.module.js +0 -28
- package/dist/backend/routing/resolve/resolve.service.js +0 -126
- package/dist/backend/routing/routing-core/provider-key.service.js +0 -190
- package/dist/backend/routing/routing-core/provider.service.js +0 -305
- package/dist/backend/routing/routing-core/resolve-agent.service.js +0 -62
- package/dist/backend/routing/routing-core/routing-cache.service.js +0 -73
- package/dist/backend/routing/routing-core/routing-core.module.js +0 -56
- package/dist/backend/routing/routing-core/routing-invalidation.service.js +0 -90
- package/dist/backend/routing/routing-core/tier-auto-assign.service.js +0 -138
- package/dist/backend/routing/routing-core/tier.service.js +0 -179
- package/dist/backend/routing/routing.module.js +0 -46
- package/dist/backend/routing/tier.controller.js +0 -129
- package/dist/backend/scoring/__tests__/fixtures.js +0 -191
- package/dist/backend/scoring/config.js +0 -383
- package/dist/backend/scoring/dimensions/contextual-dimensions.js +0 -85
- package/dist/backend/scoring/dimensions/index.js +0 -17
- package/dist/backend/scoring/dimensions/keyword-dimensions.js +0 -47
- package/dist/backend/scoring/dimensions/structural-dimensions.js +0 -118
- package/dist/backend/scoring/index.js +0 -186
- package/dist/backend/scoring/keyword-trie.js +0 -75
- package/dist/backend/scoring/momentum.js +0 -50
- package/dist/backend/scoring/overrides.js +0 -55
- package/dist/backend/scoring/sigmoid.js +0 -24
- package/dist/backend/scoring/text-extractor.js +0 -67
- package/dist/backend/scoring/types.js +0 -6
- package/dist/backend/sse/sse.controller.js +0 -45
- package/dist/backend/sse/sse.module.js +0 -20
- package/dist/node_modules/manifest-shared/dist/cjs/api-key.d.ts +0 -2
- package/dist/node_modules/manifest-shared/dist/cjs/api-key.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/api-key.js +0 -5
- package/dist/node_modules/manifest-shared/dist/cjs/api-key.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/auth-types.d.ts +0 -3
- package/dist/node_modules/manifest-shared/dist/cjs/auth-types.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/auth-types.js +0 -5
- package/dist/node_modules/manifest-shared/dist/cjs/auth-types.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/index.d.ts +0 -10
- package/dist/node_modules/manifest-shared/dist/cjs/index.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/index.js +0 -22
- package/dist/node_modules/manifest-shared/dist/cjs/index.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/provider-inference.d.ts +0 -8
- package/dist/node_modules/manifest-shared/dist/cjs/provider-inference.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/provider-inference.js +0 -37
- package/dist/node_modules/manifest-shared/dist/cjs/provider-inference.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/resolve-response.d.ts +0 -12
- package/dist/node_modules/manifest-shared/dist/cjs/resolve-response.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/resolve-response.js +0 -3
- package/dist/node_modules/manifest-shared/dist/cjs/resolve-response.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/configs.d.ts +0 -4
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/configs.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/configs.js +0 -80
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/configs.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/helpers.d.ts +0 -6
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/helpers.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/helpers.js +0 -25
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/helpers.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/index.d.ts +0 -4
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/index.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/index.js +0 -12
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/index.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/types.d.ts +0 -17
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/types.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/types.js +0 -3
- package/dist/node_modules/manifest-shared/dist/cjs/subscription/types.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/tiers.d.ts +0 -5
- package/dist/node_modules/manifest-shared/dist/cjs/tiers.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/cjs/tiers.js +0 -17
- package/dist/node_modules/manifest-shared/dist/cjs/tiers.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/api-key.d.ts +0 -2
- package/dist/node_modules/manifest-shared/dist/esm/api-key.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/api-key.js +0 -2
- package/dist/node_modules/manifest-shared/dist/esm/api-key.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/auth-types.d.ts +0 -3
- package/dist/node_modules/manifest-shared/dist/esm/auth-types.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/auth-types.js +0 -2
- package/dist/node_modules/manifest-shared/dist/esm/auth-types.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/index.d.ts +0 -10
- package/dist/node_modules/manifest-shared/dist/esm/index.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/index.js +0 -6
- package/dist/node_modules/manifest-shared/dist/esm/index.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/provider-inference.d.ts +0 -8
- package/dist/node_modules/manifest-shared/dist/esm/provider-inference.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/provider-inference.js +0 -33
- package/dist/node_modules/manifest-shared/dist/esm/provider-inference.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/resolve-response.d.ts +0 -12
- package/dist/node_modules/manifest-shared/dist/esm/resolve-response.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/resolve-response.js +0 -2
- package/dist/node_modules/manifest-shared/dist/esm/resolve-response.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/subscription/configs.d.ts +0 -4
- package/dist/node_modules/manifest-shared/dist/esm/subscription/configs.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/subscription/configs.js +0 -77
- package/dist/node_modules/manifest-shared/dist/esm/subscription/configs.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/subscription/helpers.d.ts +0 -6
- package/dist/node_modules/manifest-shared/dist/esm/subscription/helpers.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/subscription/helpers.js +0 -19
- package/dist/node_modules/manifest-shared/dist/esm/subscription/helpers.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/subscription/index.d.ts +0 -4
- package/dist/node_modules/manifest-shared/dist/esm/subscription/index.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/subscription/index.js +0 -3
- package/dist/node_modules/manifest-shared/dist/esm/subscription/index.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/subscription/types.d.ts +0 -17
- package/dist/node_modules/manifest-shared/dist/esm/subscription/types.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/subscription/types.js +0 -2
- package/dist/node_modules/manifest-shared/dist/esm/subscription/types.js.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/tiers.d.ts +0 -5
- package/dist/node_modules/manifest-shared/dist/esm/tiers.d.ts.map +0 -1
- package/dist/node_modules/manifest-shared/dist/esm/tiers.js +0 -14
- package/dist/node_modules/manifest-shared/dist/esm/tiers.js.map +0 -1
- package/dist/node_modules/manifest-shared/package.json +0 -26
- package/dist/openclaw.plugin.json +0 -37
- package/dist/package.json +0 -94
- package/dist/server.d.ts +0 -9
- package/dist/server.js +0 -69
- package/openclaw.plugin.json +0 -37
- package/public/assets/Account-C5g6WhPe.js +0 -1
- package/public/assets/AuthBadge-Dj2KkXRW.js +0 -1
- package/public/assets/ConnectProvider-axzk92LC.js +0 -1
- package/public/assets/CopyButton-BWMVlK2w.js +0 -1
- package/public/assets/FreeModels-D14GhDL_.js +0 -1
- package/public/assets/Help-ifWIlcDo.js +0 -1
- package/public/assets/Limits-Xgc4xTl5.js +0 -1
- package/public/assets/Login-DMXD4PMZ.js +0 -1
- package/public/assets/MessageLog-DoriYlHo.js +0 -1
- package/public/assets/ModelPrices-MhBT_7Zb.js +0 -1
- package/public/assets/Overview-Bi9FuoLx.js +0 -1
- package/public/assets/Pagination-D8BOkffh.js +0 -1
- package/public/assets/ProviderTokens-Cu2RUqQG.js +0 -1
- package/public/assets/Register-CrovWG_d.js +0 -1
- package/public/assets/ResetPassword-C6B1ubhL.js +0 -1
- package/public/assets/Routing-B-On2pvv.js +0 -6
- package/public/assets/Settings-BH-xNoID.js +0 -1
- package/public/assets/SetupStepAddProvider-CSNkQmoC.js +0 -3
- package/public/assets/SocialButtons-DudwEJ6b.js +0 -1
- package/public/assets/auth-CU91cd7V.js +0 -1
- package/public/assets/chart-utils-DTt1NOye.js +0 -1
- package/public/assets/charts-Cty976qB.js +0 -3
- package/public/assets/charts-Saz_VHki.css +0 -1
- package/public/assets/index-C4Qw7vZo.js +0 -2
- package/public/assets/index-DhaXpWfr.css +0 -1
- package/public/assets/model-display-DHwvDtl4.js +0 -1
- package/public/assets/overview-DKLGwfLs.js +0 -1
- package/public/assets/overview-vZEzTjBP.css +0 -1
- package/public/assets/provider-api-key-urls-1G6okUJ7.js +0 -1
- package/public/assets/routing-CLLAl6kl.js +0 -1
- package/public/assets/routing-utils-CHapjwyd.js +0 -1
- package/public/assets/vendor-C-Y5oNOq.js +0 -1
- package/public/example-messages.svg +0 -1
- package/public/example-overview.svg +0 -1
- package/public/favicon.ico +0 -0
- package/public/fonts/boxicons/boxicons-duotone.min.css +0 -37
- package/public/fonts/boxicons/boxicons-duotone.woff2 +0 -0
- package/public/fonts/bricolage-grotesque-latin.woff2 +0 -0
- package/public/fonts/dm-sans-latin.woff2 +0 -0
- package/public/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/public/icons/caret-down.svg +0 -1
- package/public/icons/cohere.svg +0 -30
- package/public/icons/free.svg +0 -91
- package/public/icons/gemini.svg +0 -25
- package/public/icons/kilocode.jpg +0 -0
- package/public/icons/nvidia.svg +0 -1
- package/public/icons/providers/alibaba.svg +0 -1
- package/public/icons/providers/amazon.svg +0 -1
- package/public/icons/providers/anthropic.svg +0 -1
- package/public/icons/providers/cohere.svg +0 -1
- package/public/icons/providers/deepseek.svg +0 -1
- package/public/icons/providers/google.svg +0 -1
- package/public/icons/providers/meta.svg +0 -1
- package/public/icons/providers/mistral.svg +0 -1
- package/public/icons/providers/moonshot.svg +0 -1
- package/public/icons/providers/openai.svg +0 -1
- package/public/icons/providers/xai.svg +0 -1
- package/public/icons/providers/zhipu.svg +0 -1
- package/public/icons/qwen.svg +0 -1
- package/public/images/oauth-callback-example.mp4 +0 -0
- package/public/images/oauth-callback-example.png +0 -0
- package/public/index.html +0 -41
- package/public/logo-white.svg +0 -93
- package/public/logo.svg +0 -93
- package/public/logos/mailgun.svg +0 -13
- package/public/logos/resend.svg +0 -4
- package/public/logos/sendgrid.svg +0 -18
- package/public/manifest-logo.png +0 -0
- package/public/theme-init.js +0 -6
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
VERSION: () => VERSION,
|
|
24
|
+
flush: () => flush,
|
|
25
|
+
manifest: () => manifest
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/runtime.ts
|
|
30
|
+
var import_node_crypto = require("crypto");
|
|
31
|
+
|
|
32
|
+
// src/wire.ts
|
|
33
|
+
var secretNames = /* @__PURE__ */ new Set([
|
|
34
|
+
"api_key",
|
|
35
|
+
"apikey",
|
|
36
|
+
"api_token",
|
|
37
|
+
"key",
|
|
38
|
+
"token",
|
|
39
|
+
"access_token",
|
|
40
|
+
"refresh_token",
|
|
41
|
+
"auth",
|
|
42
|
+
"authorization",
|
|
43
|
+
"signature",
|
|
44
|
+
"sig",
|
|
45
|
+
"secret",
|
|
46
|
+
"client_secret",
|
|
47
|
+
"password",
|
|
48
|
+
"session",
|
|
49
|
+
"session_id",
|
|
50
|
+
"bearer",
|
|
51
|
+
"jwt",
|
|
52
|
+
"id_token",
|
|
53
|
+
"auth_token",
|
|
54
|
+
"pwd",
|
|
55
|
+
"passwd",
|
|
56
|
+
"private_key"
|
|
57
|
+
]);
|
|
58
|
+
var roots = ["auth", "key", "token", "secret", "session", "password", "passwd", "cookie", "signature", "credential", "bearer", "jwt"];
|
|
59
|
+
var normalize = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replaceAll("-", "_").toLowerCase().replace(/^x_/, "");
|
|
60
|
+
var isSecret = (name) => secretNames.has(normalize(name));
|
|
61
|
+
var isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
62
|
+
function safeUrl(raw) {
|
|
63
|
+
const url = new URL(raw);
|
|
64
|
+
url.username = "";
|
|
65
|
+
url.password = "";
|
|
66
|
+
url.hash = "";
|
|
67
|
+
const pairs = [...url.searchParams].map(([key, value]) => [key, isSecret(key) ? "REDACTED" : value]);
|
|
68
|
+
url.search = new URLSearchParams(pairs).toString();
|
|
69
|
+
return url.toString();
|
|
70
|
+
}
|
|
71
|
+
function safeHeaders(headers) {
|
|
72
|
+
return Object.fromEntries([...headers].map(([key, value]) => [
|
|
73
|
+
key,
|
|
74
|
+
isSecret(key) || roots.some((root) => normalize(key).includes(root)) ? "REDACTED" : value.slice(0, 1024)
|
|
75
|
+
]));
|
|
76
|
+
}
|
|
77
|
+
function travelingBody(body) {
|
|
78
|
+
return isObject(body) ? Object.fromEntries(Object.entries(body).filter(([key]) => !isSecret(key))) : body;
|
|
79
|
+
}
|
|
80
|
+
function mergeBody(original, healed) {
|
|
81
|
+
if (!isObject(original) || !isObject(healed)) return healed;
|
|
82
|
+
return { ...Object.fromEntries(Object.entries(original).filter(([key]) => isSecret(key) && !Object.hasOwn(healed, key))), ...healed };
|
|
83
|
+
}
|
|
84
|
+
function boundedJson(value) {
|
|
85
|
+
const stack = [[value, 0]];
|
|
86
|
+
let count = 0;
|
|
87
|
+
while (stack.length) {
|
|
88
|
+
const [item, depth] = stack.pop();
|
|
89
|
+
if (++count > 1e5 || depth > 64) return false;
|
|
90
|
+
if (item !== null && typeof item === "object") {
|
|
91
|
+
for (const child of Object.values(item)) stack.push([child, depth + 1]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
function parseJson(bytes) {
|
|
97
|
+
try {
|
|
98
|
+
const value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
99
|
+
return boundedJson(value) ? value : null;
|
|
100
|
+
} catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function errorBody(bytes) {
|
|
105
|
+
const parsed = parseJson(bytes);
|
|
106
|
+
const text = Buffer.from(bytes).toString("utf8");
|
|
107
|
+
return parsed ?? new TextDecoder().decode(Buffer.from(text).subarray(0, 65536), { stream: true });
|
|
108
|
+
}
|
|
109
|
+
var TRANSPORT_ERROR = "Upstream retry failed before an HTTP response";
|
|
110
|
+
|
|
111
|
+
// src/capture.ts
|
|
112
|
+
var REQUEST_LIMIT = 262144;
|
|
113
|
+
var RESPONSE_LIMIT = 65536;
|
|
114
|
+
var CAPTURE_MS = 1e3;
|
|
115
|
+
async function prefix(reader, limit, timeoutMs) {
|
|
116
|
+
const chunks = [];
|
|
117
|
+
let size = 0;
|
|
118
|
+
let pending;
|
|
119
|
+
let timer;
|
|
120
|
+
const deadline = new Promise((resolve) => {
|
|
121
|
+
timer = setTimeout(() => resolve(null), timeoutMs);
|
|
122
|
+
});
|
|
123
|
+
let complete = false;
|
|
124
|
+
try {
|
|
125
|
+
while (size <= limit) {
|
|
126
|
+
pending = reader.read();
|
|
127
|
+
const read = await Promise.race([pending, deadline]);
|
|
128
|
+
if (read === null) break;
|
|
129
|
+
pending = void 0;
|
|
130
|
+
if (read.done) {
|
|
131
|
+
complete = true;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
chunks.push(read.value);
|
|
135
|
+
size += read.value.byteLength;
|
|
136
|
+
}
|
|
137
|
+
} catch {
|
|
138
|
+
} finally {
|
|
139
|
+
clearTimeout(timer);
|
|
140
|
+
}
|
|
141
|
+
return { chunks, complete, pending, bytes: Buffer.concat(chunks, size).subarray(0, limit) };
|
|
142
|
+
}
|
|
143
|
+
async function captureRequest(request) {
|
|
144
|
+
if (!request.body) return { body: null, complete: true };
|
|
145
|
+
const clone = request.clone();
|
|
146
|
+
const reader = clone.body.getReader();
|
|
147
|
+
try {
|
|
148
|
+
const result = await prefix(reader, REQUEST_LIMIT, CAPTURE_MS);
|
|
149
|
+
return { body: result.complete ? parseJson(result.bytes) : null, complete: result.complete };
|
|
150
|
+
} finally {
|
|
151
|
+
void reader.cancel().catch(() => {
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function metadata(response, original) {
|
|
156
|
+
const clone = response.clone.bind(response);
|
|
157
|
+
Object.defineProperties(response, {
|
|
158
|
+
url: { value: original.url },
|
|
159
|
+
redirected: { value: original.redirected },
|
|
160
|
+
type: { value: original.type },
|
|
161
|
+
clone: { value: () => metadata(clone(), original) }
|
|
162
|
+
});
|
|
163
|
+
return response;
|
|
164
|
+
}
|
|
165
|
+
async function captureResponse(original, limit = RESPONSE_LIMIT, timeoutMs = CAPTURE_MS) {
|
|
166
|
+
if (!original.body) return { response: original, body: null, truncated: false, complete: true };
|
|
167
|
+
const reader = original.body.getReader();
|
|
168
|
+
const captured = await prefix(reader, limit, timeoutMs);
|
|
169
|
+
let index = 0;
|
|
170
|
+
let pending = captured.pending;
|
|
171
|
+
const stream = new ReadableStream({
|
|
172
|
+
async pull(controller) {
|
|
173
|
+
try {
|
|
174
|
+
if (index < captured.chunks.length) {
|
|
175
|
+
controller.enqueue(captured.chunks[index++]);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const read = await (pending ?? reader.read());
|
|
179
|
+
pending = void 0;
|
|
180
|
+
if (read.done) {
|
|
181
|
+
reader.releaseLock();
|
|
182
|
+
controller.close();
|
|
183
|
+
} else controller.enqueue(read.value);
|
|
184
|
+
} catch (error) {
|
|
185
|
+
controller.error(error);
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
async cancel(reason) {
|
|
189
|
+
await reader.cancel(reason);
|
|
190
|
+
}
|
|
191
|
+
}, { highWaterMark: 0 });
|
|
192
|
+
const response = metadata(new Response(stream, {
|
|
193
|
+
status: original.status,
|
|
194
|
+
statusText: original.statusText,
|
|
195
|
+
headers: original.headers
|
|
196
|
+
}), original);
|
|
197
|
+
return { response, body: errorBody(captured.bytes), truncated: !captured.complete || Buffer.byteLength(Buffer.from(captured.bytes).toString("utf8")) > limit, complete: captured.complete };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// src/api.ts
|
|
201
|
+
var VERSION = "6.0.0";
|
|
202
|
+
var warn = (message) => process.emitWarning(message, { code: "MNFST" });
|
|
203
|
+
var HealApi = class {
|
|
204
|
+
constructor(rawFetch, key, url, timeoutMs = 6e4, reportTimeoutMs = 5e3) {
|
|
205
|
+
this.rawFetch = rawFetch;
|
|
206
|
+
this.key = key;
|
|
207
|
+
this.url = url;
|
|
208
|
+
this.timeoutMs = timeoutMs;
|
|
209
|
+
this.reportTimeoutMs = reportTimeoutMs;
|
|
210
|
+
}
|
|
211
|
+
rawFetch;
|
|
212
|
+
key;
|
|
213
|
+
url;
|
|
214
|
+
timeoutMs;
|
|
215
|
+
reportTimeoutMs;
|
|
216
|
+
disabledUntil = 0;
|
|
217
|
+
inFlight = 0;
|
|
218
|
+
pending = /* @__PURE__ */ new Set();
|
|
219
|
+
enabled() {
|
|
220
|
+
return performance.now() >= this.disabledUntil;
|
|
221
|
+
}
|
|
222
|
+
headers() {
|
|
223
|
+
return {
|
|
224
|
+
authorization: `Bearer ${this.key}`,
|
|
225
|
+
"content-type": "application/json",
|
|
226
|
+
"user-agent": `mnfst-node/${VERSION}`,
|
|
227
|
+
"x-mnfst-source": "node-sdk"
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
async heal(capture, signal) {
|
|
231
|
+
if (!this.enabled() || this.inFlight >= 8) return null;
|
|
232
|
+
this.inFlight++;
|
|
233
|
+
const controller = new AbortController();
|
|
234
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
235
|
+
try {
|
|
236
|
+
const response = await this.rawFetch(new URL("v1/heal", this.url), {
|
|
237
|
+
method: "POST",
|
|
238
|
+
headers: this.headers(),
|
|
239
|
+
body: JSON.stringify(capture),
|
|
240
|
+
signal: AbortSignal.any([signal, controller.signal]),
|
|
241
|
+
redirect: "error"
|
|
242
|
+
});
|
|
243
|
+
if (response.status !== 200 && response.status !== 403) {
|
|
244
|
+
void response.body?.cancel().catch(() => {
|
|
245
|
+
});
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
const captured = await captureResponse(response, 1048576, this.timeoutMs);
|
|
249
|
+
void captured.response.body?.cancel().catch(() => {
|
|
250
|
+
});
|
|
251
|
+
if (!captured.complete || !isObject(captured.body) || !boundedJson(captured.body)) return null;
|
|
252
|
+
if (response.status === 403 && captured.body.error === "project_disabled") {
|
|
253
|
+
this.disabledUntil = performance.now() + 3e5;
|
|
254
|
+
}
|
|
255
|
+
if (response.status !== 200 || typeof captured.body.status !== "string") return null;
|
|
256
|
+
return {
|
|
257
|
+
status: captured.body.status,
|
|
258
|
+
...typeof captured.body.healAttemptId === "string" ? { healAttemptId: captured.body.healAttemptId } : {},
|
|
259
|
+
...Array.isArray(captured.body.operations) ? { operations: captured.body.operations } : {},
|
|
260
|
+
...isObject(captured.body.healedRequest) ? { healedRequest: captured.body.healedRequest } : {}
|
|
261
|
+
};
|
|
262
|
+
} catch {
|
|
263
|
+
return null;
|
|
264
|
+
} finally {
|
|
265
|
+
clearTimeout(timer);
|
|
266
|
+
this.inFlight--;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
report(id, outcome) {
|
|
270
|
+
if (!id) return;
|
|
271
|
+
if (this.pending.size >= 64) {
|
|
272
|
+
warn("Outcome report capacity reached; report dropped");
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const promise = this.send(id, outcome);
|
|
276
|
+
this.pending.add(promise);
|
|
277
|
+
void promise.then(() => this.pending.delete(promise));
|
|
278
|
+
}
|
|
279
|
+
async send(id, outcome) {
|
|
280
|
+
const controller = new AbortController();
|
|
281
|
+
const timer = setTimeout(() => controller.abort(), this.reportTimeoutMs);
|
|
282
|
+
try {
|
|
283
|
+
const response = await this.rawFetch(new URL(`v1/heal-attempts/${encodeURIComponent(id)}`, this.url), {
|
|
284
|
+
method: "PATCH",
|
|
285
|
+
headers: this.headers(),
|
|
286
|
+
body: JSON.stringify(outcome),
|
|
287
|
+
signal: controller.signal,
|
|
288
|
+
redirect: "error"
|
|
289
|
+
});
|
|
290
|
+
void response.body?.cancel().catch(() => {
|
|
291
|
+
});
|
|
292
|
+
if (!response.ok) warn("Outcome report rejected; attempt remains unconfirmed");
|
|
293
|
+
} catch {
|
|
294
|
+
warn("Outcome report failed; attempt remains unconfirmed");
|
|
295
|
+
} finally {
|
|
296
|
+
clearTimeout(timer);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
async flush(timeoutMs = 5e3) {
|
|
300
|
+
let timer;
|
|
301
|
+
try {
|
|
302
|
+
await Promise.race([
|
|
303
|
+
Promise.allSettled([...this.pending]),
|
|
304
|
+
new Promise((resolve) => {
|
|
305
|
+
timer = setTimeout(resolve, Math.max(0, timeoutMs));
|
|
306
|
+
})
|
|
307
|
+
]);
|
|
308
|
+
} finally {
|
|
309
|
+
clearTimeout(timer);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// src/runtime.ts
|
|
315
|
+
var eligible = /* @__PURE__ */ new Set([400, 404, 422]);
|
|
316
|
+
var Runtime = class {
|
|
317
|
+
constructor(options, original, api) {
|
|
318
|
+
this.options = options;
|
|
319
|
+
this.original = original;
|
|
320
|
+
this.api = api ?? new HealApi(original, options.key, options.url);
|
|
321
|
+
}
|
|
322
|
+
options;
|
|
323
|
+
original;
|
|
324
|
+
api;
|
|
325
|
+
fetch = async (input, init) => {
|
|
326
|
+
const request = new Request(input, init);
|
|
327
|
+
const extras = { ...init };
|
|
328
|
+
delete extras.body;
|
|
329
|
+
delete extras.headers;
|
|
330
|
+
const bodyPromise = captureRequest(request).catch(() => ({ body: null, complete: false }));
|
|
331
|
+
const started = performance.now();
|
|
332
|
+
const response = await this.original(request, extras);
|
|
333
|
+
const responseTimeMs = performance.now() - started;
|
|
334
|
+
if (!eligible.has(response.status) || response.redirected || !this.api.enabled()) return response;
|
|
335
|
+
return this.repair(request, extras, response, await bodyPromise, responseTimeMs);
|
|
336
|
+
};
|
|
337
|
+
async repair(request, extras, original, body, responseTimeMs) {
|
|
338
|
+
let response = original;
|
|
339
|
+
let result = null;
|
|
340
|
+
const started = performance.now();
|
|
341
|
+
let replayStatusCode = null;
|
|
342
|
+
let replayAttempted = false;
|
|
343
|
+
try {
|
|
344
|
+
const captured = await captureResponse(response);
|
|
345
|
+
response = captured.response;
|
|
346
|
+
const payload = {
|
|
347
|
+
traceId: (0, import_node_crypto.randomUUID)(),
|
|
348
|
+
request: { method: request.method, url: safeUrl(request.url), headers: safeHeaders(request.headers), body: travelingBody(body.body) },
|
|
349
|
+
response: { statusCode: response.status, body: captured.body, truncated: captured.truncated },
|
|
350
|
+
responseTimeMs: Math.round(responseTimeMs)
|
|
351
|
+
};
|
|
352
|
+
request.signal.throwIfAborted();
|
|
353
|
+
result = await this.api.heal(payload, request.signal);
|
|
354
|
+
request.signal.throwIfAborted();
|
|
355
|
+
const retry = body.complete && captured.complete ? buildRetry(request, body.body, result) : null;
|
|
356
|
+
if (!retry) {
|
|
357
|
+
this.api.report(result?.healAttemptId, { failure: { kind: "not_attempted", message: "replay_not_attempted" } });
|
|
358
|
+
return response;
|
|
359
|
+
}
|
|
360
|
+
replayAttempted = true;
|
|
361
|
+
let retried;
|
|
362
|
+
try {
|
|
363
|
+
retried = await this.original(retry, extras);
|
|
364
|
+
} catch {
|
|
365
|
+
this.api.report(result?.healAttemptId, { failure: { kind: "transport_error", message: TRANSPORT_ERROR } });
|
|
366
|
+
request.signal.throwIfAborted();
|
|
367
|
+
return response;
|
|
368
|
+
}
|
|
369
|
+
replayStatusCode = retried.status;
|
|
370
|
+
if (retried.status >= 400) {
|
|
371
|
+
const capturedRetry = await captureResponse(retried);
|
|
372
|
+
retried = capturedRetry.response;
|
|
373
|
+
this.api.report(result?.healAttemptId, { response: { statusCode: retried.status, body: capturedRetry.body, truncated: capturedRetry.truncated } });
|
|
374
|
+
} else {
|
|
375
|
+
this.api.report(result?.healAttemptId, { response: { statusCode: retried.status } });
|
|
376
|
+
}
|
|
377
|
+
void response.body?.cancel().catch(() => {
|
|
378
|
+
});
|
|
379
|
+
return retried;
|
|
380
|
+
} catch {
|
|
381
|
+
request.signal.throwIfAborted();
|
|
382
|
+
this.api.report(result?.healAttemptId, { failure: { kind: "not_attempted", message: "replay_not_attempted" } });
|
|
383
|
+
return response;
|
|
384
|
+
} finally {
|
|
385
|
+
if (this.options.onHeal) {
|
|
386
|
+
try {
|
|
387
|
+
void Promise.resolve(this.options.onHeal({
|
|
388
|
+
url: safeUrl(request.url),
|
|
389
|
+
statusCode: original.status,
|
|
390
|
+
healStatus: replayAttempted && replayStatusCode === null ? "replay_failed" : result?.status ?? "heal_unreachable",
|
|
391
|
+
replayStatusCode,
|
|
392
|
+
healMs: Math.round(performance.now() - started),
|
|
393
|
+
operations: result?.operations
|
|
394
|
+
})).catch(() => warn("onHeal callback failed"));
|
|
395
|
+
} catch {
|
|
396
|
+
warn("onHeal callback failed");
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
function buildRetry(request, originalBody, result) {
|
|
403
|
+
if (!result || !["patched", "unverified"].includes(result.status) || !isObject(result.healedRequest)) return null;
|
|
404
|
+
const healed = result.healedRequest;
|
|
405
|
+
if (!["url", "headers", "body"].some((key) => Object.hasOwn(healed, key))) return null;
|
|
406
|
+
try {
|
|
407
|
+
const url = new URL(healed.url ?? request.url);
|
|
408
|
+
if (url.origin !== new URL(request.url).origin || url.username || url.password) return null;
|
|
409
|
+
const headers = new Headers(request.headers);
|
|
410
|
+
headers.delete("content-length");
|
|
411
|
+
if (healed.headers !== void 0 && !isObject(healed.headers)) return null;
|
|
412
|
+
for (const [name, value] of Object.entries(healed.headers ?? {})) {
|
|
413
|
+
if (value === null) headers.delete(name);
|
|
414
|
+
else if (typeof value === "string") headers.set(name, value);
|
|
415
|
+
else return null;
|
|
416
|
+
}
|
|
417
|
+
const body = Object.hasOwn(healed, "body") ? mergeBody(originalBody, healed.body) : originalBody;
|
|
418
|
+
if (body === null && !["GET", "HEAD"].includes(request.method)) return null;
|
|
419
|
+
return new Request(url, {
|
|
420
|
+
method: request.method,
|
|
421
|
+
headers,
|
|
422
|
+
body: ["GET", "HEAD"].includes(request.method) ? void 0 : JSON.stringify(body),
|
|
423
|
+
signal: request.signal,
|
|
424
|
+
redirect: request.redirect,
|
|
425
|
+
credentials: request.credentials,
|
|
426
|
+
cache: request.cache,
|
|
427
|
+
integrity: request.integrity,
|
|
428
|
+
keepalive: request.keepalive,
|
|
429
|
+
mode: request.mode,
|
|
430
|
+
referrer: request.referrer,
|
|
431
|
+
referrerPolicy: request.referrerPolicy
|
|
432
|
+
});
|
|
433
|
+
} catch {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// src/index.ts
|
|
439
|
+
var STATE = /* @__PURE__ */ Symbol.for("mnfst.node.runtime.v1");
|
|
440
|
+
var globals = globalThis;
|
|
441
|
+
function manifest(options = {}) {
|
|
442
|
+
const key = options.key || process.env.MNFST_KEY;
|
|
443
|
+
if (!key) {
|
|
444
|
+
warn("MNFST_KEY is not set; Manifest is disabled");
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
const url = new URL(options.url || process.env.MNFST_URL || "https://api.manifest.build");
|
|
448
|
+
if (!["https:", "http:"].includes(url.protocol) || url.username || url.password || url.search || url.hash) {
|
|
449
|
+
throw new TypeError("Manifest URL must be an HTTP(S) base URL without credentials, query or fragment");
|
|
450
|
+
}
|
|
451
|
+
if (!url.pathname.endsWith("/")) url.pathname += "/";
|
|
452
|
+
const resolved = { ...options, key, url: url.toString() };
|
|
453
|
+
const existing = globals[STATE];
|
|
454
|
+
if (existing) {
|
|
455
|
+
if (existing.options.key !== key || existing.options.url !== resolved.url || existing.options.onHeal !== options.onHeal) {
|
|
456
|
+
warn("Manifest is already configured; changing configuration requires a process restart");
|
|
457
|
+
}
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
const runtime = new Runtime(resolved, globalThis.fetch.bind(globalThis));
|
|
461
|
+
globalThis.fetch = runtime.fetch;
|
|
462
|
+
globals[STATE] = runtime;
|
|
463
|
+
}
|
|
464
|
+
async function flush(options = {}) {
|
|
465
|
+
await globals[STATE]?.api.flush(options.timeoutMs ?? 5e3);
|
|
466
|
+
}
|
|
467
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
468
|
+
0 && (module.exports = {
|
|
469
|
+
VERSION,
|
|
470
|
+
flush,
|
|
471
|
+
manifest
|
|
472
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface ManifestOptions {
|
|
2
|
+
key?: string;
|
|
3
|
+
url?: string;
|
|
4
|
+
onHeal?: (event: HealEvent) => void | Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
interface HealEvent {
|
|
7
|
+
url: string;
|
|
8
|
+
statusCode: number;
|
|
9
|
+
healStatus: string;
|
|
10
|
+
replayStatusCode: number | null;
|
|
11
|
+
healMs: number;
|
|
12
|
+
operations?: unknown[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare const VERSION = "6.0.0";
|
|
16
|
+
|
|
17
|
+
/** Install once, before libraries capture their own reference to global fetch. */
|
|
18
|
+
declare function manifest(options?: ManifestOptions): void;
|
|
19
|
+
/** Wait for queued outcome reports within one total deadline. Does not uninstall. */
|
|
20
|
+
declare function flush(options?: {
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
|
|
24
|
+
export { type HealEvent, type ManifestOptions, VERSION, flush, manifest };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface ManifestOptions {
|
|
2
|
+
key?: string;
|
|
3
|
+
url?: string;
|
|
4
|
+
onHeal?: (event: HealEvent) => void | Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
interface HealEvent {
|
|
7
|
+
url: string;
|
|
8
|
+
statusCode: number;
|
|
9
|
+
healStatus: string;
|
|
10
|
+
replayStatusCode: number | null;
|
|
11
|
+
healMs: number;
|
|
12
|
+
operations?: unknown[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare const VERSION = "6.0.0";
|
|
16
|
+
|
|
17
|
+
/** Install once, before libraries capture their own reference to global fetch. */
|
|
18
|
+
declare function manifest(options?: ManifestOptions): void;
|
|
19
|
+
/** Wait for queued outcome reports within one total deadline. Does not uninstall. */
|
|
20
|
+
declare function flush(options?: {
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
|
|
24
|
+
export { type HealEvent, type ManifestOptions, VERSION, flush, manifest };
|