@apart-tech/intelligence-core 1.17.3 → 1.19.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/auth/ability.d.ts +1 -1
- package/dist/auth/ability.d.ts.map +1 -1
- package/dist/auth/ability.js +19 -0
- package/dist/auth/ability.js.map +1 -1
- package/dist/auth/ability.test.js +58 -4
- package/dist/auth/ability.test.js.map +1 -1
- package/dist/db/tenant.d.ts.map +1 -1
- package/dist/db/tenant.js +10 -0
- package/dist/db/tenant.js.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/services/__tests__/agent-instruction-service.test.d.ts +2 -0
- package/dist/services/__tests__/agent-instruction-service.test.d.ts.map +1 -0
- package/dist/services/__tests__/agent-instruction-service.test.js +408 -0
- package/dist/services/__tests__/agent-instruction-service.test.js.map +1 -0
- package/dist/services/agent-instruction-service.d.ts +82 -0
- package/dist/services/agent-instruction-service.d.ts.map +1 -0
- package/dist/services/agent-instruction-service.js +249 -0
- package/dist/services/agent-instruction-service.js.map +1 -0
- package/dist/services/agent-run-service.d.ts +61 -0
- package/dist/services/agent-run-service.d.ts.map +1 -1
- package/dist/services/agent-run-service.js +72 -0
- package/dist/services/agent-run-service.js.map +1 -1
- package/dist/services/chat-context-service.d.ts +33 -0
- package/dist/services/chat-context-service.d.ts.map +1 -0
- package/dist/services/chat-context-service.js +110 -0
- package/dist/services/chat-context-service.js.map +1 -0
- package/dist/services/chat-service.d.ts +83 -0
- package/dist/services/chat-service.d.ts.map +1 -0
- package/dist/services/chat-service.js +103 -0
- package/dist/services/chat-service.js.map +1 -0
- package/dist/services/chat-usage-service.d.ts +36 -0
- package/dist/services/chat-usage-service.d.ts.map +1 -0
- package/dist/services/chat-usage-service.js +89 -0
- package/dist/services/chat-usage-service.js.map +1 -0
- package/dist/services/llm-router-service.d.ts +29 -0
- package/dist/services/llm-router-service.d.ts.map +1 -0
- package/dist/services/llm-router-service.js +70 -0
- package/dist/services/llm-router-service.js.map +1 -0
- package/dist/services/org-llm-provider-service.d.ts +47 -0
- package/dist/services/org-llm-provider-service.d.ts.map +1 -0
- package/dist/services/org-llm-provider-service.js +126 -0
- package/dist/services/org-llm-provider-service.js.map +1 -0
- package/package.json +1 -1
- package/prisma/schema.prisma +317 -162
package/prisma/schema.prisma
CHANGED
|
@@ -20,30 +20,36 @@ model Organization {
|
|
|
20
20
|
stripeSubscriptionId String? @map("stripe_subscription_id") @db.VarChar(255)
|
|
21
21
|
currentPeriodEnd DateTime? @map("current_period_end") @db.Timestamptz
|
|
22
22
|
|
|
23
|
-
nodes
|
|
24
|
-
edges
|
|
25
|
-
domains
|
|
26
|
-
apiKeys
|
|
27
|
-
workspaces
|
|
28
|
-
embeddingConfig
|
|
29
|
-
piiConfig
|
|
30
|
-
agentConfig
|
|
31
|
-
agentRuns
|
|
32
|
-
agentSchedules
|
|
33
|
-
memberships
|
|
34
|
-
invites
|
|
35
|
-
orgAgentTypes
|
|
36
|
-
orgMcpServers
|
|
37
|
-
usageRecords
|
|
38
|
-
quotaOverrides
|
|
39
|
-
onboardingPackages
|
|
40
|
-
billingEvents
|
|
41
|
-
searchMetrics
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
23
|
+
nodes Node[]
|
|
24
|
+
edges Edge[]
|
|
25
|
+
domains Domain[]
|
|
26
|
+
apiKeys ApiKey[]
|
|
27
|
+
workspaces Workspace[]
|
|
28
|
+
embeddingConfig OrgEmbeddingConfig?
|
|
29
|
+
piiConfig OrgPiiConfig?
|
|
30
|
+
agentConfig OrgAgentConfig?
|
|
31
|
+
agentRuns AgentRun[]
|
|
32
|
+
agentSchedules AgentSchedule[]
|
|
33
|
+
memberships Membership[]
|
|
34
|
+
invites Invite[]
|
|
35
|
+
orgAgentTypes OrgAgentType[]
|
|
36
|
+
orgMcpServers OrgMcpServer[]
|
|
37
|
+
usageRecords UsageRecord[]
|
|
38
|
+
quotaOverrides QuotaOverride[]
|
|
39
|
+
onboardingPackages OnboardingPackage[]
|
|
40
|
+
billingEvents BillingEvent[]
|
|
41
|
+
searchMetrics SearchMetric[]
|
|
42
|
+
agentInstructions AgentInstruction[]
|
|
43
|
+
tagDefinitions TagDefinition[]
|
|
44
|
+
nodeTags NodeTag[]
|
|
45
|
+
nodeChunks NodeChunk[]
|
|
46
|
+
piiQueryLogs PiiQueryLog[]
|
|
47
|
+
documents Document[]
|
|
48
|
+
llmProviders OrgLlmProvider[]
|
|
49
|
+
chatSessions ChatSession[]
|
|
50
|
+
chatMessages ChatMessage[]
|
|
51
|
+
chatGuidelines OrgChatGuideline[]
|
|
52
|
+
priorityDocuments OrgPriorityDocument[]
|
|
47
53
|
|
|
48
54
|
@@map("organizations")
|
|
49
55
|
}
|
|
@@ -173,22 +179,22 @@ model Domain {
|
|
|
173
179
|
}
|
|
174
180
|
|
|
175
181
|
model Node {
|
|
176
|
-
id
|
|
177
|
-
type
|
|
178
|
-
title
|
|
179
|
-
content
|
|
180
|
-
embedding
|
|
181
|
-
searchVector
|
|
182
|
-
metadata
|
|
183
|
-
status
|
|
184
|
-
createdBy
|
|
185
|
-
createdAt
|
|
186
|
-
updatedAt
|
|
187
|
-
version
|
|
188
|
-
hasPii
|
|
189
|
-
embeddingPiiMode
|
|
190
|
-
domainId
|
|
191
|
-
organizationId
|
|
182
|
+
id String @id @default(uuid()) @db.Uuid
|
|
183
|
+
type String @db.VarChar(100)
|
|
184
|
+
title String @db.VarChar(500)
|
|
185
|
+
content String @default("") @db.Text
|
|
186
|
+
embedding Unsupported("vector")?
|
|
187
|
+
searchVector Unsupported("tsvector")? @map("search_vector")
|
|
188
|
+
metadata Json @default("{}")
|
|
189
|
+
status String @default("draft") @db.VarChar(20)
|
|
190
|
+
createdBy String @map("created_by") @db.VarChar(255)
|
|
191
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
192
|
+
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz
|
|
193
|
+
version Int @default(1)
|
|
194
|
+
hasPii Boolean @default(false) @map("has_pii")
|
|
195
|
+
embeddingPiiMode String? @map("embedding_pii_mode") @db.VarChar(20)
|
|
196
|
+
domainId String? @map("domain_id") @db.Uuid
|
|
197
|
+
organizationId String @map("organization_id") @db.Uuid
|
|
192
198
|
|
|
193
199
|
sourceEdges Edge[] @relation("SourceNode")
|
|
194
200
|
targetEdges Edge[] @relation("TargetNode")
|
|
@@ -207,19 +213,19 @@ model Node {
|
|
|
207
213
|
}
|
|
208
214
|
|
|
209
215
|
model NodeChunk {
|
|
210
|
-
id String
|
|
211
|
-
nodeId String
|
|
212
|
-
chunkIndex Int
|
|
213
|
-
content String
|
|
214
|
-
tokenCount Int
|
|
215
|
-
headingContext String?
|
|
216
|
-
startOffset Int
|
|
217
|
-
endOffset Int
|
|
218
|
-
overlapPrev Int
|
|
216
|
+
id String @id @default(uuid()) @db.Uuid
|
|
217
|
+
nodeId String @map("node_id") @db.Uuid
|
|
218
|
+
chunkIndex Int @map("chunk_index")
|
|
219
|
+
content String @db.Text
|
|
220
|
+
tokenCount Int @map("token_count")
|
|
221
|
+
headingContext String? @map("heading_context") @db.VarChar(500)
|
|
222
|
+
startOffset Int @map("start_offset")
|
|
223
|
+
endOffset Int @map("end_offset")
|
|
224
|
+
overlapPrev Int @default(0) @map("overlap_prev")
|
|
219
225
|
embedding Unsupported("vector")?
|
|
220
|
-
embeddingPiiMode String?
|
|
221
|
-
organizationId String
|
|
222
|
-
createdAt DateTime
|
|
226
|
+
embeddingPiiMode String? @map("embedding_pii_mode") @db.VarChar(20)
|
|
227
|
+
organizationId String @map("organization_id") @db.Uuid
|
|
228
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
223
229
|
|
|
224
230
|
node Node @relation(fields: [nodeId], references: [id], onDelete: Cascade)
|
|
225
231
|
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
@@ -326,11 +332,12 @@ model OrgAgentType {
|
|
|
326
332
|
secretEnvMapping Json @default("{}") @map("secret_env_mapping")
|
|
327
333
|
dynamicSecrets String[] @default([]) @map("dynamic_secrets")
|
|
328
334
|
|
|
329
|
-
organization Organization
|
|
330
|
-
createdByUser User?
|
|
331
|
-
agentRuns AgentRun[]
|
|
332
|
-
schedules AgentSchedule[]
|
|
333
|
-
apiKeys ApiKey[]
|
|
335
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
336
|
+
createdByUser User? @relation("OrgAgentTypeCreatedBy", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
|
337
|
+
agentRuns AgentRun[] @relation("AgentRunAgent")
|
|
338
|
+
schedules AgentSchedule[] @relation("AgentScheduleAgent")
|
|
339
|
+
apiKeys ApiKey[] @relation("ApiKeyAgent")
|
|
340
|
+
instructions AgentInstruction[] @relation("AgentTypeInstructions")
|
|
334
341
|
|
|
335
342
|
@@unique([organizationId, slug], map: "uq_org_agent_type_org_slug")
|
|
336
343
|
@@index([organizationId], map: "idx_org_agent_types_organization")
|
|
@@ -376,13 +383,21 @@ model AgentRun {
|
|
|
376
383
|
parentAgentRunId String? @map("parent_agent_run_id") @db.Uuid
|
|
377
384
|
actClaim Json? @map("act_claim")
|
|
378
385
|
capturedAbility Json? @map("captured_ability")
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
+
instructionId String? @map("instruction_id") @db.Uuid
|
|
387
|
+
reasoningTrace Json? @map("reasoning_trace")
|
|
388
|
+
toolsCalled Json? @map("tools_called")
|
|
389
|
+
outcome Json?
|
|
390
|
+
confidence Decimal? @db.Decimal
|
|
391
|
+
taskType String? @map("task_type") @db.VarChar(100)
|
|
392
|
+
outcomeStatus String? @map("outcome_status") @db.VarChar(30)
|
|
393
|
+
|
|
394
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
395
|
+
schedule AgentSchedule? @relation(fields: [scheduleId], references: [id], onDelete: SetNull)
|
|
396
|
+
agent OrgAgentType? @relation("AgentRunAgent", fields: [agentId], references: [id], onDelete: SetNull)
|
|
397
|
+
invokedByUser User? @relation("AgentRunInvokedBy", fields: [invokedByUserId], references: [id], onDelete: SetNull)
|
|
398
|
+
parent AgentRun? @relation("AgentRunParent", fields: [parentAgentRunId], references: [id], onDelete: SetNull)
|
|
399
|
+
children AgentRun[] @relation("AgentRunParent")
|
|
400
|
+
instruction AgentInstruction? @relation(fields: [instructionId], references: [id], onDelete: SetNull)
|
|
386
401
|
|
|
387
402
|
@@index([organizationId], map: "idx_agent_runs_organization")
|
|
388
403
|
@@index([status], map: "idx_agent_runs_status")
|
|
@@ -391,9 +406,46 @@ model AgentRun {
|
|
|
391
406
|
@@index([agentId], map: "idx_agent_runs_agent_id")
|
|
392
407
|
@@index([invokedByUserId], map: "idx_agent_runs_invoked_by_user_id")
|
|
393
408
|
@@index([parentAgentRunId], map: "idx_agent_runs_parent_agent_run_id")
|
|
409
|
+
@@index([instructionId], map: "idx_agent_runs_instruction")
|
|
410
|
+
@@index([taskType, status], map: "idx_agent_runs_task_type")
|
|
394
411
|
@@map("agent_runs")
|
|
395
412
|
}
|
|
396
413
|
|
|
414
|
+
model AgentInstruction {
|
|
415
|
+
id String @id @default(uuid()) @db.Uuid
|
|
416
|
+
organizationId String @map("organization_id") @db.Uuid
|
|
417
|
+
agentTypeId String? @map("agent_type_id") @db.Uuid
|
|
418
|
+
taskType String? @map("task_type") @db.VarChar(100)
|
|
419
|
+
version String @db.VarChar(20)
|
|
420
|
+
status String @default("draft") @db.VarChar(20)
|
|
421
|
+
systemPrompt String @default("") @map("system_prompt") @db.Text
|
|
422
|
+
tools Json @default("[]")
|
|
423
|
+
guardrails Json @default("{}")
|
|
424
|
+
modelConfig Json @default("{}") @map("model_config")
|
|
425
|
+
contentHash String? @map("content_hash") @db.VarChar(64)
|
|
426
|
+
parentVersionId String? @map("parent_version_id") @db.Uuid
|
|
427
|
+
changeNote String? @map("change_note") @db.Text
|
|
428
|
+
publishedAt DateTime? @map("published_at") @db.Timestamptz
|
|
429
|
+
deprecatedAt DateTime? @map("deprecated_at") @db.Timestamptz
|
|
430
|
+
effectiveFrom DateTime? @map("effective_from") @db.Timestamptz
|
|
431
|
+
effectiveTo DateTime? @map("effective_to") @db.Timestamptz
|
|
432
|
+
createdBy String @map("created_by") @db.VarChar(255)
|
|
433
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
434
|
+
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz
|
|
435
|
+
|
|
436
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
437
|
+
agentType OrgAgentType? @relation("AgentTypeInstructions", fields: [agentTypeId], references: [id], onDelete: SetNull)
|
|
438
|
+
parentVersion AgentInstruction? @relation("InstructionVersionChain", fields: [parentVersionId], references: [id], onDelete: SetNull)
|
|
439
|
+
childVersions AgentInstruction[] @relation("InstructionVersionChain")
|
|
440
|
+
agentRuns AgentRun[]
|
|
441
|
+
|
|
442
|
+
@@index([organizationId], map: "idx_agent_instructions_org")
|
|
443
|
+
@@index([agentTypeId], map: "idx_agent_instructions_agent_type")
|
|
444
|
+
@@index([organizationId, agentTypeId, taskType, status, publishedAt(sort: Desc)], map: "idx_agent_instructions_org_agent_status")
|
|
445
|
+
@@index([contentHash], map: "idx_agent_instructions_hash")
|
|
446
|
+
@@map("agent_instructions")
|
|
447
|
+
}
|
|
448
|
+
|
|
397
449
|
model AgentSchedule {
|
|
398
450
|
id String @id @default(uuid()) @db.Uuid
|
|
399
451
|
organizationId String @map("organization_id") @db.Uuid
|
|
@@ -494,32 +546,32 @@ model UsageRecord {
|
|
|
494
546
|
// ── Tag System ──────────────────────────────────────────────────────────────
|
|
495
547
|
|
|
496
548
|
model TagDefinition {
|
|
497
|
-
id
|
|
498
|
-
organizationId
|
|
499
|
-
tagName
|
|
500
|
-
tagType
|
|
501
|
-
cardinality
|
|
502
|
-
source
|
|
503
|
-
status
|
|
504
|
-
description
|
|
505
|
-
category
|
|
506
|
-
labels
|
|
507
|
-
applicableNodeTypes
|
|
508
|
-
requiredForNodeTypes Json
|
|
509
|
-
enumValues
|
|
510
|
-
enumVersion
|
|
511
|
-
dependsOn
|
|
512
|
-
autoAcceptThreshold
|
|
513
|
-
parentDefinitionId
|
|
514
|
-
replacedBy
|
|
515
|
-
deprecatedAt
|
|
516
|
-
createdAt
|
|
517
|
-
createdBy
|
|
518
|
-
|
|
519
|
-
organization Organization?
|
|
520
|
-
parentDef TagDefinition?
|
|
549
|
+
id String @id @default(uuid()) @db.Uuid
|
|
550
|
+
organizationId String? @map("organization_id") @db.Uuid
|
|
551
|
+
tagName String @map("tag_name") @db.VarChar(100)
|
|
552
|
+
tagType String @map("tag_type") @db.VarChar(20)
|
|
553
|
+
cardinality String @default("singleton") @db.VarChar(10)
|
|
554
|
+
source String @default("extracted") @db.VarChar(20)
|
|
555
|
+
status String @default("active") @map("status") @db.VarChar(20)
|
|
556
|
+
description String @default("") @db.Text
|
|
557
|
+
category String? @map("category") @db.VarChar(50)
|
|
558
|
+
labels Json? @map("labels") @db.JsonB
|
|
559
|
+
applicableNodeTypes Json @default("[]") @map("applicable_node_types")
|
|
560
|
+
requiredForNodeTypes Json @default("[]") @map("required_for_node_types")
|
|
561
|
+
enumValues Json? @map("enum_values")
|
|
562
|
+
enumVersion Int @default(1) @map("enum_version")
|
|
563
|
+
dependsOn Json @default("[]") @map("depends_on")
|
|
564
|
+
autoAcceptThreshold Float? @map("auto_accept_threshold") @db.Real
|
|
565
|
+
parentDefinitionId String? @map("parent_definition_id") @db.Uuid
|
|
566
|
+
replacedBy String? @map("replaced_by") @db.Uuid
|
|
567
|
+
deprecatedAt DateTime? @map("deprecated_at") @db.Timestamptz
|
|
568
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
569
|
+
createdBy String @map("created_by") @db.VarChar(255)
|
|
570
|
+
|
|
571
|
+
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
572
|
+
parentDef TagDefinition? @relation("TagDefHierarchy", fields: [parentDefinitionId], references: [id])
|
|
521
573
|
childDefs TagDefinition[] @relation("TagDefHierarchy")
|
|
522
|
-
replacementDef TagDefinition?
|
|
574
|
+
replacementDef TagDefinition? @relation("TagDefReplacement", fields: [replacedBy], references: [id])
|
|
523
575
|
replacedDefs TagDefinition[] @relation("TagDefReplacement")
|
|
524
576
|
tags NodeTag[]
|
|
525
577
|
|
|
@@ -530,25 +582,25 @@ model TagDefinition {
|
|
|
530
582
|
}
|
|
531
583
|
|
|
532
584
|
model NodeTag {
|
|
533
|
-
id
|
|
534
|
-
nodeId
|
|
535
|
-
organizationId
|
|
536
|
-
tagDefinitionId
|
|
537
|
-
tagName
|
|
538
|
-
isSingleton
|
|
539
|
-
|
|
540
|
-
valueText
|
|
541
|
-
valueNum
|
|
542
|
-
valueCurrency
|
|
543
|
-
valueUnit
|
|
544
|
-
valueDate
|
|
545
|
-
valueRef
|
|
546
|
-
|
|
547
|
-
textSpan
|
|
548
|
-
offsetStart
|
|
549
|
-
offsetEnd
|
|
550
|
-
contentVersion
|
|
551
|
-
attrs
|
|
585
|
+
id String @id @default(uuid()) @db.Uuid
|
|
586
|
+
nodeId String @map("node_id") @db.Uuid
|
|
587
|
+
organizationId String @map("organization_id") @db.Uuid
|
|
588
|
+
tagDefinitionId String @map("tag_definition_id") @db.Uuid
|
|
589
|
+
tagName String @map("tag_name") @db.VarChar(100)
|
|
590
|
+
isSingleton Boolean @default(false) @map("is_singleton")
|
|
591
|
+
|
|
592
|
+
valueText String? @map("value_text") @db.Text
|
|
593
|
+
valueNum Float? @map("value_num") @db.DoublePrecision
|
|
594
|
+
valueCurrency String? @map("value_currency") @db.Char(3)
|
|
595
|
+
valueUnit String? @map("value_unit") @db.VarChar(20)
|
|
596
|
+
valueDate DateTime? @map("value_date") @db.Timestamptz
|
|
597
|
+
valueRef String? @map("value_ref") @db.Uuid
|
|
598
|
+
|
|
599
|
+
textSpan String? @map("text_span") @db.Text
|
|
600
|
+
offsetStart Int? @map("offset_start")
|
|
601
|
+
offsetEnd Int? @map("offset_end")
|
|
602
|
+
contentVersion Int? @map("content_version")
|
|
603
|
+
attrs Json @default("{}") @db.JsonB
|
|
552
604
|
|
|
553
605
|
taggedBy String @map("tagged_by") @db.VarChar(255)
|
|
554
606
|
modelId String? @map("model_id") @db.VarChar(100)
|
|
@@ -560,14 +612,14 @@ model NodeTag {
|
|
|
560
612
|
supersededBy String? @map("superseded_by") @db.Uuid
|
|
561
613
|
batchId String? @map("batch_id") @db.Uuid
|
|
562
614
|
|
|
563
|
-
createdAt
|
|
564
|
-
updatedAt
|
|
615
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
616
|
+
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz
|
|
565
617
|
|
|
566
|
-
node
|
|
567
|
-
organization
|
|
568
|
-
tagDefinition
|
|
569
|
-
supersedes
|
|
570
|
-
supersededTags NodeTag[]
|
|
618
|
+
node Node @relation(fields: [nodeId], references: [id], onDelete: Cascade)
|
|
619
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
620
|
+
tagDefinition TagDefinition @relation(fields: [tagDefinitionId], references: [id])
|
|
621
|
+
supersedes NodeTag? @relation("TagSupersession", fields: [supersededBy], references: [id])
|
|
622
|
+
supersededTags NodeTag[] @relation("TagSupersession")
|
|
571
623
|
|
|
572
624
|
@@index([nodeId], map: "idx_node_tags_node")
|
|
573
625
|
@@index([organizationId, tagName], map: "idx_node_tags_org_name")
|
|
@@ -577,25 +629,25 @@ model NodeTag {
|
|
|
577
629
|
}
|
|
578
630
|
|
|
579
631
|
model NodeTagHistory {
|
|
580
|
-
id
|
|
581
|
-
tagId
|
|
582
|
-
nodeId
|
|
583
|
-
organizationId
|
|
584
|
-
tagName
|
|
585
|
-
|
|
586
|
-
valueText
|
|
587
|
-
valueNum
|
|
588
|
-
valueCurrency
|
|
589
|
-
valueUnit
|
|
590
|
-
valueDate
|
|
591
|
-
valueRef
|
|
592
|
-
|
|
593
|
-
validFrom
|
|
594
|
-
validUntil
|
|
595
|
-
systemFrom
|
|
596
|
-
systemTo
|
|
597
|
-
|
|
598
|
-
replacedBy
|
|
632
|
+
id String @id @default(uuid()) @db.Uuid
|
|
633
|
+
tagId String @map("tag_id") @db.Uuid
|
|
634
|
+
nodeId String @map("node_id") @db.Uuid
|
|
635
|
+
organizationId String @map("organization_id") @db.Uuid
|
|
636
|
+
tagName String @map("tag_name") @db.VarChar(100)
|
|
637
|
+
|
|
638
|
+
valueText String? @map("value_text") @db.Text
|
|
639
|
+
valueNum Float? @map("value_num") @db.DoublePrecision
|
|
640
|
+
valueCurrency String? @map("value_currency") @db.Char(3)
|
|
641
|
+
valueUnit String? @map("value_unit") @db.VarChar(20)
|
|
642
|
+
valueDate DateTime? @map("value_date") @db.Timestamptz
|
|
643
|
+
valueRef String? @map("value_ref") @db.Uuid
|
|
644
|
+
|
|
645
|
+
validFrom DateTime @map("valid_from") @db.Timestamptz
|
|
646
|
+
validUntil DateTime @map("valid_until") @db.Timestamptz
|
|
647
|
+
systemFrom DateTime @map("system_from") @db.Timestamptz
|
|
648
|
+
systemTo DateTime? @map("system_to") @db.Timestamptz
|
|
649
|
+
|
|
650
|
+
replacedBy String @map("replaced_by") @db.VarChar(255)
|
|
599
651
|
|
|
600
652
|
@@index([nodeId, tagName, validFrom], map: "idx_tag_history_node_name_time")
|
|
601
653
|
@@index([organizationId, tagName, validFrom], map: "idx_tag_history_org_name_time")
|
|
@@ -604,16 +656,16 @@ model NodeTagHistory {
|
|
|
604
656
|
}
|
|
605
657
|
|
|
606
658
|
model NodeTagAudit {
|
|
607
|
-
id
|
|
608
|
-
tagId
|
|
609
|
-
nodeId
|
|
610
|
-
orgId
|
|
611
|
-
action
|
|
612
|
-
oldValue
|
|
613
|
-
newValue
|
|
614
|
-
actorId
|
|
615
|
-
reason
|
|
616
|
-
createdAt
|
|
659
|
+
id String @id @default(uuid()) @db.Uuid
|
|
660
|
+
tagId String @map("tag_id") @db.Uuid
|
|
661
|
+
nodeId String @map("node_id") @db.Uuid
|
|
662
|
+
orgId String @map("organization_id") @db.Uuid
|
|
663
|
+
action String @map("action") @db.VarChar(20)
|
|
664
|
+
oldValue Json? @map("old_value") @db.JsonB
|
|
665
|
+
newValue Json? @map("new_value") @db.JsonB
|
|
666
|
+
actorId String @map("actor_id") @db.Uuid
|
|
667
|
+
reason String? @db.Text
|
|
668
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
617
669
|
|
|
618
670
|
@@index([tagId], map: "idx_tag_audit_tag")
|
|
619
671
|
@@index([nodeId], map: "idx_tag_audit_node")
|
|
@@ -642,25 +694,25 @@ model QuotaOverride {
|
|
|
642
694
|
// ── Document Archive ────────────────────────────────────────────────────────
|
|
643
695
|
|
|
644
696
|
model Document {
|
|
645
|
-
id
|
|
646
|
-
organizationId
|
|
647
|
-
fileName
|
|
648
|
-
mimeType
|
|
649
|
-
fileSizeBytes
|
|
650
|
-
storagePath
|
|
651
|
-
contentHash
|
|
652
|
-
status
|
|
653
|
-
ocrModel
|
|
654
|
-
ocrTokensIn
|
|
655
|
-
ocrTokensOut
|
|
656
|
-
pageCount
|
|
657
|
-
nodeId
|
|
658
|
-
errorMessage
|
|
659
|
-
createdBy
|
|
660
|
-
createdAt
|
|
661
|
-
updatedAt
|
|
697
|
+
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
|
698
|
+
organizationId String @map("organization_id") @db.Uuid
|
|
699
|
+
fileName String @map("file_name") @db.VarChar(500)
|
|
700
|
+
mimeType String @map("mime_type") @db.VarChar(100)
|
|
701
|
+
fileSizeBytes Int @map("file_size_bytes")
|
|
702
|
+
storagePath String @map("storage_path") @db.VarChar(1000)
|
|
703
|
+
contentHash String? @map("content_hash") @db.VarChar(64)
|
|
704
|
+
status String @default("uploading") @db.VarChar(20)
|
|
705
|
+
ocrModel String? @map("ocr_model") @db.VarChar(100)
|
|
706
|
+
ocrTokensIn Int? @map("ocr_tokens_in")
|
|
707
|
+
ocrTokensOut Int? @map("ocr_tokens_out")
|
|
708
|
+
pageCount Int? @map("page_count")
|
|
709
|
+
nodeId String? @map("node_id") @db.Uuid
|
|
710
|
+
errorMessage String? @map("error_message")
|
|
711
|
+
createdBy String @map("created_by") @db.VarChar(255)
|
|
712
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
713
|
+
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz
|
|
662
714
|
|
|
663
|
-
organization
|
|
715
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
664
716
|
|
|
665
717
|
@@index([organizationId, contentHash], map: "idx_documents_org_hash")
|
|
666
718
|
@@index([organizationId, status], map: "idx_documents_org_status")
|
|
@@ -728,3 +780,106 @@ model SearchMetric {
|
|
|
728
780
|
@@index([organizationId, createdAt], map: "idx_search_metrics_org_time")
|
|
729
781
|
@@map("search_metrics")
|
|
730
782
|
}
|
|
783
|
+
|
|
784
|
+
// ── Chat Gateway ────────────────────────────────────────────────────────────
|
|
785
|
+
|
|
786
|
+
model OrgLlmProvider {
|
|
787
|
+
id String @id @default(uuid()) @db.Uuid
|
|
788
|
+
organizationId String @map("organization_id") @db.Uuid
|
|
789
|
+
provider String @db.VarChar(30)
|
|
790
|
+
displayName String @map("display_name") @db.VarChar(200)
|
|
791
|
+
encryptedApiKey String @map("encrypted_api_key") @db.Text
|
|
792
|
+
baseUrl String? @map("base_url") @db.VarChar(500)
|
|
793
|
+
models String[]
|
|
794
|
+
defaultModel String? @map("default_model") @db.VarChar(100)
|
|
795
|
+
dataResidency String @default("any") @map("data_residency") @db.VarChar(10)
|
|
796
|
+
enabled Boolean @default(true)
|
|
797
|
+
priority Int @default(0)
|
|
798
|
+
maxTokensPerMin Int? @map("max_tokens_per_min")
|
|
799
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
800
|
+
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz
|
|
801
|
+
|
|
802
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
803
|
+
|
|
804
|
+
@@unique([organizationId, provider], map: "uq_org_llm_provider_org_provider")
|
|
805
|
+
@@index([organizationId], map: "idx_org_llm_providers_org")
|
|
806
|
+
@@map("org_llm_providers")
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
model ChatSession {
|
|
810
|
+
id String @id @default(uuid()) @db.Uuid
|
|
811
|
+
organizationId String @map("organization_id") @db.Uuid
|
|
812
|
+
userId String @map("user_id") @db.Uuid
|
|
813
|
+
title String? @db.VarChar(500)
|
|
814
|
+
privacy String @default("private") @db.VarChar(20)
|
|
815
|
+
status String @default("active") @db.VarChar(20)
|
|
816
|
+
workspaceId String? @map("workspace_id") @db.Uuid
|
|
817
|
+
graphCaptured Boolean @default(false) @map("graph_captured")
|
|
818
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
819
|
+
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz
|
|
820
|
+
|
|
821
|
+
messages ChatMessage[]
|
|
822
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
823
|
+
|
|
824
|
+
@@index([organizationId, userId, createdAt], map: "idx_chat_sessions_org_user_time")
|
|
825
|
+
@@index([organizationId, privacy, createdAt], map: "idx_chat_sessions_org_privacy_time")
|
|
826
|
+
@@map("chat_sessions")
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
model ChatMessage {
|
|
830
|
+
id String @id @default(uuid()) @db.Uuid
|
|
831
|
+
sessionId String @map("session_id") @db.Uuid
|
|
832
|
+
organizationId String @map("organization_id") @db.Uuid
|
|
833
|
+
role String @db.VarChar(20)
|
|
834
|
+
content String @db.Text
|
|
835
|
+
contentClean String? @map("content_clean") @db.Text
|
|
836
|
+
model String? @db.VarChar(100)
|
|
837
|
+
providerId String? @map("provider_id") @db.Uuid
|
|
838
|
+
tokensIn Int? @map("tokens_in")
|
|
839
|
+
tokensOut Int? @map("tokens_out")
|
|
840
|
+
costCents Int? @map("cost_cents")
|
|
841
|
+
durationMs Int? @map("duration_ms")
|
|
842
|
+
piiDetected Boolean @default(false) @map("pii_detected")
|
|
843
|
+
piiReport Json? @map("pii_report")
|
|
844
|
+
contextNodeIds String[] @default([]) @map("context_node_ids")
|
|
845
|
+
documentIds String[] @default([]) @map("document_ids")
|
|
846
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
847
|
+
|
|
848
|
+
session ChatSession @relation(fields: [sessionId], references: [id], onDelete: Cascade)
|
|
849
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
850
|
+
|
|
851
|
+
@@index([sessionId, createdAt], map: "idx_chat_messages_session_time")
|
|
852
|
+
@@index([organizationId, createdAt], map: "idx_chat_messages_org_time")
|
|
853
|
+
@@map("chat_messages")
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
model OrgChatGuideline {
|
|
857
|
+
id String @id @default(uuid()) @db.Uuid
|
|
858
|
+
organizationId String @map("organization_id") @db.Uuid
|
|
859
|
+
title String @db.VarChar(200)
|
|
860
|
+
content String @db.Text
|
|
861
|
+
priority Int @default(0)
|
|
862
|
+
enabled Boolean @default(true)
|
|
863
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
864
|
+
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz
|
|
865
|
+
|
|
866
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
867
|
+
|
|
868
|
+
@@index([organizationId], map: "idx_org_chat_guidelines_org")
|
|
869
|
+
@@map("org_chat_guidelines")
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
model OrgPriorityDocument {
|
|
873
|
+
id String @id @default(uuid()) @db.Uuid
|
|
874
|
+
organizationId String @map("organization_id") @db.Uuid
|
|
875
|
+
nodeId String @map("node_id") @db.Uuid
|
|
876
|
+
boostWeight Int @default(1) @map("boost_weight")
|
|
877
|
+
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
|
|
878
|
+
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz
|
|
879
|
+
|
|
880
|
+
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
|
881
|
+
|
|
882
|
+
@@unique([organizationId, nodeId], map: "uq_org_priority_doc_org_node")
|
|
883
|
+
@@index([organizationId], map: "idx_org_priority_documents_org")
|
|
884
|
+
@@map("org_priority_documents")
|
|
885
|
+
}
|