@oneuptime/common 11.3.25 → 11.3.26
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/Models/DatabaseModels/AIConversation.ts +322 -0
- package/Models/DatabaseModels/AIConversationMessage.ts +495 -0
- package/Models/DatabaseModels/AIRun.ts +584 -0
- package/Models/DatabaseModels/AIRunEvent.ts +443 -0
- package/Models/DatabaseModels/Index.ts +8 -0
- package/Models/DatabaseModels/LlmLog.ts +26 -0
- package/Models/DatabaseModels/LlmProvider.ts +2 -2
- package/Server/API/AIChatAPI.ts +693 -0
- package/Server/API/LlmProviderAPI.ts +169 -0
- package/Server/API/MicrosoftTeamsAPI.ts +5 -0
- package/Server/API/SlackAPI.ts +663 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783363279075-AddAIChatModels.ts +245 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783443471795-AddLlmProviderToAIConversation.ts +36 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783453297388-AddAIChatWriteActionsAndWidgets.ts +46 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1783461767405-MigrationName.ts +119 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
- package/Server/Services/AIConversationMessageService.ts +39 -0
- package/Server/Services/AIConversationService.ts +63 -0
- package/Server/Services/AIRunEventService.ts +39 -0
- package/Server/Services/AIRunService.ts +39 -0
- package/Server/Services/AIService.ts +53 -31
- package/Server/Services/DatabaseService.ts +19 -0
- package/Server/Services/LlmProviderService.ts +110 -0
- package/Server/Services/ProjectService.ts +24 -0
- package/Server/Types/AnalyticsDatabase/ModelPermission.ts +74 -9
- package/Server/Utils/AI/AIChatPrivacyFilter.ts +28 -0
- package/Server/Utils/AI/Chat/ChatAgentRunner.ts +1054 -0
- package/Server/Utils/AI/Chat/ObservabilityAssistant.ts +239 -0
- package/Server/Utils/AI/Chat/ObservabilityChatPrompt.ts +51 -0
- package/Server/Utils/AI/Toolbox/AlertTools.ts +201 -0
- package/Server/Utils/AI/Toolbox/AlertWriteTools.ts +174 -0
- package/Server/Utils/AI/Toolbox/ContextTools.ts +189 -0
- package/Server/Utils/AI/Toolbox/ExceptionTools.ts +149 -0
- package/Server/Utils/AI/Toolbox/IncidentTools.ts +204 -0
- package/Server/Utils/AI/Toolbox/IncidentWriteTools.ts +350 -0
- package/Server/Utils/AI/Toolbox/Index.ts +228 -0
- package/Server/Utils/AI/Toolbox/LogTools.ts +339 -0
- package/Server/Utils/AI/Toolbox/MetricTools.ts +179 -0
- package/Server/Utils/AI/Toolbox/MonitorTools.ts +193 -0
- package/Server/Utils/AI/Toolbox/Serializer.ts +257 -0
- package/Server/Utils/AI/Toolbox/ToolTypes.ts +249 -0
- package/Server/Utils/AI/Toolbox/TraceTools.ts +402 -0
- package/Server/Utils/AI/Toolbox/WidgetBuilder.ts +189 -0
- package/Server/Utils/LLM/LLMService.ts +502 -92
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +512 -19
- package/Server/Utils/Workspace/Slack/Slack.ts +80 -0
- package/Server/Utils/Workspace/Slack/app-manifest.json +16 -1
- package/Tests/Server/Utils/AI/AIChatModelACL.test.ts +42 -0
- package/Tests/Server/Utils/AI/ChatAgentHelpers.test.ts +89 -0
- package/Tests/Server/Utils/AI/LLMServiceBaseUrl.test.ts +139 -0
- package/Tests/Server/Utils/AI/LLMServiceToolCalling.test.ts +308 -0
- package/Tests/Server/Utils/AI/ToolArgsGetTimeRange.test.ts +62 -0
- package/Tests/Server/Utils/AI/ToolArgsScopeServiceIds.test.ts +79 -0
- package/Tests/Server/Utils/AI/ToolResultSerializer.test.ts +155 -0
- package/Tests/Types/Billing/SubscriptionStatus.test.ts +127 -0
- package/Tests/Types/Metrics/RecordingRuleDefinition.test.ts +213 -0
- package/Types/AI/AIChatMessageRole.ts +6 -0
- package/Types/AI/AIChatMessageStatus.ts +32 -0
- package/Types/AI/AIChatPermissionMode.ts +69 -0
- package/Types/AI/AIChatTypes.ts +231 -0
- package/Types/AI/AIRunEventType.ts +17 -0
- package/Types/AI/AIRunStatus.ts +28 -0
- package/Types/AI/AIRunType.ts +6 -0
- package/Types/LLM/LlmType.ts +6 -0
- package/UI/Components/Header/HeaderIconDropdownButton.tsx +22 -12
- package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +35 -3
- package/UI/Components/Page/Page.tsx +14 -0
- package/UI/Utils/LlmTypeDropdownOptions.ts +40 -0
- package/UI/Utils/TestLLMProvider.ts +59 -0
- package/build/dist/Models/DatabaseModels/AIConversation.js +345 -0
- package/build/dist/Models/DatabaseModels/AIConversation.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AIConversationMessage.js +521 -0
- package/build/dist/Models/DatabaseModels/AIConversationMessage.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AIRun.js +619 -0
- package/build/dist/Models/DatabaseModels/AIRun.js.map +1 -0
- package/build/dist/Models/DatabaseModels/AIRunEvent.js +469 -0
- package/build/dist/Models/DatabaseModels/AIRunEvent.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Index.js +8 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/LlmLog.js +28 -0
- package/build/dist/Models/DatabaseModels/LlmLog.js.map +1 -1
- package/build/dist/Models/DatabaseModels/LlmProvider.js +2 -2
- package/build/dist/Models/DatabaseModels/LlmProvider.js.map +1 -1
- package/build/dist/Server/API/AIChatAPI.js +498 -0
- package/build/dist/Server/API/AIChatAPI.js.map +1 -0
- package/build/dist/Server/API/LlmProviderAPI.js +107 -1
- package/build/dist/Server/API/LlmProviderAPI.js.map +1 -1
- package/build/dist/Server/API/MicrosoftTeamsAPI.js +4 -0
- package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -1
- package/build/dist/Server/API/SlackAPI.js +442 -0
- package/build/dist/Server/API/SlackAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783363279075-AddAIChatModels.js +96 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783363279075-AddAIChatModels.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783443471795-AddLlmProviderToAIConversation.js +25 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783443471795-AddLlmProviderToAIConversation.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783453297388-AddAIChatWriteActionsAndWidgets.js +31 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783453297388-AddAIChatWriteActionsAndWidgets.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783461767405-MigrationName.js +46 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1783461767405-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/AIConversationMessageService.js +34 -0
- package/build/dist/Server/Services/AIConversationMessageService.js.map +1 -0
- package/build/dist/Server/Services/AIConversationService.js +42 -0
- package/build/dist/Server/Services/AIConversationService.js.map +1 -0
- package/build/dist/Server/Services/AIRunEventService.js +34 -0
- package/build/dist/Server/Services/AIRunEventService.js.map +1 -0
- package/build/dist/Server/Services/AIRunService.js +34 -0
- package/build/dist/Server/Services/AIRunService.js.map +1 -0
- package/build/dist/Server/Services/AIService.js +31 -23
- package/build/dist/Server/Services/AIService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +10 -0
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/LlmProviderService.js +108 -0
- package/build/dist/Server/Services/LlmProviderService.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +25 -0
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js +50 -7
- package/build/dist/Server/Types/AnalyticsDatabase/ModelPermission.js.map +1 -1
- package/build/dist/Server/Utils/AI/AIChatPrivacyFilter.js +18 -0
- package/build/dist/Server/Utils/AI/AIChatPrivacyFilter.js.map +1 -0
- package/build/dist/Server/Utils/AI/Chat/ChatAgentRunner.js +745 -0
- package/build/dist/Server/Utils/AI/Chat/ChatAgentRunner.js.map +1 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityAssistant.js +165 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityAssistant.js.map +1 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityChatPrompt.js +44 -0
- package/build/dist/Server/Utils/AI/Chat/ObservabilityChatPrompt.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/AlertTools.js +167 -0
- package/build/dist/Server/Utils/AI/Toolbox/AlertTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/AlertWriteTools.js +136 -0
- package/build/dist/Server/Utils/AI/Toolbox/AlertWriteTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/ContextTools.js +141 -0
- package/build/dist/Server/Utils/AI/Toolbox/ContextTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/ExceptionTools.js +117 -0
- package/build/dist/Server/Utils/AI/Toolbox/ExceptionTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentTools.js +167 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentWriteTools.js +280 -0
- package/build/dist/Server/Utils/AI/Toolbox/IncidentWriteTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/Index.js +150 -0
- package/build/dist/Server/Utils/AI/Toolbox/Index.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/LogTools.js +246 -0
- package/build/dist/Server/Utils/AI/Toolbox/LogTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js +120 -0
- package/build/dist/Server/Utils/AI/Toolbox/MetricTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/MonitorTools.js +158 -0
- package/build/dist/Server/Utils/AI/Toolbox/MonitorTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/Serializer.js +188 -0
- package/build/dist/Server/Utils/AI/Toolbox/Serializer.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/ToolTypes.js +142 -0
- package/build/dist/Server/Utils/AI/Toolbox/ToolTypes.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/TraceTools.js +309 -0
- package/build/dist/Server/Utils/AI/Toolbox/TraceTools.js.map +1 -0
- package/build/dist/Server/Utils/AI/Toolbox/WidgetBuilder.js +120 -0
- package/build/dist/Server/Utils/AI/Toolbox/WidgetBuilder.js.map +1 -0
- package/build/dist/Server/Utils/LLM/LLMService.js +372 -88
- package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +378 -15
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js +59 -0
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/app-manifest.json +16 -1
- package/build/dist/Types/AI/AIChatMessageRole.js +7 -0
- package/build/dist/Types/AI/AIChatMessageRole.js.map +1 -0
- package/build/dist/Types/AI/AIChatMessageStatus.js +27 -0
- package/build/dist/Types/AI/AIChatMessageStatus.js.map +1 -0
- package/build/dist/Types/AI/AIChatPermissionMode.js +53 -0
- package/build/dist/Types/AI/AIChatPermissionMode.js.map +1 -0
- package/build/dist/Types/AI/AIChatTypes.js +74 -0
- package/build/dist/Types/AI/AIChatTypes.js.map +1 -0
- package/build/dist/Types/AI/AIRunEventType.js +18 -0
- package/build/dist/Types/AI/AIRunEventType.js.map +1 -0
- package/build/dist/Types/AI/AIRunStatus.js +26 -0
- package/build/dist/Types/AI/AIRunStatus.js.map +1 -0
- package/build/dist/Types/AI/AIRunType.js +7 -0
- package/build/dist/Types/AI/AIRunType.js.map +1 -0
- package/build/dist/Types/LLM/LlmType.js +6 -0
- package/build/dist/Types/LLM/LlmType.js.map +1 -1
- package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js +10 -5
- package/build/dist/UI/Components/Header/HeaderIconDropdownButton.js.map +1 -1
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +18 -4
- package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js.map +1 -1
- package/build/dist/UI/Components/Page/Page.js +3 -1
- package/build/dist/UI/Components/Page/Page.js.map +1 -1
- package/build/dist/UI/Utils/LlmTypeDropdownOptions.js +38 -0
- package/build/dist/UI/Utils/LlmTypeDropdownOptions.js.map +1 -0
- package/build/dist/UI/Utils/TestLLMProvider.js +37 -0
- package/build/dist/UI/Utils/TestLLMProvider.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import Project from "./Project";
|
|
2
|
+
import User from "./User";
|
|
3
|
+
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
|
|
4
|
+
import Route from "../../Types/API/Route";
|
|
5
|
+
import { PlanType } from "../../Types/Billing/SubscriptionPlan";
|
|
6
|
+
import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
|
|
7
|
+
import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
|
|
8
|
+
import TableBillingAccessControl from "../../Types/Database/AccessControl/TableBillingAccessControl";
|
|
9
|
+
import ColumnLength from "../../Types/Database/ColumnLength";
|
|
10
|
+
import ColumnType from "../../Types/Database/ColumnType";
|
|
11
|
+
import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
|
|
12
|
+
import TableColumn from "../../Types/Database/TableColumn";
|
|
13
|
+
import TableColumnType from "../../Types/Database/TableColumnType";
|
|
14
|
+
import TableMetadata from "../../Types/Database/TableMetadata";
|
|
15
|
+
import TenantColumn from "../../Types/Database/TenantColumn";
|
|
16
|
+
import IconProp from "../../Types/Icon/IconProp";
|
|
17
|
+
import ObjectID from "../../Types/ObjectID";
|
|
18
|
+
import Permission from "../../Types/Permission";
|
|
19
|
+
import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
|
|
20
|
+
import EnableDocumentation from "../../Types/Database/EnableDocumentation";
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* A conversation between a user and the OneUptime AI about the project's
|
|
24
|
+
* observability data. Conversations are personal: AIConversationService pins
|
|
25
|
+
* all non-root reads/updates/deletes to the creating user.
|
|
26
|
+
*/
|
|
27
|
+
@EnableDocumentation()
|
|
28
|
+
@TableBillingAccessControl({
|
|
29
|
+
create: PlanType.Growth,
|
|
30
|
+
read: PlanType.Free,
|
|
31
|
+
update: PlanType.Growth,
|
|
32
|
+
delete: PlanType.Free,
|
|
33
|
+
})
|
|
34
|
+
@TenantColumn("projectId")
|
|
35
|
+
@CrudApiEndpoint(new Route("/ai-conversation"))
|
|
36
|
+
@Entity({
|
|
37
|
+
name: "AIConversation",
|
|
38
|
+
})
|
|
39
|
+
@TableMetadata({
|
|
40
|
+
tableName: "AIConversation",
|
|
41
|
+
singularName: "AI Conversation",
|
|
42
|
+
pluralName: "AI Conversations",
|
|
43
|
+
icon: IconProp.ChatBubbleLeftRight,
|
|
44
|
+
tableDescription:
|
|
45
|
+
"A conversation with the OneUptime AI about observability data (logs, traces, metrics, exceptions, incidents, monitors and alerts).",
|
|
46
|
+
})
|
|
47
|
+
@TableAccessControl({
|
|
48
|
+
create: [
|
|
49
|
+
Permission.ProjectOwner,
|
|
50
|
+
Permission.ProjectAdmin,
|
|
51
|
+
Permission.ProjectMember,
|
|
52
|
+
],
|
|
53
|
+
read: [
|
|
54
|
+
Permission.ProjectOwner,
|
|
55
|
+
Permission.ProjectAdmin,
|
|
56
|
+
Permission.ProjectMember,
|
|
57
|
+
],
|
|
58
|
+
delete: [
|
|
59
|
+
Permission.ProjectOwner,
|
|
60
|
+
Permission.ProjectAdmin,
|
|
61
|
+
Permission.ProjectMember,
|
|
62
|
+
],
|
|
63
|
+
update: [],
|
|
64
|
+
})
|
|
65
|
+
export default class AIConversation extends BaseModel {
|
|
66
|
+
@ColumnAccessControl({
|
|
67
|
+
create: [
|
|
68
|
+
Permission.ProjectOwner,
|
|
69
|
+
Permission.ProjectAdmin,
|
|
70
|
+
Permission.ProjectMember,
|
|
71
|
+
],
|
|
72
|
+
read: [
|
|
73
|
+
Permission.ProjectOwner,
|
|
74
|
+
Permission.ProjectAdmin,
|
|
75
|
+
Permission.ProjectMember,
|
|
76
|
+
],
|
|
77
|
+
update: [],
|
|
78
|
+
})
|
|
79
|
+
@TableColumn({
|
|
80
|
+
type: TableColumnType.Entity,
|
|
81
|
+
required: true,
|
|
82
|
+
modelType: Project,
|
|
83
|
+
manyToOneRelationColumn: "projectId",
|
|
84
|
+
title: "Project",
|
|
85
|
+
description: "Project this conversation belongs to.",
|
|
86
|
+
})
|
|
87
|
+
@ManyToOne(
|
|
88
|
+
() => {
|
|
89
|
+
return Project;
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
cascade: false,
|
|
93
|
+
eager: false,
|
|
94
|
+
nullable: false,
|
|
95
|
+
onDelete: "CASCADE",
|
|
96
|
+
orphanedRowAction: "nullify",
|
|
97
|
+
},
|
|
98
|
+
)
|
|
99
|
+
@JoinColumn({ name: "projectId" })
|
|
100
|
+
public project?: Project = undefined;
|
|
101
|
+
|
|
102
|
+
@ColumnAccessControl({
|
|
103
|
+
create: [
|
|
104
|
+
Permission.ProjectOwner,
|
|
105
|
+
Permission.ProjectAdmin,
|
|
106
|
+
Permission.ProjectMember,
|
|
107
|
+
],
|
|
108
|
+
read: [
|
|
109
|
+
Permission.ProjectOwner,
|
|
110
|
+
Permission.ProjectAdmin,
|
|
111
|
+
Permission.ProjectMember,
|
|
112
|
+
],
|
|
113
|
+
update: [],
|
|
114
|
+
})
|
|
115
|
+
@Index()
|
|
116
|
+
@TableColumn({
|
|
117
|
+
type: TableColumnType.ObjectID,
|
|
118
|
+
required: true,
|
|
119
|
+
canReadOnRelationQuery: true,
|
|
120
|
+
title: "Project ID",
|
|
121
|
+
description: "ID of the project this conversation belongs to.",
|
|
122
|
+
})
|
|
123
|
+
@Column({
|
|
124
|
+
type: ColumnType.ObjectID,
|
|
125
|
+
nullable: false,
|
|
126
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
127
|
+
})
|
|
128
|
+
public projectId?: ObjectID = undefined;
|
|
129
|
+
|
|
130
|
+
@ColumnAccessControl({
|
|
131
|
+
create: [],
|
|
132
|
+
read: [
|
|
133
|
+
Permission.ProjectOwner,
|
|
134
|
+
Permission.ProjectAdmin,
|
|
135
|
+
Permission.ProjectMember,
|
|
136
|
+
],
|
|
137
|
+
update: [],
|
|
138
|
+
})
|
|
139
|
+
@TableColumn({
|
|
140
|
+
required: false,
|
|
141
|
+
type: TableColumnType.ShortText,
|
|
142
|
+
title: "Title",
|
|
143
|
+
description: "Title of the conversation. Generated from the first message.",
|
|
144
|
+
canReadOnRelationQuery: true,
|
|
145
|
+
})
|
|
146
|
+
@Column({
|
|
147
|
+
nullable: true,
|
|
148
|
+
type: ColumnType.ShortText,
|
|
149
|
+
length: ColumnLength.ShortText,
|
|
150
|
+
})
|
|
151
|
+
public title?: string = undefined;
|
|
152
|
+
|
|
153
|
+
@ColumnAccessControl({
|
|
154
|
+
create: [],
|
|
155
|
+
read: [
|
|
156
|
+
Permission.ProjectOwner,
|
|
157
|
+
Permission.ProjectAdmin,
|
|
158
|
+
Permission.ProjectMember,
|
|
159
|
+
],
|
|
160
|
+
update: [],
|
|
161
|
+
})
|
|
162
|
+
@TableColumn({
|
|
163
|
+
required: false,
|
|
164
|
+
type: TableColumnType.Date,
|
|
165
|
+
title: "Last Message At",
|
|
166
|
+
description: "When the last message in this conversation was sent.",
|
|
167
|
+
})
|
|
168
|
+
@Column({
|
|
169
|
+
nullable: true,
|
|
170
|
+
type: ColumnType.Date,
|
|
171
|
+
})
|
|
172
|
+
public lastMessageAt?: Date = undefined;
|
|
173
|
+
|
|
174
|
+
/*
|
|
175
|
+
* The LLM provider the user chose for this conversation. Stored as a plain
|
|
176
|
+
* ObjectID (no foreign key) so it can reference either a project-scoped
|
|
177
|
+
* provider or a cross-tenant global provider, and so deleting the provider
|
|
178
|
+
* gracefully falls back to the project default rather than cascading. Set
|
|
179
|
+
* server-side from the /ai-chat/send-message endpoint (never member-writable
|
|
180
|
+
* through CRUD), so the model can't be forged to point at another project's
|
|
181
|
+
* provider.
|
|
182
|
+
*/
|
|
183
|
+
@ColumnAccessControl({
|
|
184
|
+
create: [],
|
|
185
|
+
read: [
|
|
186
|
+
Permission.ProjectOwner,
|
|
187
|
+
Permission.ProjectAdmin,
|
|
188
|
+
Permission.ProjectMember,
|
|
189
|
+
],
|
|
190
|
+
update: [],
|
|
191
|
+
})
|
|
192
|
+
@Index()
|
|
193
|
+
@TableColumn({
|
|
194
|
+
required: false,
|
|
195
|
+
type: TableColumnType.ObjectID,
|
|
196
|
+
canReadOnRelationQuery: true,
|
|
197
|
+
title: "LLM Provider ID",
|
|
198
|
+
description:
|
|
199
|
+
"The LLM provider selected for this conversation. If empty, the project default (or global) provider is used.",
|
|
200
|
+
})
|
|
201
|
+
@Column({
|
|
202
|
+
type: ColumnType.ObjectID,
|
|
203
|
+
nullable: true,
|
|
204
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
205
|
+
})
|
|
206
|
+
public llmProviderId?: ObjectID = undefined;
|
|
207
|
+
|
|
208
|
+
/*
|
|
209
|
+
* How much autonomy the agent has to run mutating tools in this conversation
|
|
210
|
+
* (see AIChatPermissionMode: AskForApproval | AutoRun | ReadOnly). Set
|
|
211
|
+
* server-side from /ai-chat/send-message so a member can't forge a conversation
|
|
212
|
+
* into a wider permission mode than the endpoint would grant.
|
|
213
|
+
*/
|
|
214
|
+
@ColumnAccessControl({
|
|
215
|
+
create: [],
|
|
216
|
+
read: [
|
|
217
|
+
Permission.ProjectOwner,
|
|
218
|
+
Permission.ProjectAdmin,
|
|
219
|
+
Permission.ProjectMember,
|
|
220
|
+
],
|
|
221
|
+
update: [],
|
|
222
|
+
})
|
|
223
|
+
@TableColumn({
|
|
224
|
+
required: false,
|
|
225
|
+
type: TableColumnType.ShortText,
|
|
226
|
+
title: "Permission Mode",
|
|
227
|
+
description:
|
|
228
|
+
"How the agent is allowed to run mutating tools: AskForApproval, AutoRun or ReadOnly.",
|
|
229
|
+
canReadOnRelationQuery: true,
|
|
230
|
+
})
|
|
231
|
+
@Column({
|
|
232
|
+
nullable: true,
|
|
233
|
+
type: ColumnType.ShortText,
|
|
234
|
+
length: ColumnLength.ShortText,
|
|
235
|
+
})
|
|
236
|
+
public permissionMode?: string = undefined;
|
|
237
|
+
|
|
238
|
+
@ColumnAccessControl({
|
|
239
|
+
create: [],
|
|
240
|
+
read: [],
|
|
241
|
+
update: [],
|
|
242
|
+
})
|
|
243
|
+
@TableColumn({ type: TableColumnType.Entity, modelType: User })
|
|
244
|
+
@ManyToOne(
|
|
245
|
+
() => {
|
|
246
|
+
return User;
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
cascade: false,
|
|
250
|
+
eager: false,
|
|
251
|
+
nullable: true,
|
|
252
|
+
onDelete: "SET NULL",
|
|
253
|
+
orphanedRowAction: "nullify",
|
|
254
|
+
},
|
|
255
|
+
)
|
|
256
|
+
@JoinColumn({ name: "deletedByUserId" })
|
|
257
|
+
public deletedByUser?: User = undefined;
|
|
258
|
+
|
|
259
|
+
@ColumnAccessControl({
|
|
260
|
+
create: [],
|
|
261
|
+
read: [],
|
|
262
|
+
update: [],
|
|
263
|
+
})
|
|
264
|
+
@TableColumn({
|
|
265
|
+
type: TableColumnType.ObjectID,
|
|
266
|
+
title: "Deleted by User ID",
|
|
267
|
+
description:
|
|
268
|
+
"User ID who deleted this object (if this object was deleted by a User)",
|
|
269
|
+
})
|
|
270
|
+
@Column({
|
|
271
|
+
type: ColumnType.ObjectID,
|
|
272
|
+
nullable: true,
|
|
273
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
274
|
+
})
|
|
275
|
+
public deletedByUserId?: ObjectID = undefined;
|
|
276
|
+
|
|
277
|
+
@ColumnAccessControl({
|
|
278
|
+
create: [],
|
|
279
|
+
read: [
|
|
280
|
+
Permission.ProjectOwner,
|
|
281
|
+
Permission.ProjectAdmin,
|
|
282
|
+
Permission.ProjectMember,
|
|
283
|
+
],
|
|
284
|
+
update: [],
|
|
285
|
+
})
|
|
286
|
+
@TableColumn({ type: TableColumnType.Entity, modelType: User })
|
|
287
|
+
@ManyToOne(
|
|
288
|
+
() => {
|
|
289
|
+
return User;
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
eager: false,
|
|
293
|
+
nullable: true,
|
|
294
|
+
onDelete: "SET NULL",
|
|
295
|
+
orphanedRowAction: "nullify",
|
|
296
|
+
},
|
|
297
|
+
)
|
|
298
|
+
@JoinColumn({ name: "createdByUserId" })
|
|
299
|
+
public createdByUser?: User = undefined;
|
|
300
|
+
|
|
301
|
+
@ColumnAccessControl({
|
|
302
|
+
create: [],
|
|
303
|
+
read: [
|
|
304
|
+
Permission.ProjectOwner,
|
|
305
|
+
Permission.ProjectAdmin,
|
|
306
|
+
Permission.ProjectMember,
|
|
307
|
+
],
|
|
308
|
+
update: [],
|
|
309
|
+
})
|
|
310
|
+
@Index()
|
|
311
|
+
@TableColumn({
|
|
312
|
+
type: TableColumnType.ObjectID,
|
|
313
|
+
title: "Created by User ID",
|
|
314
|
+
description: "User ID who created this conversation.",
|
|
315
|
+
})
|
|
316
|
+
@Column({
|
|
317
|
+
type: ColumnType.ObjectID,
|
|
318
|
+
nullable: true,
|
|
319
|
+
transformer: ObjectID.getDatabaseTransformer(),
|
|
320
|
+
})
|
|
321
|
+
public createdByUserId?: ObjectID = undefined;
|
|
322
|
+
}
|