@damn-dev/cli 0.15.1 → 0.19.4

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.
@@ -13,6 +13,7 @@ model User {
13
13
  email String @unique
14
14
  emailVerified Boolean @default(false)
15
15
  image String?
16
+ phone String?
16
17
  defaultWorkspaceId String?
17
18
  createdAt DateTime @default(now())
18
19
  updatedAt DateTime @updatedAt
@@ -162,6 +163,7 @@ model Channel {
162
163
  messages Message[]
163
164
  readReceipts ReadReceipt[]
164
165
  participants ChannelParticipant[]
166
+ attachments Attachment[]
165
167
 
166
168
  @@index([watchingAgentId])
167
169
  @@index([parentChannelId])
@@ -250,11 +252,15 @@ model Attachment {
250
252
  id String @id @default(cuid())
251
253
  messageId String?
252
254
  message Message? @relation(fields: [messageId], references: [id], onDelete: Cascade)
255
+ channelId String?
256
+ channel Channel? @relation(fields: [channelId], references: [id], onDelete: Cascade)
253
257
  filename String
254
258
  mimeType String
255
259
  path String
256
260
  size Int
257
261
  createdAt DateTime @default(now())
262
+
263
+ @@index([channelId])
258
264
  }
259
265
 
260
266
  model Skill {
@@ -510,6 +516,37 @@ model TelegramPairing {
510
516
  @@index([workspaceId])
511
517
  }
512
518
 
519
+ model WhatsAppPairing {
520
+ id String @id @default(cuid())
521
+ workspaceId String
522
+ userId String
523
+ waUserId String
524
+ waPushName String?
525
+ channelId String
526
+ externalChannelId String
527
+ pairedAt DateTime @default(now())
528
+
529
+ // Contact identity layer (read-only card; NOT a CRM — chut.co owns CRM depth).
530
+ // phoneNumber is best-effort: present when WhatsApp surfaces the PN alongside a
531
+ // LID address (msg.key.remoteJidAlt/participantAlt), null for strict-privacy.
532
+ // knownUserId links the contact to a workspace member (auto via User.phone match,
533
+ // or manual); null ⇒ prospect. isProspect is derived in the router, not stored.
534
+ phoneNumber String?
535
+ firstSeenAt DateTime @default(now())
536
+ lastSeenAt DateTime @default(now())
537
+ messageCount Int @default(0)
538
+ knownUserId String?
539
+
540
+ // One pairing per WhatsApp identity (waUserId) is the real invariant. We do NOT
541
+ // constrain (externalChannelId, userId) unique: in "open" inbox mode every
542
+ // external WhatsApp sender is pinned to the workspace owner's userId but lives in
543
+ // its own per-sender thread, so a single damn.dev user legitimately holds many
544
+ // WhatsApp pairings on the same channel. The old userId-unique blocked the 2nd
545
+ // sender with a P2002 (the "my other number got no reply" bug).
546
+ @@unique([externalChannelId, waUserId])
547
+ @@index([workspaceId])
548
+ }
549
+
513
550
  model AgentTask {
514
551
  id String @id @default(cuid())
515
552
  parentTaskId String?
@@ -734,3 +771,62 @@ model RemoteAgent {
734
771
  @@unique([nodeId, remoteAgentId])
735
772
  @@index([nodeId])
736
773
  }
774
+
775
+ model SupportAccessGrant {
776
+ id String @id @default(cuid())
777
+ workspaceId String
778
+ grantedByUserId String
779
+ ttlMinutes Int
780
+ reason String?
781
+ status String @default("active") // active | expired | revoked
782
+ createdAt DateTime @default(now())
783
+ expiresAt DateTime
784
+ revokedAt DateTime?
785
+ revokedByUserId String?
786
+
787
+ @@index([workspaceId, createdAt])
788
+ }
789
+
790
+ // Tamper-evident audit log — the operator/CISO "Trace" surface. Append-only by
791
+ // discipline + hash-chained per workspace (each row's `hash` covers its content
792
+ // + the previous row's hash), so any tampering with a past row breaks the chain
793
+ // and is detectable. Distinct from AgentEvent (mutable telemetry): this is
794
+ // governance-grade, immutable, exportable. Int autoincrement id = monotonic
795
+ // ordering for the chain. See lib/audit.ts.
796
+ model AuditEvent {
797
+ id Int @id @default(autoincrement())
798
+ workspaceId String
799
+ actorType String // 'user' | 'agent' | 'system'
800
+ actorId String
801
+ actorName String?
802
+ action String // 'shell_exec' | 'config_change' | 'approval_decision' | 'policy_change' | 'agent_invoke' | ...
803
+ category String // 'activity' | 'config' | 'approval' | 'policy' | 'security'
804
+ targetType String?
805
+ targetId String?
806
+ summary String // plain-language one-line for the timeline
807
+ detail String? // JSON: raw payload / scopes / model / cost / decision
808
+ inputHash String?
809
+ outputHash String?
810
+ decision String? // 'allowed' | 'denied' | 'escalated' | 'approved' | 'rejected'
811
+ prevHash String?
812
+ hash String
813
+ createdAt DateTime @default(now())
814
+
815
+ @@index([workspaceId, id])
816
+ @@index([workspaceId, category, id])
817
+ @@index([workspaceId, actorId, id])
818
+ }
819
+
820
+ // The CISO-configurable governance policy — one per workspace, all dimensions in
821
+ // policyJson (validated by the Zod schema in lib/governancePolicy.ts). Seeded
822
+ // from a template at setup; editable by operators anytime. Absent row = the
823
+ // secure Regulated baseline default. See lib/governancePolicy.ts.
824
+ model GovernancePolicy {
825
+ id String @id @default(cuid())
826
+ workspaceId String @unique
827
+ template String @default("regulated")
828
+ policyJson String
829
+ updatedBy String?
830
+ createdAt DateTime @default(now())
831
+ updatedAt DateTime @updatedAt
832
+ }