manifest 5.45.1 → 7.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.
Files changed (414) hide show
  1. package/CONTRACT.md +50 -0
  2. package/README.md +47 -101
  3. package/dist/chunk-DP2C4E42.js +720 -0
  4. package/dist/index.cjs +757 -0
  5. package/dist/index.d.cts +20 -0
  6. package/dist/index.d.ts +20 -0
  7. package/dist/index.js +8 -18
  8. package/dist/register.cjs +742 -0
  9. package/dist/register.d.cts +2 -0
  10. package/dist/register.d.ts +2 -0
  11. package/dist/register.js +6 -0
  12. package/docs/guide.md +94 -0
  13. package/docs/healing-diagram.svg +549 -0
  14. package/package.json +50 -79
  15. package/dist/backend/analytics/analytics.module.js +0 -60
  16. package/dist/backend/analytics/controllers/agent-analytics.controller.js +0 -69
  17. package/dist/backend/analytics/controllers/agents.controller.js +0 -176
  18. package/dist/backend/analytics/controllers/costs.controller.js +0 -71
  19. package/dist/backend/analytics/controllers/messages.controller.js +0 -67
  20. package/dist/backend/analytics/controllers/overview.controller.js +0 -104
  21. package/dist/backend/analytics/controllers/tokens.controller.js +0 -74
  22. package/dist/backend/analytics/dto/messages-query.dto.js +0 -73
  23. package/dist/backend/analytics/services/agent-analytics.service.js +0 -125
  24. package/dist/backend/analytics/services/agent-lifecycle.service.js +0 -102
  25. package/dist/backend/analytics/services/aggregation.service.js +0 -205
  26. package/dist/backend/analytics/services/message-details.service.js +0 -147
  27. package/dist/backend/analytics/services/messages-query.service.js +0 -197
  28. package/dist/backend/analytics/services/query-helpers.js +0 -45
  29. package/dist/backend/analytics/services/timeseries-queries.service.js +0 -237
  30. package/dist/backend/app.module.js +0 -94
  31. package/dist/backend/auth/auth.instance.js +0 -121
  32. package/dist/backend/auth/auth.module.js +0 -17
  33. package/dist/backend/auth/current-user.decorator.js +0 -9
  34. package/dist/backend/auth/local-auth.guard.js +0 -51
  35. package/dist/backend/auth/session.guard.js +0 -57
  36. package/dist/backend/common/common.module.js +0 -41
  37. package/dist/backend/common/constants/api-key.constants.js +0 -6
  38. package/dist/backend/common/constants/cache.constants.js +0 -8
  39. package/dist/backend/common/constants/local-mode.constants.js +0 -102
  40. package/dist/backend/common/constants/ollama.js +0 -5
  41. package/dist/backend/common/constants/providers.js +0 -134
  42. package/dist/backend/common/decorators/public.decorator.js +0 -8
  43. package/dist/backend/common/dto/create-agent.dto.js +0 -26
  44. package/dist/backend/common/dto/range-query.dto.js +0 -29
  45. package/dist/backend/common/dto/rename-agent.dto.js +0 -26
  46. package/dist/backend/common/filters/spa-fallback.filter.js +0 -46
  47. package/dist/backend/common/guards/api-key.guard.js +0 -89
  48. package/dist/backend/common/interceptors/agent-cache.interceptor.js +0 -39
  49. package/dist/backend/common/interceptors/user-cache.interceptor.js +0 -39
  50. package/dist/backend/common/middleware/http-error-logger.middleware.js +0 -19
  51. package/dist/backend/common/services/ingest-event-bus.service.js +0 -44
  52. package/dist/backend/common/services/manifest-runtime.service.js +0 -39
  53. package/dist/backend/common/services/tenant-cache.service.js +0 -56
  54. package/dist/backend/common/utils/anthropic-model-id.js +0 -36
  55. package/dist/backend/common/utils/cost-calculator.js +0 -19
  56. package/dist/backend/common/utils/crypto.util.js +0 -72
  57. package/dist/backend/common/utils/frontend-path.js +0 -21
  58. package/dist/backend/common/utils/hash.util.js +0 -32
  59. package/dist/backend/common/utils/local-ip.js +0 -33
  60. package/dist/backend/common/utils/period.util.js +0 -55
  61. package/dist/backend/common/utils/provider-aliases.js +0 -13
  62. package/dist/backend/common/utils/provider-inference.js +0 -7
  63. package/dist/backend/common/utils/range.util.js +0 -29
  64. package/dist/backend/common/utils/slugify.js +0 -13
  65. package/dist/backend/common/utils/sql-dialect.js +0 -71
  66. package/dist/backend/common/utils/subscription-support.js +0 -12
  67. package/dist/backend/common/utils/ttl-cache.js +0 -59
  68. package/dist/backend/common/utils/url-validation.js +0 -107
  69. package/dist/backend/config/app.config.js +0 -48
  70. package/dist/backend/database/database-seeder.service.js +0 -180
  71. package/dist/backend/database/database.module.js +0 -201
  72. package/dist/backend/database/datasource.js +0 -28
  73. package/dist/backend/database/local-bootstrap.service.js +0 -161
  74. package/dist/backend/database/migrations/1771464895790-InitialSchema.js +0 -91
  75. package/dist/backend/database/migrations/1771500000000-HashApiKeys.js +0 -67
  76. package/dist/backend/database/migrations/1771600000000-AddModelCapabilities.js +0 -27
  77. package/dist/backend/database/migrations/1771600000000-ModelPricingImprovements.js +0 -60
  78. package/dist/backend/database/migrations/1771700000000-AddRoutingTables.js +0 -50
  79. package/dist/backend/database/migrations/1771700000000-EmailProviderConfigs.js +0 -31
  80. package/dist/backend/database/migrations/1771800000000-AddNotificationEmailAndOptionalDomain.js +0 -16
  81. package/dist/backend/database/migrations/1771800000000-AddQualityScore.js +0 -50
  82. package/dist/backend/database/migrations/1771800100000-SeedQualityScores.js +0 -45
  83. package/dist/backend/database/migrations/1771900000000-EncryptApiKeys.js +0 -34
  84. package/dist/backend/database/migrations/1772000000000-MakeApiKeyNullable.js +0 -16
  85. package/dist/backend/database/migrations/1772100000000-AddRoutingTier.js +0 -17
  86. package/dist/backend/database/migrations/1772200000000-AddLimitAction.js +0 -17
  87. package/dist/backend/database/migrations/1772300000000-AddRoutingReason.js +0 -17
  88. package/dist/backend/database/migrations/1772400000000-AddAgentDisplayName.js +0 -13
  89. package/dist/backend/database/migrations/1772500000000-PerAgentRouting.js +0 -82
  90. package/dist/backend/database/migrations/1772668898071-AddCustomProviders.js +0 -31
  91. package/dist/backend/database/migrations/1772682112419-NullablePricing.js +0 -17
  92. package/dist/backend/database/migrations/1772843035514-AddPerformanceIndexes.js +0 -56
  93. package/dist/backend/database/migrations/1772900000000-AddProviderAuthType.js +0 -13
  94. package/dist/backend/database/migrations/1772905146384-AddDashboardIndexes.js +0 -24
  95. package/dist/backend/database/migrations/1772905260464-AddFallbacks.js +0 -18
  96. package/dist/backend/database/migrations/1772920000000-AddModelDisplayName.js +0 -14
  97. package/dist/backend/database/migrations/1772940000000-DropRedundantIndexes.js +0 -39
  98. package/dist/backend/database/migrations/1772948502780-BackfillTenantId.js +0 -20
  99. package/dist/backend/database/migrations/1772960000000-DropUnusedIndexes.js +0 -19
  100. package/dist/backend/database/migrations/1772960000000-PurgeNonCuratedModels.js +0 -86
  101. package/dist/backend/database/migrations/1773000000000-ExpandProviderUniqueKey.js +0 -19
  102. package/dist/backend/database/migrations/1773100000000-AddOverrideAuthType.js +0 -18
  103. package/dist/backend/database/migrations/1773200000000-AddMessageAuthType.js +0 -18
  104. package/dist/backend/database/migrations/1773202787708-AddModelsAgentIndex.js +0 -16
  105. package/dist/backend/database/migrations/1773300000000-AddEmailProviderKeyPrefix.js +0 -13
  106. package/dist/backend/database/migrations/1773400000000-AddProviderModelCache.js +0 -15
  107. package/dist/backend/database/migrations/1773500000000-DropModelPricingTables.js +0 -51
  108. package/dist/backend/database/migrations/1773600000000-AddOverrideProvider.js +0 -18
  109. package/dist/backend/database/migrations/1773650000000-AddProviderRegion.js +0 -13
  110. package/dist/backend/database/migrations/1773700000000-DropSecurityEventTable.js +0 -24
  111. package/dist/backend/database/migrations/1773800000000-FixNegativeCosts.js +0 -12
  112. package/dist/backend/database/migrations/1773900000000-AddKeyPrefixIndex.js +0 -15
  113. package/dist/backend/database/migrations/1774000000000-WidenKeyHashColumn.js +0 -15
  114. package/dist/backend/database/migrations/1774896789000-WidenApiKeyColumn.js +0 -14
  115. package/dist/backend/database/migrations/1775000000000-AddErrorHttpStatus.js +0 -18
  116. package/dist/backend/database/models-dev-sync.service.js +0 -238
  117. package/dist/backend/database/ollama-sync.service.js +0 -70
  118. package/dist/backend/database/pricing-sync.service.js +0 -116
  119. package/dist/backend/database/quality-score.util.js +0 -76
  120. package/dist/backend/database/seed-messages.js +0 -66
  121. package/dist/backend/entities/agent-api-key.entity.js +0 -91
  122. package/dist/backend/entities/agent-log.entity.js +0 -71
  123. package/dist/backend/entities/agent-message.entity.js +0 -163
  124. package/dist/backend/entities/agent.entity.js +0 -75
  125. package/dist/backend/entities/api-key.entity.js +0 -62
  126. package/dist/backend/entities/cost-snapshot.entity.js +0 -56
  127. package/dist/backend/entities/custom-provider.entity.js +0 -64
  128. package/dist/backend/entities/email-provider-config.entity.js +0 -72
  129. package/dist/backend/entities/llm-call.entity.js +0 -106
  130. package/dist/backend/entities/notification-log.entity.js +0 -67
  131. package/dist/backend/entities/notification-rule.entity.js +0 -84
  132. package/dist/backend/entities/tenant.entity.js +0 -62
  133. package/dist/backend/entities/tier-assignment.entity.js +0 -72
  134. package/dist/backend/entities/token-usage-snapshot.entity.js +0 -71
  135. package/dist/backend/entities/tool-execution.entity.js +0 -60
  136. package/dist/backend/entities/user-provider.entity.js +0 -87
  137. package/dist/backend/github/github.controller.js +0 -53
  138. package/dist/backend/github/github.module.js +0 -20
  139. package/dist/backend/health/health.controller.js +0 -51
  140. package/dist/backend/health/health.module.js +0 -22
  141. package/dist/backend/health/version-check.service.js +0 -95
  142. package/dist/backend/main.js +0 -154
  143. package/dist/backend/model-discovery/anthropic-subscription-probe.js +0 -87
  144. package/dist/backend/model-discovery/known-model-prices.js +0 -18
  145. package/dist/backend/model-discovery/model-discovery.module.js +0 -28
  146. package/dist/backend/model-discovery/model-discovery.service.js +0 -309
  147. package/dist/backend/model-discovery/model-fallback.js +0 -234
  148. package/dist/backend/model-discovery/model-fetcher.js +0 -3
  149. package/dist/backend/model-discovery/provider-model-fetcher.service.js +0 -376
  150. package/dist/backend/model-discovery/provider-model-registry.service.js +0 -84
  151. package/dist/backend/model-prices/model-name-normalizer.js +0 -129
  152. package/dist/backend/model-prices/model-prices.controller.js +0 -39
  153. package/dist/backend/model-prices/model-prices.module.js +0 -41
  154. package/dist/backend/model-prices/model-prices.service.js +0 -45
  155. package/dist/backend/model-prices/model-pricing-cache.service.js +0 -171
  156. package/dist/backend/notifications/dto/notification-rule.dto.js +0 -82
  157. package/dist/backend/notifications/dto/set-email-provider.dto.js +0 -86
  158. package/dist/backend/notifications/dto/set-notification-email.dto.js +0 -24
  159. package/dist/backend/notifications/emails/reset-password.js +0 -108
  160. package/dist/backend/notifications/emails/test-email.js +0 -91
  161. package/dist/backend/notifications/emails/threshold-alert.js +0 -187
  162. package/dist/backend/notifications/emails/verify-email.js +0 -108
  163. package/dist/backend/notifications/notifications.controller.js +0 -208
  164. package/dist/backend/notifications/notifications.module.js +0 -35
  165. package/dist/backend/notifications/services/email-provider-config.service.js +0 -184
  166. package/dist/backend/notifications/services/email-provider-validation.js +0 -47
  167. package/dist/backend/notifications/services/email-providers/email-provider.interface.js +0 -3
  168. package/dist/backend/notifications/services/email-providers/mailgun.provider.js +0 -62
  169. package/dist/backend/notifications/services/email-providers/resend.provider.js +0 -51
  170. package/dist/backend/notifications/services/email-providers/resolve-provider.js +0 -19
  171. package/dist/backend/notifications/services/email-providers/send-email.js +0 -34
  172. package/dist/backend/notifications/services/email-providers/sendgrid.provider.js +0 -59
  173. package/dist/backend/notifications/services/limit-check.service.js +0 -160
  174. package/dist/backend/notifications/services/notification-cron.service.js +0 -151
  175. package/dist/backend/notifications/services/notification-email.service.js +0 -65
  176. package/dist/backend/notifications/services/notification-log.service.js +0 -84
  177. package/dist/backend/notifications/services/notification-rules.service.js +0 -156
  178. package/dist/backend/otlp/guards/agent-key-auth.guard.js +0 -226
  179. package/dist/backend/otlp/interfaces/ingestion-context.interface.js +0 -3
  180. package/dist/backend/otlp/otlp-deprecated.controller.js +0 -61
  181. package/dist/backend/otlp/otlp.module.js +0 -30
  182. package/dist/backend/otlp/services/api-key.service.js +0 -143
  183. package/dist/backend/public-stats/public-stats.controller.js +0 -141
  184. package/dist/backend/public-stats/public-stats.module.js +0 -26
  185. package/dist/backend/public-stats/public-stats.service.js +0 -226
  186. package/dist/backend/routing/copilot.controller.js +0 -79
  187. package/dist/backend/routing/custom-provider/custom-provider.controller.js +0 -131
  188. package/dist/backend/routing/custom-provider/custom-provider.module.js +0 -27
  189. package/dist/backend/routing/custom-provider/custom-provider.service.js +0 -161
  190. package/dist/backend/routing/dto/custom-provider.dto.js +0 -124
  191. package/dist/backend/routing/dto/resolve-request.dto.js +0 -63
  192. package/dist/backend/routing/dto/resolve-response.js +0 -3
  193. package/dist/backend/routing/dto/routing.dto.js +0 -136
  194. package/dist/backend/routing/model.controller.js +0 -105
  195. package/dist/backend/routing/oauth/copilot-device-auth.service.js +0 -77
  196. package/dist/backend/routing/oauth/minimax-oauth-helpers.js +0 -70
  197. package/dist/backend/routing/oauth/minimax-oauth.controller.js +0 -80
  198. package/dist/backend/routing/oauth/minimax-oauth.service.js +0 -252
  199. package/dist/backend/routing/oauth/oauth.module.js +0 -29
  200. package/dist/backend/routing/oauth/openai-oauth.controller.js +0 -138
  201. package/dist/backend/routing/oauth/openai-oauth.service.js +0 -273
  202. package/dist/backend/routing/oauth/openai-oauth.types.js +0 -45
  203. package/dist/backend/routing/provider-base-url.js +0 -25
  204. package/dist/backend/routing/provider.controller.js +0 -152
  205. package/dist/backend/routing/proxy/anthropic-adapter.js +0 -295
  206. package/dist/backend/routing/proxy/cache-injection.js +0 -33
  207. package/dist/backend/routing/proxy/chatgpt-adapter.js +0 -272
  208. package/dist/backend/routing/proxy/chatgpt-helpers.js +0 -108
  209. package/dist/backend/routing/proxy/copilot-token.service.js +0 -63
  210. package/dist/backend/routing/proxy/fallback-status-codes.js +0 -7
  211. package/dist/backend/routing/proxy/google-adapter.js +0 -314
  212. package/dist/backend/routing/proxy/provider-client-converters.js +0 -190
  213. package/dist/backend/routing/proxy/provider-client.js +0 -130
  214. package/dist/backend/routing/proxy/provider-endpoints.js +0 -182
  215. package/dist/backend/routing/proxy/proxy-error-sanitizer.js +0 -40
  216. package/dist/backend/routing/proxy/proxy-exception.filter.js +0 -67
  217. package/dist/backend/routing/proxy/proxy-fallback.service.js +0 -227
  218. package/dist/backend/routing/proxy/proxy-friendly-response.js +0 -115
  219. package/dist/backend/routing/proxy/proxy-message-dedup.js +0 -121
  220. package/dist/backend/routing/proxy/proxy-message-recorder.js +0 -264
  221. package/dist/backend/routing/proxy/proxy-rate-limiter.js +0 -81
  222. package/dist/backend/routing/proxy/proxy-response-handler.js +0 -202
  223. package/dist/backend/routing/proxy/proxy-transport.js +0 -90
  224. package/dist/backend/routing/proxy/proxy-types.js +0 -3
  225. package/dist/backend/routing/proxy/proxy.controller.js +0 -174
  226. package/dist/backend/routing/proxy/proxy.module.js +0 -62
  227. package/dist/backend/routing/proxy/proxy.service.js +0 -227
  228. package/dist/backend/routing/proxy/session-momentum.service.js +0 -66
  229. package/dist/backend/routing/proxy/stream-writer.js +0 -147
  230. package/dist/backend/routing/proxy/thought-signature-cache.js +0 -45
  231. package/dist/backend/routing/qwen-region.js +0 -51
  232. package/dist/backend/routing/resolve/resolve.controller.js +0 -106
  233. package/dist/backend/routing/resolve/resolve.module.js +0 -28
  234. package/dist/backend/routing/resolve/resolve.service.js +0 -126
  235. package/dist/backend/routing/routing-core/provider-key.service.js +0 -190
  236. package/dist/backend/routing/routing-core/provider.service.js +0 -305
  237. package/dist/backend/routing/routing-core/resolve-agent.service.js +0 -62
  238. package/dist/backend/routing/routing-core/routing-cache.service.js +0 -73
  239. package/dist/backend/routing/routing-core/routing-core.module.js +0 -56
  240. package/dist/backend/routing/routing-core/routing-invalidation.service.js +0 -90
  241. package/dist/backend/routing/routing-core/tier-auto-assign.service.js +0 -138
  242. package/dist/backend/routing/routing-core/tier.service.js +0 -179
  243. package/dist/backend/routing/routing.module.js +0 -46
  244. package/dist/backend/routing/tier.controller.js +0 -129
  245. package/dist/backend/scoring/__tests__/fixtures.js +0 -191
  246. package/dist/backend/scoring/config.js +0 -383
  247. package/dist/backend/scoring/dimensions/contextual-dimensions.js +0 -85
  248. package/dist/backend/scoring/dimensions/index.js +0 -17
  249. package/dist/backend/scoring/dimensions/keyword-dimensions.js +0 -47
  250. package/dist/backend/scoring/dimensions/structural-dimensions.js +0 -118
  251. package/dist/backend/scoring/index.js +0 -186
  252. package/dist/backend/scoring/keyword-trie.js +0 -75
  253. package/dist/backend/scoring/momentum.js +0 -50
  254. package/dist/backend/scoring/overrides.js +0 -55
  255. package/dist/backend/scoring/sigmoid.js +0 -24
  256. package/dist/backend/scoring/text-extractor.js +0 -67
  257. package/dist/backend/scoring/types.js +0 -6
  258. package/dist/backend/sse/sse.controller.js +0 -45
  259. package/dist/backend/sse/sse.module.js +0 -20
  260. package/dist/node_modules/manifest-shared/dist/cjs/api-key.d.ts +0 -2
  261. package/dist/node_modules/manifest-shared/dist/cjs/api-key.d.ts.map +0 -1
  262. package/dist/node_modules/manifest-shared/dist/cjs/api-key.js +0 -5
  263. package/dist/node_modules/manifest-shared/dist/cjs/api-key.js.map +0 -1
  264. package/dist/node_modules/manifest-shared/dist/cjs/auth-types.d.ts +0 -3
  265. package/dist/node_modules/manifest-shared/dist/cjs/auth-types.d.ts.map +0 -1
  266. package/dist/node_modules/manifest-shared/dist/cjs/auth-types.js +0 -5
  267. package/dist/node_modules/manifest-shared/dist/cjs/auth-types.js.map +0 -1
  268. package/dist/node_modules/manifest-shared/dist/cjs/index.d.ts +0 -10
  269. package/dist/node_modules/manifest-shared/dist/cjs/index.d.ts.map +0 -1
  270. package/dist/node_modules/manifest-shared/dist/cjs/index.js +0 -22
  271. package/dist/node_modules/manifest-shared/dist/cjs/index.js.map +0 -1
  272. package/dist/node_modules/manifest-shared/dist/cjs/provider-inference.d.ts +0 -8
  273. package/dist/node_modules/manifest-shared/dist/cjs/provider-inference.d.ts.map +0 -1
  274. package/dist/node_modules/manifest-shared/dist/cjs/provider-inference.js +0 -37
  275. package/dist/node_modules/manifest-shared/dist/cjs/provider-inference.js.map +0 -1
  276. package/dist/node_modules/manifest-shared/dist/cjs/resolve-response.d.ts +0 -12
  277. package/dist/node_modules/manifest-shared/dist/cjs/resolve-response.d.ts.map +0 -1
  278. package/dist/node_modules/manifest-shared/dist/cjs/resolve-response.js +0 -3
  279. package/dist/node_modules/manifest-shared/dist/cjs/resolve-response.js.map +0 -1
  280. package/dist/node_modules/manifest-shared/dist/cjs/subscription/configs.d.ts +0 -4
  281. package/dist/node_modules/manifest-shared/dist/cjs/subscription/configs.d.ts.map +0 -1
  282. package/dist/node_modules/manifest-shared/dist/cjs/subscription/configs.js +0 -80
  283. package/dist/node_modules/manifest-shared/dist/cjs/subscription/configs.js.map +0 -1
  284. package/dist/node_modules/manifest-shared/dist/cjs/subscription/helpers.d.ts +0 -6
  285. package/dist/node_modules/manifest-shared/dist/cjs/subscription/helpers.d.ts.map +0 -1
  286. package/dist/node_modules/manifest-shared/dist/cjs/subscription/helpers.js +0 -25
  287. package/dist/node_modules/manifest-shared/dist/cjs/subscription/helpers.js.map +0 -1
  288. package/dist/node_modules/manifest-shared/dist/cjs/subscription/index.d.ts +0 -4
  289. package/dist/node_modules/manifest-shared/dist/cjs/subscription/index.d.ts.map +0 -1
  290. package/dist/node_modules/manifest-shared/dist/cjs/subscription/index.js +0 -12
  291. package/dist/node_modules/manifest-shared/dist/cjs/subscription/index.js.map +0 -1
  292. package/dist/node_modules/manifest-shared/dist/cjs/subscription/types.d.ts +0 -17
  293. package/dist/node_modules/manifest-shared/dist/cjs/subscription/types.d.ts.map +0 -1
  294. package/dist/node_modules/manifest-shared/dist/cjs/subscription/types.js +0 -3
  295. package/dist/node_modules/manifest-shared/dist/cjs/subscription/types.js.map +0 -1
  296. package/dist/node_modules/manifest-shared/dist/cjs/tiers.d.ts +0 -5
  297. package/dist/node_modules/manifest-shared/dist/cjs/tiers.d.ts.map +0 -1
  298. package/dist/node_modules/manifest-shared/dist/cjs/tiers.js +0 -17
  299. package/dist/node_modules/manifest-shared/dist/cjs/tiers.js.map +0 -1
  300. package/dist/node_modules/manifest-shared/dist/esm/api-key.d.ts +0 -2
  301. package/dist/node_modules/manifest-shared/dist/esm/api-key.d.ts.map +0 -1
  302. package/dist/node_modules/manifest-shared/dist/esm/api-key.js +0 -2
  303. package/dist/node_modules/manifest-shared/dist/esm/api-key.js.map +0 -1
  304. package/dist/node_modules/manifest-shared/dist/esm/auth-types.d.ts +0 -3
  305. package/dist/node_modules/manifest-shared/dist/esm/auth-types.d.ts.map +0 -1
  306. package/dist/node_modules/manifest-shared/dist/esm/auth-types.js +0 -2
  307. package/dist/node_modules/manifest-shared/dist/esm/auth-types.js.map +0 -1
  308. package/dist/node_modules/manifest-shared/dist/esm/index.d.ts +0 -10
  309. package/dist/node_modules/manifest-shared/dist/esm/index.d.ts.map +0 -1
  310. package/dist/node_modules/manifest-shared/dist/esm/index.js +0 -6
  311. package/dist/node_modules/manifest-shared/dist/esm/index.js.map +0 -1
  312. package/dist/node_modules/manifest-shared/dist/esm/provider-inference.d.ts +0 -8
  313. package/dist/node_modules/manifest-shared/dist/esm/provider-inference.d.ts.map +0 -1
  314. package/dist/node_modules/manifest-shared/dist/esm/provider-inference.js +0 -33
  315. package/dist/node_modules/manifest-shared/dist/esm/provider-inference.js.map +0 -1
  316. package/dist/node_modules/manifest-shared/dist/esm/resolve-response.d.ts +0 -12
  317. package/dist/node_modules/manifest-shared/dist/esm/resolve-response.d.ts.map +0 -1
  318. package/dist/node_modules/manifest-shared/dist/esm/resolve-response.js +0 -2
  319. package/dist/node_modules/manifest-shared/dist/esm/resolve-response.js.map +0 -1
  320. package/dist/node_modules/manifest-shared/dist/esm/subscription/configs.d.ts +0 -4
  321. package/dist/node_modules/manifest-shared/dist/esm/subscription/configs.d.ts.map +0 -1
  322. package/dist/node_modules/manifest-shared/dist/esm/subscription/configs.js +0 -77
  323. package/dist/node_modules/manifest-shared/dist/esm/subscription/configs.js.map +0 -1
  324. package/dist/node_modules/manifest-shared/dist/esm/subscription/helpers.d.ts +0 -6
  325. package/dist/node_modules/manifest-shared/dist/esm/subscription/helpers.d.ts.map +0 -1
  326. package/dist/node_modules/manifest-shared/dist/esm/subscription/helpers.js +0 -19
  327. package/dist/node_modules/manifest-shared/dist/esm/subscription/helpers.js.map +0 -1
  328. package/dist/node_modules/manifest-shared/dist/esm/subscription/index.d.ts +0 -4
  329. package/dist/node_modules/manifest-shared/dist/esm/subscription/index.d.ts.map +0 -1
  330. package/dist/node_modules/manifest-shared/dist/esm/subscription/index.js +0 -3
  331. package/dist/node_modules/manifest-shared/dist/esm/subscription/index.js.map +0 -1
  332. package/dist/node_modules/manifest-shared/dist/esm/subscription/types.d.ts +0 -17
  333. package/dist/node_modules/manifest-shared/dist/esm/subscription/types.d.ts.map +0 -1
  334. package/dist/node_modules/manifest-shared/dist/esm/subscription/types.js +0 -2
  335. package/dist/node_modules/manifest-shared/dist/esm/subscription/types.js.map +0 -1
  336. package/dist/node_modules/manifest-shared/dist/esm/tiers.d.ts +0 -5
  337. package/dist/node_modules/manifest-shared/dist/esm/tiers.d.ts.map +0 -1
  338. package/dist/node_modules/manifest-shared/dist/esm/tiers.js +0 -14
  339. package/dist/node_modules/manifest-shared/dist/esm/tiers.js.map +0 -1
  340. package/dist/node_modules/manifest-shared/package.json +0 -26
  341. package/dist/openclaw.plugin.json +0 -37
  342. package/dist/package.json +0 -94
  343. package/dist/server.d.ts +0 -9
  344. package/dist/server.js +0 -69
  345. package/openclaw.plugin.json +0 -37
  346. package/public/assets/Account-C5g6WhPe.js +0 -1
  347. package/public/assets/AuthBadge-Dj2KkXRW.js +0 -1
  348. package/public/assets/ConnectProvider-axzk92LC.js +0 -1
  349. package/public/assets/CopyButton-BWMVlK2w.js +0 -1
  350. package/public/assets/FreeModels-D14GhDL_.js +0 -1
  351. package/public/assets/Help-ifWIlcDo.js +0 -1
  352. package/public/assets/Limits-Xgc4xTl5.js +0 -1
  353. package/public/assets/Login-DMXD4PMZ.js +0 -1
  354. package/public/assets/MessageLog-DoriYlHo.js +0 -1
  355. package/public/assets/ModelPrices-MhBT_7Zb.js +0 -1
  356. package/public/assets/Overview-Bi9FuoLx.js +0 -1
  357. package/public/assets/Pagination-D8BOkffh.js +0 -1
  358. package/public/assets/ProviderTokens-Cu2RUqQG.js +0 -1
  359. package/public/assets/Register-CrovWG_d.js +0 -1
  360. package/public/assets/ResetPassword-C6B1ubhL.js +0 -1
  361. package/public/assets/Routing-B-On2pvv.js +0 -6
  362. package/public/assets/Settings-BH-xNoID.js +0 -1
  363. package/public/assets/SetupStepAddProvider-CSNkQmoC.js +0 -3
  364. package/public/assets/SocialButtons-DudwEJ6b.js +0 -1
  365. package/public/assets/auth-CU91cd7V.js +0 -1
  366. package/public/assets/chart-utils-DTt1NOye.js +0 -1
  367. package/public/assets/charts-Cty976qB.js +0 -3
  368. package/public/assets/charts-Saz_VHki.css +0 -1
  369. package/public/assets/index-C4Qw7vZo.js +0 -2
  370. package/public/assets/index-DhaXpWfr.css +0 -1
  371. package/public/assets/model-display-DHwvDtl4.js +0 -1
  372. package/public/assets/overview-DKLGwfLs.js +0 -1
  373. package/public/assets/overview-vZEzTjBP.css +0 -1
  374. package/public/assets/provider-api-key-urls-1G6okUJ7.js +0 -1
  375. package/public/assets/routing-CLLAl6kl.js +0 -1
  376. package/public/assets/routing-utils-CHapjwyd.js +0 -1
  377. package/public/assets/vendor-C-Y5oNOq.js +0 -1
  378. package/public/example-messages.svg +0 -1
  379. package/public/example-overview.svg +0 -1
  380. package/public/favicon.ico +0 -0
  381. package/public/fonts/boxicons/boxicons-duotone.min.css +0 -37
  382. package/public/fonts/boxicons/boxicons-duotone.woff2 +0 -0
  383. package/public/fonts/bricolage-grotesque-latin.woff2 +0 -0
  384. package/public/fonts/dm-sans-latin.woff2 +0 -0
  385. package/public/fonts/jetbrains-mono-latin.woff2 +0 -0
  386. package/public/icons/caret-down.svg +0 -1
  387. package/public/icons/cohere.svg +0 -30
  388. package/public/icons/free.svg +0 -91
  389. package/public/icons/gemini.svg +0 -25
  390. package/public/icons/kilocode.jpg +0 -0
  391. package/public/icons/nvidia.svg +0 -1
  392. package/public/icons/providers/alibaba.svg +0 -1
  393. package/public/icons/providers/amazon.svg +0 -1
  394. package/public/icons/providers/anthropic.svg +0 -1
  395. package/public/icons/providers/cohere.svg +0 -1
  396. package/public/icons/providers/deepseek.svg +0 -1
  397. package/public/icons/providers/google.svg +0 -1
  398. package/public/icons/providers/meta.svg +0 -1
  399. package/public/icons/providers/mistral.svg +0 -1
  400. package/public/icons/providers/moonshot.svg +0 -1
  401. package/public/icons/providers/openai.svg +0 -1
  402. package/public/icons/providers/xai.svg +0 -1
  403. package/public/icons/providers/zhipu.svg +0 -1
  404. package/public/icons/qwen.svg +0 -1
  405. package/public/images/oauth-callback-example.mp4 +0 -0
  406. package/public/images/oauth-callback-example.png +0 -0
  407. package/public/index.html +0 -41
  408. package/public/logo-white.svg +0 -93
  409. package/public/logo.svg +0 -93
  410. package/public/logos/mailgun.svg +0 -13
  411. package/public/logos/resend.svg +0 -4
  412. package/public/logos/sendgrid.svg +0 -18
  413. package/public/manifest-logo.png +0 -0
  414. package/public/theme-init.js +0 -6
