manifest 5.25.4 → 5.26.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/dist/backend/analytics/analytics.module.js +9 -1
- package/dist/backend/analytics/controllers/messages.controller.js +17 -2
- package/dist/backend/analytics/services/message-details.service.js +146 -0
- package/dist/backend/analytics/services/messages-query.service.js +1 -2
- package/dist/backend/analytics/services/timeseries-queries.service.js +2 -5
- package/dist/backend/auth/local-auth.guard.js +2 -2
- package/dist/backend/common/constants/providers.js +126 -0
- package/dist/backend/common/utils/local-ip.js +31 -0
- package/dist/backend/database/database-seeder.service.js +4 -31
- package/dist/backend/database/database.module.js +4 -7
- package/dist/backend/database/local-bootstrap.service.js +16 -55
- package/dist/backend/database/migrations/1773400000000-AddProviderModelCache.js +15 -0
- package/dist/backend/database/migrations/1773500000000-DropModelPricingTables.js +51 -0
- package/dist/backend/database/ollama-sync.service.js +34 -121
- package/dist/backend/database/pricing-sync.service.js +45 -306
- package/dist/backend/entities/user-provider.entity.js +10 -0
- package/dist/backend/main.js +2 -2
- package/dist/backend/model-prices/model-prices.controller.js +0 -22
- package/dist/backend/model-prices/model-prices.module.js +2 -22
- package/dist/backend/model-prices/model-prices.service.js +10 -31
- package/dist/backend/model-prices/model-pricing-cache.service.js +55 -34
- package/dist/backend/otlp/guards/otlp-auth.guard.js +5 -4
- package/dist/backend/otlp/services/trace-ingest.service.js +1 -1
- package/dist/backend/routing/custom-provider.service.js +2 -54
- package/dist/backend/routing/model-discovery/model-discovery.module.js +27 -0
- package/dist/backend/routing/model-discovery/model-discovery.service.js +264 -0
- package/dist/backend/routing/model-discovery/model-fetcher.js +3 -0
- package/dist/backend/routing/model-discovery/provider-model-fetcher.service.js +260 -0
- package/dist/backend/routing/provider-aliases.js +3 -27
- package/dist/backend/routing/proxy/anthropic-adapter.js +54 -11
- package/dist/backend/routing/proxy/fallback-status-codes.js +3 -2
- package/dist/backend/routing/proxy/google-adapter.js +27 -8
- package/dist/backend/routing/proxy/provider-endpoints.js +11 -5
- package/dist/backend/routing/proxy/proxy.controller.js +28 -46
- package/dist/backend/routing/proxy/proxy.service.js +18 -6
- package/dist/backend/routing/resolve.service.js +20 -18
- package/dist/backend/routing/routing.controller.js +35 -27
- package/dist/backend/routing/routing.module.js +2 -2
- package/dist/backend/routing/routing.service.js +22 -1
- package/dist/backend/routing/tier-auto-assign.service.js +16 -28
- package/dist/index.js +2 -2
- package/dist/local-mode.js +1 -1
- package/package.json +1 -1
- package/public/assets/{Account-DMc7dwPo.js → Account-DtR3Bovj.js} +1 -1
- package/public/assets/AuthBadge-CN6tvI2S.js +1 -0
- package/public/assets/Limits-DYEhhHov.js +1 -0
- package/public/assets/{Login-C7FjhLGA.js → Login-sV6eKBAf.js} +1 -1
- package/public/assets/MessageLog-BfdBjKNj.js +1 -0
- package/public/assets/ModelPrices-D9JiRM0x.js +1 -0
- package/public/assets/Overview-C5W2WzOa.js +1 -0
- package/public/assets/ProviderIcon-ZusUWlbr.js +1 -0
- package/public/assets/{Register-DTq8sO1P.js → Register-CK1-HR7-.js} +1 -1
- package/public/assets/{ResetPassword-BR7oSEUq.js → ResetPassword-BXCgyBPz.js} +1 -1
- package/public/assets/Routing-ByCp9o3v.js +3 -0
- package/public/assets/{Settings-C2R8p3er.js → Settings-Cs8Y-DYp.js} +1 -1
- package/public/assets/{SocialButtons-Ct35unUm.js → SocialButtons-B29ADQVX.js} +1 -1
- package/public/assets/index-BJbiHRsE.css +1 -0
- package/public/assets/index-BV7oRqov.js +2 -0
- package/public/assets/model-display-3wEhsKxc.js +1 -0
- package/public/assets/overview-cTUikYPe.js +1 -0
- package/public/index.html +2 -2
- package/dist/backend/database/pricing-history.service.js +0 -75
- package/dist/backend/database/seed-models.js +0 -254
- package/dist/backend/entities/model-pricing-history.entity.js +0 -62
- package/dist/backend/entities/model-pricing.entity.js +0 -71
- package/dist/backend/entities/unresolved-model.entity.js +0 -57
- package/dist/backend/model-prices/unresolved-model-tracker.service.js +0 -97
- package/public/assets/AuthBadge-CXkjgzF2.js +0 -1
- package/public/assets/InfoTooltip-Bno8U6nE.js +0 -1
- package/public/assets/Limits-g_jT_iws.js +0 -1
- package/public/assets/MessageLog-B00Gyfw4.js +0 -1
- package/public/assets/ModelPrices-DHxoFAJw.js +0 -1
- package/public/assets/Overview-C8EMzcig.js +0 -1
- package/public/assets/ProviderIcon-CsB_Gx2t.js +0 -1
- package/public/assets/Routing-NibaWO2c.js +0 -3
- package/public/assets/index-CsMphenL.js +0 -2
- package/public/assets/index-DKDt23c1.css +0 -1
- package/public/assets/overview-n00krspr.js +0 -1
|
@@ -12,10 +12,14 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
12
12
|
const agent_message_entity_1 = require("../entities/agent-message.entity");
|
|
13
13
|
const agent_entity_1 = require("../entities/agent.entity");
|
|
14
14
|
const tenant_entity_1 = require("../entities/tenant.entity");
|
|
15
|
+
const llm_call_entity_1 = require("../entities/llm-call.entity");
|
|
16
|
+
const tool_execution_entity_1 = require("../entities/tool-execution.entity");
|
|
17
|
+
const agent_log_entity_1 = require("../entities/agent-log.entity");
|
|
15
18
|
const otlp_module_1 = require("../otlp/otlp.module");
|
|
16
19
|
const aggregation_service_1 = require("./services/aggregation.service");
|
|
17
20
|
const timeseries_queries_service_1 = require("./services/timeseries-queries.service");
|
|
18
21
|
const messages_query_service_1 = require("./services/messages-query.service");
|
|
22
|
+
const message_details_service_1 = require("./services/message-details.service");
|
|
19
23
|
const agent_analytics_service_1 = require("./services/agent-analytics.service");
|
|
20
24
|
const overview_controller_1 = require("./controllers/overview.controller");
|
|
21
25
|
const tokens_controller_1 = require("./controllers/tokens.controller");
|
|
@@ -28,7 +32,10 @@ let AnalyticsModule = class AnalyticsModule {
|
|
|
28
32
|
exports.AnalyticsModule = AnalyticsModule;
|
|
29
33
|
exports.AnalyticsModule = AnalyticsModule = __decorate([
|
|
30
34
|
(0, common_1.Module)({
|
|
31
|
-
imports: [
|
|
35
|
+
imports: [
|
|
36
|
+
typeorm_1.TypeOrmModule.forFeature([agent_message_entity_1.AgentMessage, agent_entity_1.Agent, tenant_entity_1.Tenant, llm_call_entity_1.LlmCall, tool_execution_entity_1.ToolExecution, agent_log_entity_1.AgentLog]),
|
|
37
|
+
otlp_module_1.OtlpModule,
|
|
38
|
+
],
|
|
32
39
|
controllers: [
|
|
33
40
|
overview_controller_1.OverviewController,
|
|
34
41
|
tokens_controller_1.TokensController,
|
|
@@ -41,6 +48,7 @@ exports.AnalyticsModule = AnalyticsModule = __decorate([
|
|
|
41
48
|
aggregation_service_1.AggregationService,
|
|
42
49
|
timeseries_queries_service_1.TimeseriesQueriesService,
|
|
43
50
|
messages_query_service_1.MessagesQueryService,
|
|
51
|
+
message_details_service_1.MessageDetailsService,
|
|
44
52
|
agent_analytics_service_1.AgentAnalyticsService,
|
|
45
53
|
],
|
|
46
54
|
})
|
|
@@ -16,11 +16,14 @@ exports.MessagesController = void 0;
|
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const messages_query_dto_1 = require("../dto/messages-query.dto");
|
|
18
18
|
const messages_query_service_1 = require("../services/messages-query.service");
|
|
19
|
+
const message_details_service_1 = require("../services/message-details.service");
|
|
19
20
|
const current_user_decorator_1 = require("../../auth/current-user.decorator");
|
|
20
21
|
let MessagesController = class MessagesController {
|
|
21
22
|
messagesQuery;
|
|
22
|
-
|
|
23
|
+
messageDetails;
|
|
24
|
+
constructor(messagesQuery, messageDetails) {
|
|
23
25
|
this.messagesQuery = messagesQuery;
|
|
26
|
+
this.messageDetails = messageDetails;
|
|
24
27
|
}
|
|
25
28
|
async getMessages(query, user) {
|
|
26
29
|
return this.messagesQuery.getMessages({
|
|
@@ -35,6 +38,9 @@ let MessagesController = class MessagesController {
|
|
|
35
38
|
agent_name: query.agent_name,
|
|
36
39
|
});
|
|
37
40
|
}
|
|
41
|
+
async getMessageDetails(id, user) {
|
|
42
|
+
return this.messageDetails.getDetails(id, user.id);
|
|
43
|
+
}
|
|
38
44
|
};
|
|
39
45
|
exports.MessagesController = MessagesController;
|
|
40
46
|
__decorate([
|
|
@@ -45,8 +51,17 @@ __decorate([
|
|
|
45
51
|
__metadata("design:paramtypes", [messages_query_dto_1.MessagesQueryDto, Object]),
|
|
46
52
|
__metadata("design:returntype", Promise)
|
|
47
53
|
], MessagesController.prototype, "getMessages", null);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, common_1.Get)('messages/:id/details'),
|
|
56
|
+
__param(0, (0, common_1.Param)('id')),
|
|
57
|
+
__param(1, (0, current_user_decorator_1.CurrentUser)()),
|
|
58
|
+
__metadata("design:type", Function),
|
|
59
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
60
|
+
__metadata("design:returntype", Promise)
|
|
61
|
+
], MessagesController.prototype, "getMessageDetails", null);
|
|
48
62
|
exports.MessagesController = MessagesController = __decorate([
|
|
49
63
|
(0, common_1.Controller)('api/v1'),
|
|
50
|
-
__metadata("design:paramtypes", [messages_query_service_1.MessagesQueryService
|
|
64
|
+
__metadata("design:paramtypes", [messages_query_service_1.MessagesQueryService,
|
|
65
|
+
message_details_service_1.MessageDetailsService])
|
|
51
66
|
], MessagesController);
|
|
52
67
|
//# sourceMappingURL=messages.controller.js.map
|
|
@@ -0,0 +1,146 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MessageDetailsService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
19
|
+
const agent_message_entity_1 = require("../../entities/agent-message.entity");
|
|
20
|
+
const llm_call_entity_1 = require("../../entities/llm-call.entity");
|
|
21
|
+
const tool_execution_entity_1 = require("../../entities/tool-execution.entity");
|
|
22
|
+
const agent_log_entity_1 = require("../../entities/agent-log.entity");
|
|
23
|
+
const tenant_cache_service_1 = require("../../common/services/tenant-cache.service");
|
|
24
|
+
let MessageDetailsService = class MessageDetailsService {
|
|
25
|
+
messageRepo;
|
|
26
|
+
llmCallRepo;
|
|
27
|
+
toolRepo;
|
|
28
|
+
logRepo;
|
|
29
|
+
tenantCache;
|
|
30
|
+
constructor(messageRepo, llmCallRepo, toolRepo, logRepo, tenantCache) {
|
|
31
|
+
this.messageRepo = messageRepo;
|
|
32
|
+
this.llmCallRepo = llmCallRepo;
|
|
33
|
+
this.toolRepo = toolRepo;
|
|
34
|
+
this.logRepo = logRepo;
|
|
35
|
+
this.tenantCache = tenantCache;
|
|
36
|
+
}
|
|
37
|
+
async getDetails(messageId, userId) {
|
|
38
|
+
const tenantId = await this.tenantCache.resolve(userId);
|
|
39
|
+
const messageQb = this.messageRepo
|
|
40
|
+
.createQueryBuilder('m')
|
|
41
|
+
.where('m.id = :id', { id: messageId });
|
|
42
|
+
if (tenantId) {
|
|
43
|
+
messageQb.andWhere('m.tenant_id = :tenantId', { tenantId });
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
messageQb.andWhere('m.user_id = :userId', { userId });
|
|
47
|
+
}
|
|
48
|
+
const message = await messageQb.getOne();
|
|
49
|
+
if (!message)
|
|
50
|
+
throw new common_1.NotFoundException('Message not found');
|
|
51
|
+
const llmCallsQb = this.llmCallRepo
|
|
52
|
+
.createQueryBuilder('lc')
|
|
53
|
+
.where('lc.turn_id = :turnId', { turnId: messageId })
|
|
54
|
+
.orderBy('lc.call_index', 'ASC')
|
|
55
|
+
.addOrderBy('lc.timestamp', 'ASC');
|
|
56
|
+
const logsQb = message.trace_id
|
|
57
|
+
? this.logRepo
|
|
58
|
+
.createQueryBuilder('al')
|
|
59
|
+
.where('al.trace_id = :traceId', { traceId: message.trace_id })
|
|
60
|
+
.orderBy('al.timestamp', 'ASC')
|
|
61
|
+
: null;
|
|
62
|
+
const [llmCalls, agentLogs] = await Promise.all([
|
|
63
|
+
llmCallsQb.getMany(),
|
|
64
|
+
logsQb ? logsQb.getMany() : Promise.resolve([]),
|
|
65
|
+
]);
|
|
66
|
+
const llmCallIds = llmCalls.map((lc) => lc.id);
|
|
67
|
+
const toolExecutions = llmCallIds.length > 0
|
|
68
|
+
? await this.toolRepo
|
|
69
|
+
.createQueryBuilder('te')
|
|
70
|
+
.where('te.llm_call_id IN (:...ids)', { ids: llmCallIds })
|
|
71
|
+
.orderBy('te.llm_call_id', 'ASC')
|
|
72
|
+
.getMany()
|
|
73
|
+
: [];
|
|
74
|
+
return {
|
|
75
|
+
message: {
|
|
76
|
+
id: message.id,
|
|
77
|
+
timestamp: message.timestamp,
|
|
78
|
+
agent_name: message.agent_name,
|
|
79
|
+
model: message.model,
|
|
80
|
+
status: message.status,
|
|
81
|
+
error_message: message.error_message,
|
|
82
|
+
description: message.description,
|
|
83
|
+
service_type: message.service_type,
|
|
84
|
+
input_tokens: message.input_tokens,
|
|
85
|
+
output_tokens: message.output_tokens,
|
|
86
|
+
cache_read_tokens: message.cache_read_tokens,
|
|
87
|
+
cache_creation_tokens: message.cache_creation_tokens,
|
|
88
|
+
cost_usd: message.cost_usd,
|
|
89
|
+
duration_ms: message.duration_ms,
|
|
90
|
+
trace_id: message.trace_id,
|
|
91
|
+
routing_tier: message.routing_tier,
|
|
92
|
+
routing_reason: message.routing_reason,
|
|
93
|
+
auth_type: message.auth_type,
|
|
94
|
+
skill_name: message.skill_name,
|
|
95
|
+
fallback_from_model: message.fallback_from_model,
|
|
96
|
+
fallback_index: message.fallback_index,
|
|
97
|
+
session_key: message.session_key,
|
|
98
|
+
},
|
|
99
|
+
llm_calls: llmCalls.map((lc) => ({
|
|
100
|
+
id: lc.id,
|
|
101
|
+
call_index: lc.call_index,
|
|
102
|
+
request_model: lc.request_model,
|
|
103
|
+
response_model: lc.response_model,
|
|
104
|
+
gen_ai_system: lc.gen_ai_system,
|
|
105
|
+
input_tokens: lc.input_tokens,
|
|
106
|
+
output_tokens: lc.output_tokens,
|
|
107
|
+
cache_read_tokens: lc.cache_read_tokens,
|
|
108
|
+
cache_creation_tokens: lc.cache_creation_tokens,
|
|
109
|
+
duration_ms: lc.duration_ms,
|
|
110
|
+
ttft_ms: lc.ttft_ms,
|
|
111
|
+
temperature: lc.temperature,
|
|
112
|
+
max_output_tokens: lc.max_output_tokens,
|
|
113
|
+
timestamp: lc.timestamp,
|
|
114
|
+
})),
|
|
115
|
+
tool_executions: toolExecutions.map((te) => ({
|
|
116
|
+
id: te.id,
|
|
117
|
+
llm_call_id: te.llm_call_id,
|
|
118
|
+
tool_name: te.tool_name,
|
|
119
|
+
duration_ms: te.duration_ms,
|
|
120
|
+
status: te.status,
|
|
121
|
+
error_message: te.error_message,
|
|
122
|
+
})),
|
|
123
|
+
agent_logs: agentLogs.map((al) => ({
|
|
124
|
+
id: al.id,
|
|
125
|
+
severity: al.severity,
|
|
126
|
+
body: al.body,
|
|
127
|
+
timestamp: al.timestamp,
|
|
128
|
+
span_id: al.span_id,
|
|
129
|
+
})),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
exports.MessageDetailsService = MessageDetailsService;
|
|
134
|
+
exports.MessageDetailsService = MessageDetailsService = __decorate([
|
|
135
|
+
(0, common_1.Injectable)(),
|
|
136
|
+
__param(0, (0, typeorm_1.InjectRepository)(agent_message_entity_1.AgentMessage)),
|
|
137
|
+
__param(1, (0, typeorm_1.InjectRepository)(llm_call_entity_1.LlmCall)),
|
|
138
|
+
__param(2, (0, typeorm_1.InjectRepository)(tool_execution_entity_1.ToolExecution)),
|
|
139
|
+
__param(3, (0, typeorm_1.InjectRepository)(agent_log_entity_1.AgentLog)),
|
|
140
|
+
__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
141
|
+
typeorm_2.Repository,
|
|
142
|
+
typeorm_2.Repository,
|
|
143
|
+
typeorm_2.Repository,
|
|
144
|
+
tenant_cache_service_1.TenantCacheService])
|
|
145
|
+
], MessageDetailsService);
|
|
146
|
+
//# sourceMappingURL=message-details.service.js.map
|
|
@@ -68,12 +68,11 @@ let MessagesQueryService = class MessagesQueryService {
|
|
|
68
68
|
const costExpr = (0, sql_dialect_1.sqlCastFloat)((0, sql_dialect_1.sqlSanitizeCost)('at.cost_usd'), this.dialect);
|
|
69
69
|
const dataQb = baseQb
|
|
70
70
|
.clone()
|
|
71
|
-
.leftJoin('model_pricing', 'mp', 'at.model = mp.model_name')
|
|
72
71
|
.select('at.id', 'id')
|
|
73
72
|
.addSelect('at.timestamp', 'timestamp')
|
|
74
73
|
.addSelect('at.agent_name', 'agent_name')
|
|
75
74
|
.addSelect('at.model', 'model')
|
|
76
|
-
.addSelect(
|
|
75
|
+
.addSelect('at.model', 'display_name')
|
|
77
76
|
.addSelect('at.description', 'description')
|
|
78
77
|
.addSelect('at.service_type', 'service_type')
|
|
79
78
|
.addSelect('at.input_tokens', 'input_tokens')
|
|
@@ -202,12 +202,11 @@ let TimeseriesQueriesService = class TimeseriesQueriesService {
|
|
|
202
202
|
const costExpr = (0, sql_dialect_1.sqlCastFloat)((0, sql_dialect_1.sqlSanitizeCost)('at.cost_usd'), this.dialect);
|
|
203
203
|
const qb = this.turnRepo
|
|
204
204
|
.createQueryBuilder('at')
|
|
205
|
-
.leftJoin('model_pricing', 'mp', 'at.model = mp.model_name')
|
|
206
205
|
.select('at.id', 'id')
|
|
207
206
|
.addSelect('at.timestamp', 'timestamp')
|
|
208
207
|
.addSelect('at.agent_name', 'agent_name')
|
|
209
208
|
.addSelect('at.model', 'model')
|
|
210
|
-
.addSelect(
|
|
209
|
+
.addSelect('at.model', 'display_name')
|
|
211
210
|
.addSelect('at.input_tokens', 'input_tokens')
|
|
212
211
|
.addSelect('at.output_tokens', 'output_tokens')
|
|
213
212
|
.addSelect('at.status', 'status')
|
|
@@ -229,9 +228,8 @@ let TimeseriesQueriesService = class TimeseriesQueriesService {
|
|
|
229
228
|
const cutoff = (0, sql_dialect_1.computeCutoff)(interval);
|
|
230
229
|
const qb = this.turnRepo
|
|
231
230
|
.createQueryBuilder('at')
|
|
232
|
-
.leftJoin('model_pricing', 'mp', 'at.model = mp.model_name')
|
|
233
231
|
.select("COALESCE(at.model, 'unknown')", 'model')
|
|
234
|
-
.addSelect(
|
|
232
|
+
.addSelect('at.model', 'display_name')
|
|
235
233
|
.addSelect('SUM(at.input_tokens + at.output_tokens)', 'tokens')
|
|
236
234
|
.addSelect(`COALESCE(SUM(${(0, sql_dialect_1.sqlSanitizeCost)('at.cost_usd')}), 0)`, 'estimated_cost')
|
|
237
235
|
.addSelect('at.auth_type', 'auth_type')
|
|
@@ -242,7 +240,6 @@ let TimeseriesQueriesService = class TimeseriesQueriesService {
|
|
|
242
240
|
const rows = await qb
|
|
243
241
|
.groupBy('at.model')
|
|
244
242
|
.addGroupBy('at.auth_type')
|
|
245
|
-
.addGroupBy('mp.display_name')
|
|
246
243
|
.orderBy('tokens', 'DESC')
|
|
247
244
|
.getRawMany();
|
|
248
245
|
const totalTokens = rows.reduce((sum, r) => sum + Number(r['tokens'] ?? 0), 0);
|
|
@@ -14,7 +14,7 @@ const common_1 = require("@nestjs/common");
|
|
|
14
14
|
const core_1 = require("@nestjs/core");
|
|
15
15
|
const public_decorator_1 = require("../common/decorators/public.decorator");
|
|
16
16
|
const local_mode_constants_1 = require("../common/constants/local-mode.constants");
|
|
17
|
-
const
|
|
17
|
+
const local_ip_1 = require("../common/utils/local-ip");
|
|
18
18
|
let LocalAuthGuard = class LocalAuthGuard {
|
|
19
19
|
reflector;
|
|
20
20
|
constructor(reflector) {
|
|
@@ -31,7 +31,7 @@ let LocalAuthGuard = class LocalAuthGuard {
|
|
|
31
31
|
if (request.headers['x-api-key'])
|
|
32
32
|
return true;
|
|
33
33
|
const clientIp = request.ip ?? '';
|
|
34
|
-
if (
|
|
34
|
+
if ((0, local_ip_1.isAllowedLocalIp)(clientIp)) {
|
|
35
35
|
const configEmail = (0, local_mode_constants_1.readLocalNotificationEmail)();
|
|
36
36
|
request.user = {
|
|
37
37
|
id: local_mode_constants_1.LOCAL_USER_ID,
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALL_PROVIDER_IDS = exports.OPENROUTER_PREFIX_TO_PROVIDER = exports.PROVIDER_BY_ID_OR_ALIAS = exports.PROVIDER_BY_ID = exports.PROVIDER_REGISTRY = void 0;
|
|
4
|
+
exports.expandProviderNames = expandProviderNames;
|
|
5
|
+
exports.PROVIDER_REGISTRY = [
|
|
6
|
+
{
|
|
7
|
+
id: 'anthropic',
|
|
8
|
+
displayName: 'Anthropic',
|
|
9
|
+
aliases: [],
|
|
10
|
+
openRouterPrefixes: ['anthropic'],
|
|
11
|
+
requiresApiKey: true,
|
|
12
|
+
localOnly: false,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 'openai',
|
|
16
|
+
displayName: 'OpenAI',
|
|
17
|
+
aliases: [],
|
|
18
|
+
openRouterPrefixes: ['openai'],
|
|
19
|
+
requiresApiKey: true,
|
|
20
|
+
localOnly: false,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'gemini',
|
|
24
|
+
displayName: 'Google',
|
|
25
|
+
aliases: ['google'],
|
|
26
|
+
openRouterPrefixes: ['google'],
|
|
27
|
+
requiresApiKey: true,
|
|
28
|
+
localOnly: false,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: 'deepseek',
|
|
32
|
+
displayName: 'DeepSeek',
|
|
33
|
+
aliases: [],
|
|
34
|
+
openRouterPrefixes: ['deepseek'],
|
|
35
|
+
requiresApiKey: true,
|
|
36
|
+
localOnly: false,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'mistral',
|
|
40
|
+
displayName: 'Mistral',
|
|
41
|
+
aliases: [],
|
|
42
|
+
openRouterPrefixes: ['mistralai'],
|
|
43
|
+
requiresApiKey: true,
|
|
44
|
+
localOnly: false,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: 'moonshot',
|
|
48
|
+
displayName: 'Moonshot',
|
|
49
|
+
aliases: ['kimi'],
|
|
50
|
+
openRouterPrefixes: ['moonshotai'],
|
|
51
|
+
requiresApiKey: true,
|
|
52
|
+
localOnly: false,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'xai',
|
|
56
|
+
displayName: 'xAI',
|
|
57
|
+
aliases: [],
|
|
58
|
+
openRouterPrefixes: ['xai', 'x-ai'],
|
|
59
|
+
requiresApiKey: true,
|
|
60
|
+
localOnly: false,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 'minimax',
|
|
64
|
+
displayName: 'MiniMax',
|
|
65
|
+
aliases: [],
|
|
66
|
+
openRouterPrefixes: ['minimax'],
|
|
67
|
+
requiresApiKey: true,
|
|
68
|
+
localOnly: false,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'qwen',
|
|
72
|
+
displayName: 'Alibaba',
|
|
73
|
+
aliases: ['alibaba'],
|
|
74
|
+
openRouterPrefixes: ['qwen', 'alibaba'],
|
|
75
|
+
requiresApiKey: true,
|
|
76
|
+
localOnly: false,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: 'zai',
|
|
80
|
+
displayName: 'Z.ai',
|
|
81
|
+
aliases: ['z.ai'],
|
|
82
|
+
openRouterPrefixes: ['z-ai', 'zhipuai'],
|
|
83
|
+
requiresApiKey: true,
|
|
84
|
+
localOnly: false,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'openrouter',
|
|
88
|
+
displayName: 'OpenRouter',
|
|
89
|
+
aliases: [],
|
|
90
|
+
openRouterPrefixes: ['openrouter'],
|
|
91
|
+
requiresApiKey: true,
|
|
92
|
+
localOnly: false,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 'ollama',
|
|
96
|
+
displayName: 'Ollama',
|
|
97
|
+
aliases: [],
|
|
98
|
+
openRouterPrefixes: [],
|
|
99
|
+
requiresApiKey: false,
|
|
100
|
+
localOnly: true,
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
exports.PROVIDER_BY_ID = new Map(exports.PROVIDER_REGISTRY.map((p) => [p.id, p]));
|
|
104
|
+
exports.PROVIDER_BY_ID_OR_ALIAS = new Map(exports.PROVIDER_REGISTRY.flatMap((p) => [
|
|
105
|
+
[p.id, p],
|
|
106
|
+
...p.aliases.map((a) => [a, p]),
|
|
107
|
+
]));
|
|
108
|
+
exports.OPENROUTER_PREFIX_TO_PROVIDER = new Map(exports.PROVIDER_REGISTRY.flatMap((p) => p.openRouterPrefixes.map((prefix) => [prefix, p.displayName])));
|
|
109
|
+
exports.ALL_PROVIDER_IDS = new Set(exports.PROVIDER_REGISTRY.flatMap((p) => [p.id, ...p.aliases]));
|
|
110
|
+
function expandProviderNames(names) {
|
|
111
|
+
const expanded = new Set();
|
|
112
|
+
for (const name of names) {
|
|
113
|
+
const lower = name.toLowerCase();
|
|
114
|
+
expanded.add(lower);
|
|
115
|
+
if (lower.startsWith('custom:'))
|
|
116
|
+
continue;
|
|
117
|
+
const entry = exports.PROVIDER_BY_ID_OR_ALIAS.get(lower);
|
|
118
|
+
if (entry) {
|
|
119
|
+
expanded.add(entry.id);
|
|
120
|
+
for (const alias of entry.aliases)
|
|
121
|
+
expanded.add(alias);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return expanded;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=providers.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLoopbackIp = isLoopbackIp;
|
|
4
|
+
exports.isAllowedLocalIp = isAllowedLocalIp;
|
|
5
|
+
const FFMPEG_PREFIX = '::ffff:';
|
|
6
|
+
function isLoopbackIp(ip) {
|
|
7
|
+
return ip === '127.0.0.1' || ip === '::1' || ip === '::ffff:127.0.0.1';
|
|
8
|
+
}
|
|
9
|
+
function parseIpv4(ip) {
|
|
10
|
+
return ip.startsWith(FFMPEG_PREFIX) ? ip.slice(FFMPEG_PREFIX.length) : ip;
|
|
11
|
+
}
|
|
12
|
+
function isPrivateIpv4(ipv4) {
|
|
13
|
+
const parts = ipv4.split('.');
|
|
14
|
+
if (parts.length !== 4)
|
|
15
|
+
return false;
|
|
16
|
+
const [a, b] = parts.map(Number);
|
|
17
|
+
if (a === 10)
|
|
18
|
+
return true;
|
|
19
|
+
if (a === 172 && b >= 16 && b <= 31)
|
|
20
|
+
return true;
|
|
21
|
+
if (a === 192 && b === 168)
|
|
22
|
+
return true;
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
function isAllowedLocalIp(ip) {
|
|
26
|
+
if (isLoopbackIp(ip))
|
|
27
|
+
return true;
|
|
28
|
+
const ipv4 = parseIpv4(ip);
|
|
29
|
+
return isPrivateIpv4(ipv4);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=local-ip.js.map
|
|
@@ -23,13 +23,10 @@ const tenant_entity_1 = require("../entities/tenant.entity");
|
|
|
23
23
|
const agent_entity_1 = require("../entities/agent.entity");
|
|
24
24
|
const agent_api_key_entity_1 = require("../entities/agent-api-key.entity");
|
|
25
25
|
const api_key_entity_1 = require("../entities/api-key.entity");
|
|
26
|
-
const model_pricing_entity_1 = require("../entities/model-pricing.entity");
|
|
27
26
|
const security_event_entity_1 = require("../entities/security-event.entity");
|
|
28
27
|
const agent_message_entity_1 = require("../entities/agent-message.entity");
|
|
29
28
|
const hash_util_1 = require("../common/utils/hash.util");
|
|
30
|
-
const model_pricing_cache_service_1 = require("../model-prices/model-pricing-cache.service");
|
|
31
29
|
const seed_messages_1 = require("./seed-messages");
|
|
32
|
-
const seed_models_1 = require("./seed-models");
|
|
33
30
|
const SEED_API_KEY = 'dev-api-key-manifest-001';
|
|
34
31
|
const SEED_OTLP_KEY = 'mnfst_dev-otlp-key-001';
|
|
35
32
|
const SEED_TENANT_ID = 'seed-tenant-001';
|
|
@@ -41,28 +38,23 @@ let DatabaseSeederService = DatabaseSeederService_1 = class DatabaseSeederServic
|
|
|
41
38
|
agentRepo;
|
|
42
39
|
agentKeyRepo;
|
|
43
40
|
apiKeyRepo;
|
|
44
|
-
pricingRepo;
|
|
45
41
|
securityRepo;
|
|
46
42
|
messageRepo;
|
|
47
|
-
pricingCache;
|
|
48
43
|
logger = new common_1.Logger(DatabaseSeederService_1.name);
|
|
49
|
-
constructor(dataSource, configService, tenantRepo, agentRepo, agentKeyRepo, apiKeyRepo,
|
|
44
|
+
constructor(dataSource, configService, tenantRepo, agentRepo, agentKeyRepo, apiKeyRepo, securityRepo, messageRepo) {
|
|
50
45
|
this.dataSource = dataSource;
|
|
51
46
|
this.configService = configService;
|
|
52
47
|
this.tenantRepo = tenantRepo;
|
|
53
48
|
this.agentRepo = agentRepo;
|
|
54
49
|
this.agentKeyRepo = agentKeyRepo;
|
|
55
50
|
this.apiKeyRepo = apiKeyRepo;
|
|
56
|
-
this.pricingRepo = pricingRepo;
|
|
57
51
|
this.securityRepo = securityRepo;
|
|
58
52
|
this.messageRepo = messageRepo;
|
|
59
|
-
this.pricingCache = pricingCache;
|
|
60
53
|
}
|
|
61
54
|
async onModuleInit() {
|
|
62
55
|
if (process.env['MANIFEST_MODE'] === 'local')
|
|
63
56
|
return;
|
|
64
57
|
await this.runBetterAuthMigrations();
|
|
65
|
-
await this.seedModelPricing();
|
|
66
58
|
const env = this.configService.get('app.nodeEnv', 'production');
|
|
67
59
|
const shouldSeed = (env === 'development' || env === 'test') && process.env['SEED_DATA'] === 'true';
|
|
68
60
|
if (shouldSeed) {
|
|
@@ -164,22 +156,6 @@ let DatabaseSeederService = DatabaseSeederService_1 = class DatabaseSeederServic
|
|
|
164
156
|
});
|
|
165
157
|
this.logger.log(`Seeded tenant/agent with OTLP key: ${SEED_OTLP_KEY.substring(0, 8)}***`);
|
|
166
158
|
}
|
|
167
|
-
async seedModelPricing() {
|
|
168
|
-
for (const [name, provider, inputPrice, outputPrice, ctxWindow, reasoning, code, displayName,] of seed_models_1.SEED_MODELS) {
|
|
169
|
-
await this.pricingRepo.upsert({
|
|
170
|
-
model_name: name,
|
|
171
|
-
provider,
|
|
172
|
-
input_price_per_token: inputPrice,
|
|
173
|
-
output_price_per_token: outputPrice,
|
|
174
|
-
context_window: ctxWindow,
|
|
175
|
-
capability_reasoning: reasoning,
|
|
176
|
-
capability_code: code,
|
|
177
|
-
display_name: displayName,
|
|
178
|
-
}, ['model_name']);
|
|
179
|
-
}
|
|
180
|
-
await this.pricingCache.reload();
|
|
181
|
-
this.logger.log('Seeded model pricing data');
|
|
182
|
-
}
|
|
183
159
|
async seedSecurityEvents() {
|
|
184
160
|
const count = await this.securityRepo.count();
|
|
185
161
|
if (count > 0)
|
|
@@ -297,9 +273,8 @@ exports.DatabaseSeederService = DatabaseSeederService = DatabaseSeederService_1
|
|
|
297
273
|
__param(3, (0, typeorm_1.InjectRepository)(agent_entity_1.Agent)),
|
|
298
274
|
__param(4, (0, typeorm_1.InjectRepository)(agent_api_key_entity_1.AgentApiKey)),
|
|
299
275
|
__param(5, (0, typeorm_1.InjectRepository)(api_key_entity_1.ApiKey)),
|
|
300
|
-
__param(6, (0, typeorm_1.InjectRepository)(
|
|
301
|
-
__param(7, (0, typeorm_1.InjectRepository)(
|
|
302
|
-
__param(8, (0, typeorm_1.InjectRepository)(agent_message_entity_1.AgentMessage)),
|
|
276
|
+
__param(6, (0, typeorm_1.InjectRepository)(security_event_entity_1.SecurityEvent)),
|
|
277
|
+
__param(7, (0, typeorm_1.InjectRepository)(agent_message_entity_1.AgentMessage)),
|
|
303
278
|
__metadata("design:paramtypes", [typeorm_2.DataSource,
|
|
304
279
|
config_1.ConfigService,
|
|
305
280
|
typeorm_2.Repository,
|
|
@@ -307,8 +282,6 @@ exports.DatabaseSeederService = DatabaseSeederService = DatabaseSeederService_1
|
|
|
307
282
|
typeorm_2.Repository,
|
|
308
283
|
typeorm_2.Repository,
|
|
309
284
|
typeorm_2.Repository,
|
|
310
|
-
typeorm_2.Repository
|
|
311
|
-
typeorm_2.Repository,
|
|
312
|
-
model_pricing_cache_service_1.ModelPricingCacheService])
|
|
285
|
+
typeorm_2.Repository])
|
|
313
286
|
], DatabaseSeederService);
|
|
314
287
|
//# sourceMappingURL=database-seeder.service.js.map
|
|
@@ -15,9 +15,6 @@ const agent_message_entity_1 = require("../entities/agent-message.entity");
|
|
|
15
15
|
const llm_call_entity_1 = require("../entities/llm-call.entity");
|
|
16
16
|
const tool_execution_entity_1 = require("../entities/tool-execution.entity");
|
|
17
17
|
const security_event_entity_1 = require("../entities/security-event.entity");
|
|
18
|
-
const model_pricing_entity_1 = require("../entities/model-pricing.entity");
|
|
19
|
-
const model_pricing_history_entity_1 = require("../entities/model-pricing-history.entity");
|
|
20
|
-
const unresolved_model_entity_1 = require("../entities/unresolved-model.entity");
|
|
21
18
|
const token_usage_snapshot_entity_1 = require("../entities/token-usage-snapshot.entity");
|
|
22
19
|
const cost_snapshot_entity_1 = require("../entities/cost-snapshot.entity");
|
|
23
20
|
const agent_log_entity_1 = require("../entities/agent-log.entity");
|
|
@@ -66,14 +63,13 @@ const _1773100000000_AddOverrideAuthType_1 = require("./migrations/1773100000000
|
|
|
66
63
|
const _1773200000000_AddMessageAuthType_1 = require("./migrations/1773200000000-AddMessageAuthType");
|
|
67
64
|
const _1773202787708_AddModelsAgentIndex_1 = require("./migrations/1773202787708-AddModelsAgentIndex");
|
|
68
65
|
const _1773300000000_AddEmailProviderKeyPrefix_1 = require("./migrations/1773300000000-AddEmailProviderKeyPrefix");
|
|
66
|
+
const _1773400000000_AddProviderModelCache_1 = require("./migrations/1773400000000-AddProviderModelCache");
|
|
67
|
+
const _1773500000000_DropModelPricingTables_1 = require("./migrations/1773500000000-DropModelPricingTables");
|
|
69
68
|
const entities = [
|
|
70
69
|
agent_message_entity_1.AgentMessage,
|
|
71
70
|
llm_call_entity_1.LlmCall,
|
|
72
71
|
tool_execution_entity_1.ToolExecution,
|
|
73
72
|
security_event_entity_1.SecurityEvent,
|
|
74
|
-
model_pricing_entity_1.ModelPricing,
|
|
75
|
-
model_pricing_history_entity_1.ModelPricingHistory,
|
|
76
|
-
unresolved_model_entity_1.UnresolvedModel,
|
|
77
73
|
token_usage_snapshot_entity_1.TokenUsageSnapshot,
|
|
78
74
|
cost_snapshot_entity_1.CostSnapshot,
|
|
79
75
|
agent_log_entity_1.AgentLog,
|
|
@@ -121,6 +117,8 @@ const migrations = [
|
|
|
121
117
|
_1773200000000_AddMessageAuthType_1.AddMessageAuthType1773200000000,
|
|
122
118
|
_1773202787708_AddModelsAgentIndex_1.AddModelsAgentIndex1773202787708,
|
|
123
119
|
_1773300000000_AddEmailProviderKeyPrefix_1.AddEmailProviderKeyPrefix1773300000000,
|
|
120
|
+
_1773400000000_AddProviderModelCache_1.AddProviderModelCache1773400000000,
|
|
121
|
+
_1773500000000_DropModelPricingTables_1.DropModelPricingTables1773500000000,
|
|
124
122
|
];
|
|
125
123
|
const isLocalMode = process.env['MANIFEST_MODE'] === 'local';
|
|
126
124
|
function buildModeServices() {
|
|
@@ -171,7 +169,6 @@ exports.DatabaseModule = DatabaseModule = __decorate([
|
|
|
171
169
|
agent_api_key_entity_1.AgentApiKey,
|
|
172
170
|
agent_message_entity_1.AgentMessage,
|
|
173
171
|
api_key_entity_1.ApiKey,
|
|
174
|
-
model_pricing_entity_1.ModelPricing,
|
|
175
172
|
security_event_entity_1.SecurityEvent,
|
|
176
173
|
user_provider_entity_1.UserProvider,
|
|
177
174
|
tier_assignment_entity_1.TierAssignment,
|