@@ -1,108 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertAssistantToolCalls = convertAssistantToolCalls;
4
- exports.convertTools = convertTools;
5
- exports.convertContent = convertContent;
6
- exports.extractInstructions = extractInstructions;
7
- exports.extractTextContent = extractTextContent;
8
- exports.isObjectRecord = isObjectRecord;
9
- exports.safeParse = safeParse;
10
- exports.formatSSE = formatSSE;
11
- const crypto_1 = require("crypto");
12
- const DEFAULT_INSTRUCTIONS = 'You are a helpful assistant.';
13
- function convertAssistantToolCalls(toolCalls) {
14
- return toolCalls.flatMap((toolCall) => {
15
- if (!isObjectRecord(toolCall) || !isObjectRecord(toolCall.function))
16
- return [];
17
- return [
18
- {
19
- type: 'function_call',
20
- call_id: typeof toolCall.id === 'string' ? toolCall.id : (0, crypto_1.randomUUID)(),
21
- name: typeof toolCall.function.name === 'string' ? toolCall.function.name : 'unknown',
22
- arguments: typeof toolCall.function.arguments === 'string' ? toolCall.function.arguments : '{}',
23
- },
24
- ];
25
- });
26
- }
27
- function convertTools(tools) {
28
- return tools.map((tool) => {
29
- if (tool.type === 'function' && isObjectRecord(tool.function)) {
30
- return {
31
- type: 'function',
32
- name: tool.function.name,
33
- ...(tool.function.description !== undefined && { description: tool.function.description }),
34
- ...(tool.function.parameters !== undefined && { parameters: tool.function.parameters }),
35
- ...(tool.function.strict !== undefined && { strict: tool.function.strict }),
36
- };
37
- }
38
- return tool;
39
- });
40
- }
41
- function convertContent(content, role) {
42
- const partType = role === 'assistant' ? 'output_text' : 'input_text';
43
- if (content === null || content === undefined) {
44
- return [{ type: partType, text: '' }];
45
- }
46
- if (typeof content === 'string') {
47
- return [{ type: partType, text: content }];
48
- }
49
- if (!Array.isArray(content))
50
- return content;
51
- return content.map((part) => {
52
- if (part.type === 'text')
53
- return { ...part, type: partType };
54
- return part;
55
- });
56
- }
57
- function extractInstructions(messages) {
58
- const instructions = messages
59
- .filter((message) => message.role === 'system' || message.role === 'developer')
60
- .map((message) => extractTextContent(message.content))
61
- .filter((content) => Boolean(content))
62
- .map((content) => content.trim())
63
- .filter(Boolean)
64
- .join('\n\n');
65
- return instructions || DEFAULT_INSTRUCTIONS;
66
- }
67
- function extractTextContent(content) {
68
- if (typeof content === 'string')
69
- return content || null;
70
- if (!Array.isArray(content))
71
- return null;
72
- const text = content
73
- .filter(isObjectRecord)
74
- .map((part) => {
75
- if (!isTextPart(part.type) || typeof part.text !== 'string')
76
- return '';
77
- return part.text;
78
- })
79
- .join('');
80
- return text || null;
81
- }
82
- function isObjectRecord(value) {
83
- return !!value && typeof value === 'object' && !Array.isArray(value);
84
- }
85
- function isTextPart(type) {
86
- return type === 'text' || type === 'input_text' || type === 'output_text';
87
- }
88
- function safeParse(str) {
89
- try {
90
- return JSON.parse(str);
91
- }
92
- catch {
93
- return null;
94
- }
95
- }
96
- function formatSSE(choice, model, usage) {
97
- const payload = {
98
- id: `chatcmpl-${(0, crypto_1.randomUUID)().replace(/-/g, '').slice(0, 29)}`,
99
- object: 'chat.completion.chunk',
100
- created: Math.floor(Date.now() / 1000),
101
- model,
102
- choices: [{ index: 0, ...choice }],
103
- };
104
- if (usage)
105
- payload.usage = usage;
106
- return `data: ${JSON.stringify(payload)}\n\n`;
107
- }
108
- //# sourceMappingURL=chatgpt-helpers.js.map
@@ -1,63 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var CopilotTokenService_1;
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.CopilotTokenService = void 0;
11
- const common_1 = require("@nestjs/common");
12
- const TOKEN_ENDPOINT = 'https://api.github.com/copilot_internal/v2/token';
13
- const EXPIRY_BUFFER_MS = 2 * 60 * 1000;
14
- let CopilotTokenService = CopilotTokenService_1 = class CopilotTokenService {
15
- logger = new common_1.Logger(CopilotTokenService_1.name);
16
- cache = new Map();
17
- async getCopilotToken(githubToken) {
18
- const cached = this.cache.get(githubToken);
19
- if (cached && Date.now() < cached.expiresAt - EXPIRY_BUFFER_MS) {
20
- return cached.token;
21
- }
22
- this.evictExpired();
23
- const result = await this.exchange(githubToken);
24
- this.cache.set(githubToken, result);
25
- return result.token;
26
- }
27
- evictExpired() {
28
- const now = Date.now();
29
- for (const [key, entry] of this.cache) {
30
- if (now >= entry.expiresAt)
31
- this.cache.delete(key);
32
- }
33
- }
34
- async exchange(githubToken) {
35
- const res = await fetch(TOKEN_ENDPOINT, {
36
- method: 'GET',
37
- headers: {
38
- Authorization: `token ${githubToken}`,
39
- Accept: 'application/json',
40
- },
41
- signal: AbortSignal.timeout(10_000),
42
- });
43
- if (!res.ok) {
44
- const body = await res.text().catch(() => '');
45
- this.logger.warn(`Copilot token exchange failed: ${res.status} ${body}`);
46
- throw new Error(`Copilot token exchange failed: ${res.status}`);
47
- }
48
- const data = (await res.json());
49
- if (!data.token || !data.expires_at) {
50
- throw new Error('Invalid Copilot token exchange response');
51
- }
52
- this.logger.debug(`Copilot token exchanged, expires at ${new Date(data.expires_at * 1000).toISOString()}`);
53
- return {
54
- token: data.token,
55
- expiresAt: data.expires_at * 1000,
56
- };
57
- }
58
- };
59
- exports.CopilotTokenService = CopilotTokenService;
60
- exports.CopilotTokenService = CopilotTokenService = CopilotTokenService_1 = __decorate([
61
- (0, common_1.Injectable)()
62
- ], CopilotTokenService);
63
- //# sourceMappingURL=copilot-token.service.js.map
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldTriggerFallback = shouldTriggerFallback;
4
- function shouldTriggerFallback(status) {
5
- return status >= 400;
6
- }
7
- //# sourceMappingURL=fallback-status-codes.js.map
@@ -1,314 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toGoogleRequest = toGoogleRequest;
4
- exports.fromGoogleResponse = fromGoogleResponse;
5
- exports.transformGoogleStreamChunk = transformGoogleStreamChunk;
6
- const crypto_1 = require("crypto");
7
- const UNSUPPORTED_SCHEMA_FIELDS = new Set([
8
- 'patternProperties',
9
- 'additionalProperties',
10
- '$schema',
11
- '$id',
12
- '$ref',
13
- '$defs',
14
- 'definitions',
15
- 'allOf',
16
- 'anyOf',
17
- 'oneOf',
18
- 'not',
19
- 'if',
20
- 'then',
21
- 'else',
22
- 'dependentSchemas',
23
- 'dependentRequired',
24
- 'unevaluatedProperties',
25
- 'unevaluatedItems',
26
- 'contentMediaType',
27
- 'contentEncoding',
28
- 'examples',
29
- 'default',
30
- 'const',
31
- 'title',
32
- ]);
33
- function sanitizeSchema(schema, isPropertiesMap = false) {
34
- if (schema === null || schema === undefined || typeof schema !== 'object') {
35
- return schema;
36
- }
37
- if (Array.isArray(schema)) {
38
- return schema.map((item) => sanitizeSchema(item));
39
- }
40
- const result = {};
41
- for (const [key, value] of Object.entries(schema)) {
42
- if (!isPropertiesMap && UNSUPPORTED_SCHEMA_FIELDS.has(key))
43
- continue;
44
- result[key] = sanitizeSchema(value, key === 'properties');
45
- }
46
- return result;
47
- }
48
- function safeParseArgs(args) {
49
- try {
50
- return JSON.parse(args || '{}');
51
- }
52
- catch {
53
- return {};
54
- }
55
- }
56
- function mapRole(role) {
57
- if (role === 'assistant')
58
- return 'model';
59
- if (role === 'system')
60
- return 'user';
61
- return 'user';
62
- }
63
- function messageToContent(msg, signatureLookup) {
64
- const parts = [];
65
- if (typeof msg.content === 'string') {
66
- parts.push({ text: msg.content });
67
- }
68
- else if (Array.isArray(msg.content)) {
69
- for (const block of msg.content) {
70
- if (block.type === 'text' && typeof block.text === 'string') {
71
- parts.push({ text: block.text });
72
- }
73
- }
74
- }
75
- if (Array.isArray(msg.tool_calls)) {
76
- for (const tc of msg.tool_calls) {
77
- const functionCall = {
78
- name: tc.function.name,
79
- args: safeParseArgs(tc.function.arguments),
80
- };
81
- const sig = tc.thought_signature;
82
- if (sig) {
83
- functionCall.thought_signature = sig;
84
- }
85
- else if (signatureLookup) {
86
- const cached = signatureLookup(tc.id);
87
- if (cached)
88
- functionCall.thought_signature = cached;
89
- }
90
- parts.push({ functionCall });
91
- }
92
- }
93
- if (msg.role === 'tool' && typeof msg.content === 'string') {
94
- return {
95
- role: 'user',
96
- parts: [
97
- {
98
- functionResponse: {
99
- name: msg.tool_call_id || 'unknown',
100
- response: { result: msg.content },
101
- },
102
- },
103
- ],
104
- };
105
- }
106
- if (parts.length === 0)
107
- return null;
108
- return { role: mapRole(msg.role), parts };
109
- }
110
- function convertTools(tools) {
111
- if (!tools || tools.length === 0)
112
- return undefined;
113
- const declarations = tools
114
- .map((t) => {
115
- const fn = t.function;
116
- if (!fn)
117
- return null;
118
- return {
119
- name: fn.name,
120
- description: fn.description,
121
- parameters: fn.parameters ? sanitizeSchema(fn.parameters) : undefined,
122
- };
123
- })
124
- .filter(Boolean);
125
- if (declarations.length === 0)
126
- return undefined;
127
- return [{ functionDeclarations: declarations }];
128
- }
129
- function toGoogleRequest(body, _model, signatureLookup) {
130
- const messages = body.messages || [];
131
- const contents = [];
132
- const systemMsgs = messages.filter((m) => m.role === 'system');
133
- const systemText = systemMsgs
134
- .map((m) => (typeof m.content === 'string' ? m.content : ''))
135
- .filter(Boolean)
136
- .join('\n');
137
- for (const msg of messages) {
138
- if (msg.role === 'system')
139
- continue;
140
- const content = messageToContent(msg, signatureLookup);
141
- if (content)
142
- contents.push(content);
143
- }
144
- const result = { contents };
145
- if (systemText) {
146
- result.systemInstruction = {
147
- parts: [{ text: systemText }],
148
- };
149
- }
150
- const tools = convertTools(body.tools);
151
- if (tools)
152
- result.tools = tools;
153
- const genConfig = {};
154
- if (body.max_tokens !== undefined)
155
- genConfig.maxOutputTokens = body.max_tokens;
156
- if (body.temperature !== undefined)
157
- genConfig.temperature = body.temperature;
158
- if (body.top_p !== undefined)
159
- genConfig.topP = body.top_p;
160
- if (Object.keys(genConfig).length > 0)
161
- result.generationConfig = genConfig;
162
- return result;
163
- }
164
- function fromGoogleResponse(googleResp, model) {
165
- const candidates = googleResp.candidates || [];
166
- const candidate = candidates[0];
167
- if (!candidate) {
168
- return {
169
- id: `chatcmpl-${(0, crypto_1.randomUUID)()}`,
170
- object: 'chat.completion',
171
- created: Math.floor(Date.now() / 1000),
172
- model,
173
- choices: [],
174
- };
175
- }
176
- const content = candidate.content;
177
- const parts = content?.parts || [];
178
- let textContent = '';
179
- const toolCalls = [];
180
- for (const part of parts) {
181
- if (part.text)
182
- textContent += part.text;
183
- if (part.functionCall) {
184
- const fc = part.functionCall;
185
- const toolCall = {
186
- id: `call_${(0, crypto_1.randomUUID)()}`,
187
- type: 'function',
188
- function: { name: fc.name, arguments: JSON.stringify(fc.args) },
189
- };
190
- if (fc.thought_signature)
191
- toolCall.thought_signature = fc.thought_signature;
192
- toolCalls.push(toolCall);
193
- }
194
- }
195
- const message = { role: 'assistant', content: textContent || null };
196
- if (toolCalls.length > 0)
197
- message.tool_calls = toolCalls;
198
- const extractedSignatures = [];
199
- for (const tc of toolCalls) {
200
- if (tc.thought_signature && typeof tc.id === 'string') {
201
- extractedSignatures.push({
202
- toolCallId: tc.id,
203
- signature: tc.thought_signature,
204
- });
205
- }
206
- }
207
- const usage = googleResp.usageMetadata;
208
- return {
209
- id: `chatcmpl-${(0, crypto_1.randomUUID)()}`,
210
- object: 'chat.completion',
211
- created: Math.floor(Date.now() / 1000),
212
- model,
213
- choices: [
214
- { index: 0, message, finish_reason: mapFinishReason(candidate, toolCalls.length > 0) },
215
- ],
216
- usage: usage
217
- ? {
218
- prompt_tokens: usage.promptTokenCount ?? 0,
219
- completion_tokens: usage.candidatesTokenCount ?? 0,
220
- total_tokens: usage.totalTokenCount ?? 0,
221
- prompt_tokens_details: { cached_tokens: usage.cachedContentTokenCount ?? 0 },
222
- cache_read_tokens: usage.cachedContentTokenCount ?? 0,
223
- cache_creation_tokens: 0,
224
- }
225
- : undefined,
226
- ...(extractedSignatures.length > 0 ? { _extractedSignatures: extractedSignatures } : {}),
227
- };
228
- }
229
- function mapFinishReason(candidate, hasToolCalls = false) {
230
- const reason = candidate.finishReason;
231
- if (!reason || reason === 'STOP') {
232
- return hasToolCalls ? 'tool_calls' : 'stop';
233
- }
234
- const map = {
235
- MAX_TOKENS: 'length',
236
- SAFETY: 'content_filter',
237
- RECITATION: 'content_filter',
238
- };
239
- return map[reason] ?? 'stop';
240
- }
241
- function transformGoogleStreamChunk(chunk, model) {
242
- if (!chunk.trim())
243
- return null;
244
- let data;
245
- try {
246
- data = JSON.parse(chunk);
247
- }
248
- catch {
249
- return null;
250
- }
251
- const candidates = data.candidates || [];
252
- const candidate = candidates[0];
253
- const content = candidate?.content;
254
- const parts = content?.parts || [];
255
- const text = parts.map((p) => p.text || '').join('');
256
- const toolCalls = [];
257
- for (const part of parts) {
258
- if (part.functionCall) {
259
- const fc = part.functionCall;
260
- const toolCall = {
261
- index: toolCalls.length,
262
- id: `call_${(0, crypto_1.randomUUID)()}`,
263
- type: 'function',
264
- function: { name: fc.name, arguments: JSON.stringify(fc.args ?? {}) },
265
- };
266
- if (fc.thought_signature)
267
- toolCall.thought_signature = fc.thought_signature;
268
- toolCalls.push(toolCall);
269
- }
270
- }
271
- let result = '';
272
- if (text || toolCalls.length > 0) {
273
- const delta = {};
274
- if (text)
275
- delta.content = text;
276
- if (toolCalls.length > 0)
277
- delta.tool_calls = toolCalls;
278
- result += `data: ${JSON.stringify({
279
- id: `chatcmpl-${(0, crypto_1.randomUUID)()}`,
280
- object: 'chat.completion.chunk',
281
- created: Math.floor(Date.now() / 1000),
282
- model,
283
- choices: [{ index: 0, delta, finish_reason: null }],
284
- })}\n\n`;
285
- }
286
- const usage = data.usageMetadata;
287
- if (usage) {
288
- const finishReason = mapFinishReason(candidate ?? {}, toolCalls.length > 0);
289
- result += `data: ${JSON.stringify({
290
- id: `chatcmpl-${(0, crypto_1.randomUUID)()}`,
291
- object: 'chat.completion.chunk',
292
- created: Math.floor(Date.now() / 1000),
293
- model,
294
- choices: [{ index: 0, delta: {}, finish_reason: finishReason }],
295
- })}\n\n`;
296
- result += `data: ${JSON.stringify({
297
- id: `chatcmpl-${(0, crypto_1.randomUUID)()}`,
298
- object: 'chat.completion.chunk',
299
- created: Math.floor(Date.now() / 1000),
300
- model,
301
- choices: [],
302
- usage: {
303
- prompt_tokens: usage.promptTokenCount ?? 0,
304
- completion_tokens: usage.candidatesTokenCount ?? 0,
305
- total_tokens: usage.totalTokenCount ?? 0,
306
- prompt_tokens_details: { cached_tokens: usage.cachedContentTokenCount ?? 0 },
307
- cache_read_tokens: usage.cachedContentTokenCount ?? 0,
308
- cache_creation_tokens: 0,
309
- },
310
- })}\n\n`;
311
- }
312
- return result || null;
313
- }
314
- //# sourceMappingURL=google-adapter.js.map
@@ -1,190 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.collectChatGptSseResponse = exports.toResponsesRequest = exports.toAnthropicRequest = exports.toGoogleRequest = void 0;
4
- exports.convertChatGptResponse = convertChatGptResponse;
5
- exports.convertChatGptStreamChunk = convertChatGptStreamChunk;
6
- exports.convertGoogleResponse = convertGoogleResponse;
7
- exports.convertGoogleStreamChunk = convertGoogleStreamChunk;
8
- exports.convertAnthropicResponse = convertAnthropicResponse;
9
- exports.convertAnthropicStreamChunk = convertAnthropicStreamChunk;
10
- exports.createAnthropicTransformer = createAnthropicTransformer;
11
- exports.sanitizeOpenAiBody = sanitizeOpenAiBody;
12
- const google_adapter_1 = require("./google-adapter");
13
- Object.defineProperty(exports, "toGoogleRequest", { enumerable: true, get: function () { return google_adapter_1.toGoogleRequest; } });
14
- const anthropic_adapter_1 = require("./anthropic-adapter");
15
- Object.defineProperty(exports, "toAnthropicRequest", { enumerable: true, get: function () { return anthropic_adapter_1.toAnthropicRequest; } });
16
- const chatgpt_adapter_1 = require("./chatgpt-adapter");
17
- Object.defineProperty(exports, "toResponsesRequest", { enumerable: true, get: function () { return chatgpt_adapter_1.toResponsesRequest; } });
18
- Object.defineProperty(exports, "collectChatGptSseResponse", { enumerable: true, get: function () { return chatgpt_adapter_1.collectChatGptSseResponse; } });
19
- function convertChatGptResponse(body, model) {
20
- return (0, chatgpt_adapter_1.fromResponsesResponse)(body, model);
21
- }
22
- function convertChatGptStreamChunk(chunk, model) {
23
- return (0, chatgpt_adapter_1.transformResponsesStreamChunk)(chunk, model);
24
- }
25
- function convertGoogleResponse(googleBody, model) {
26
- return (0, google_adapter_1.fromGoogleResponse)(googleBody, model);
27
- }
28
- function convertGoogleStreamChunk(chunk, model) {
29
- return (0, google_adapter_1.transformGoogleStreamChunk)(chunk, model);
30
- }
31
- function convertAnthropicResponse(anthropicBody, model) {
32
- return (0, anthropic_adapter_1.fromAnthropicResponse)(anthropicBody, model);
33
- }
34
- function convertAnthropicStreamChunk(chunk, model) {
35
- return (0, anthropic_adapter_1.transformAnthropicStreamChunk)(chunk, model);
36
- }
37
- function createAnthropicTransformer(model) {
38
- return (0, anthropic_adapter_1.createAnthropicStreamTransformer)(model);
39
- }
40
- const OPENAI_ONLY_FIELDS = new Set([
41
- 'store',
42
- 'metadata',
43
- 'service_tier',
44
- 'stream_options',
45
- 'modalities',
46
- 'audio',
47
- 'prediction',
48
- 'reasoning_effort',
49
- ]);
50
- const PASSTHROUGH_PROVIDERS = new Set(['openai', 'openrouter']);
51
- const MISTRAL_TOOL_CALL_ID_REGEX = /^[A-Za-z0-9]{9}$/;
52
- const DEEPSEEK_MAX_TOKENS_LIMIT = 8192;
53
- const OPENAI_MAX_COMPLETION_TOKENS_RE = /^(o\d|gpt-5)/i;
54
- function supportsReasoningContent(endpointKey, model) {
55
- if (endpointKey === 'deepseek')
56
- return true;
57
- if (endpointKey === 'openrouter')
58
- return model.toLowerCase().startsWith('deepseek/');
59
- return false;
60
- }
61
- function sanitizeOpenAiMessages(messages, endpointKey, model) {
62
- if (!Array.isArray(messages))
63
- return messages;
64
- const preserveReasoningContent = supportsReasoningContent(endpointKey, model);
65
- const isMistral = endpointKey === 'mistral';
66
- const mistralIdMap = new Map();
67
- const reservedMistralIds = new Set();
68
- let generatedMistralIdCounter = 0;
69
- const reserveMistralToolCallId = (toolCallId) => {
70
- if (!isMistral || typeof toolCallId !== 'string')
71
- return;
72
- if (MISTRAL_TOOL_CALL_ID_REGEX.test(toolCallId)) {
73
- reservedMistralIds.add(toolCallId);
74
- }
75
- };
76
- if (isMistral) {
77
- for (const message of messages) {
78
- if (!message || typeof message !== 'object' || Array.isArray(message)) {
79
- continue;
80
- }
81
- const rawMessage = message;
82
- if (Array.isArray(rawMessage.tool_calls)) {
83
- for (const toolCall of rawMessage.tool_calls) {
84
- if (!toolCall || typeof toolCall !== 'object' || Array.isArray(toolCall)) {
85
- continue;
86
- }
87
- reserveMistralToolCallId(toolCall.id);
88
- }
89
- }
90
- if ('tool_call_id' in rawMessage) {
91
- reserveMistralToolCallId(rawMessage.tool_call_id);
92
- }
93
- }
94
- }
95
- const nextGeneratedMistralId = () => {
96
- do {
97
- generatedMistralIdCounter += 1;
98
- const candidate = `tc${generatedMistralIdCounter.toString(36).padStart(7, '0')}`;
99
- if (!reservedMistralIds.has(candidate))
100
- return candidate;
101
- } while (true);
102
- };
103
- const normalizeMistralToolCallId = (toolCallId) => {
104
- if (!isMistral || typeof toolCallId !== 'string')
105
- return toolCallId;
106
- const existing = mistralIdMap.get(toolCallId);
107
- if (existing)
108
- return existing;
109
- if (MISTRAL_TOOL_CALL_ID_REGEX.test(toolCallId)) {
110
- mistralIdMap.set(toolCallId, toolCallId);
111
- reservedMistralIds.add(toolCallId);
112
- return toolCallId;
113
- }
114
- const rewritten = nextGeneratedMistralId();
115
- mistralIdMap.set(toolCallId, rewritten);
116
- reservedMistralIds.add(rewritten);
117
- return rewritten;
118
- };
119
- return messages.map((message) => {
120
- if (!message || typeof message !== 'object' || Array.isArray(message)) {
121
- return message;
122
- }
123
- const cleaned = { ...message };
124
- if (!preserveReasoningContent) {
125
- delete cleaned.reasoning_content;
126
- }
127
- if (isMistral && Array.isArray(cleaned.tool_calls)) {
128
- cleaned.tool_calls = cleaned.tool_calls.map((toolCall) => {
129
- if (!toolCall || typeof toolCall !== 'object' || Array.isArray(toolCall)) {
130
- return toolCall;
131
- }
132
- const cleanedToolCall = { ...toolCall };
133
- cleanedToolCall.id = normalizeMistralToolCallId(cleanedToolCall.id);
134
- return cleanedToolCall;
135
- });
136
- }
137
- if (isMistral && 'tool_call_id' in cleaned) {
138
- cleaned.tool_call_id = normalizeMistralToolCallId(cleaned.tool_call_id);
139
- }
140
- return cleaned;
141
- });
142
- }
143
- function normalizeDeepSeekMaxTokens(body) {
144
- if (!('max_tokens' in body))
145
- return;
146
- const raw = body.max_tokens;
147
- const parsed = typeof raw === 'number' ? raw : typeof raw === 'string' ? Number(raw) : Number.NaN;
148
- if (!Number.isFinite(parsed) || parsed <= 0) {
149
- delete body.max_tokens;
150
- return;
151
- }
152
- body.max_tokens = Math.min(Math.trunc(parsed), DEEPSEEK_MAX_TOKENS_LIMIT);
153
- if (body.max_tokens < 1)
154
- delete body.max_tokens;
155
- }
156
- function sanitizeOpenAiBody(body, endpointKey, model) {
157
- const passthroughTopLevel = PASSTHROUGH_PROVIDERS.has(endpointKey);
158
- const bareForRegex = model.includes('/') ? model.substring(model.indexOf('/') + 1) : model;
159
- const convertMaxTokens = endpointKey === 'openai' &&
160
- OPENAI_MAX_COMPLETION_TOKENS_RE.test(bareForRegex) &&
161
- 'max_tokens' in body &&
162
- !('max_completion_tokens' in body);
163
- const cleaned = {};
164
- for (const [key, value] of Object.entries(body)) {
165
- if (key === 'messages') {
166
- cleaned[key] = sanitizeOpenAiMessages(value, endpointKey, model);
167
- continue;
168
- }
169
- if (passthroughTopLevel) {
170
- if (convertMaxTokens && key === 'max_tokens') {
171
- cleaned['max_completion_tokens'] = value;
172
- continue;
173
- }
174
- cleaned[key] = value;
175
- continue;
176
- }
177
- if (OPENAI_ONLY_FIELDS.has(key))
178
- continue;
179
- if (key === 'max_completion_tokens') {
180
- if (!('max_tokens' in body))
181
- cleaned['max_tokens'] = value;
182
- continue;
183
- }
184
- cleaned[key] = value;
185
- }
186
- if (endpointKey === 'deepseek')
187
- normalizeDeepSeekMaxTokens(cleaned);
188
- return cleaned;
189
- }
190
- //# sourceMappingURL=provider-client-converters.js.map