chattercatcher 0.2.5 → 0.2.7

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/index.d.ts CHANGED
@@ -101,6 +101,7 @@ interface MessageRecord {
101
101
  chatId: string;
102
102
  senderId: string;
103
103
  senderName: string;
104
+ personId?: string;
104
105
  messageType: string;
105
106
  text: string;
106
107
  rawPayloadJson: string;
@@ -126,6 +127,7 @@ interface IngestMessageInput {
126
127
  platformMessageId: string;
127
128
  senderId: string;
128
129
  senderName: string;
130
+ personId?: string;
129
131
  messageType: string;
130
132
  text: string;
131
133
  rawPayload?: unknown;
@@ -143,6 +145,7 @@ interface CreateImageSummaryMessageInput {
143
145
  interface MessageSearchScope {
144
146
  platform?: string;
145
147
  platformChatId?: string;
148
+ personId?: string;
146
149
  }
147
150
  interface MessageSearchResult {
148
151
  chunkId: string;
@@ -152,16 +155,21 @@ interface MessageSearchResult {
152
155
  score: number;
153
156
  messageType: string;
154
157
  chatName: string;
158
+ senderId: string;
155
159
  senderName: string;
160
+ personId?: string;
156
161
  sentAt: string;
157
162
  }
158
163
 
159
- type SourceType = "message" | "episode" | "file" | "image" | "audio" | "link" | "feishu_doc";
164
+ type SourceType = "message" | "episode" | "file" | "image" | "audio" | "link" | "feishu_doc" | "person_profile";
160
165
  interface EvidenceSource {
161
166
  type: SourceType;
162
167
  label: string;
163
168
  timestamp?: string;
164
169
  sender?: string;
170
+ senderId?: string;
171
+ personId?: string;
172
+ profileAvailable?: boolean;
165
173
  location?: string;
166
174
  }
167
175
  interface EvidenceBlock {
@@ -698,6 +706,152 @@ interface MultimodalModel {
698
706
  describeImage(input: DescribeImageInput): Promise<DescribeImageResult>;
699
707
  }
700
708
 
709
+ type PersonIdentitySource = "message" | "feishu_member" | "manual" | "inferred";
710
+ type ProfileEntryType = "fact" | "inferred";
711
+ type ProfileEntryStatus = "active" | "superseded" | "deleted";
712
+ type ProfileEntrySource = "dream" | "explicit_user_request" | "manual";
713
+ interface PersonRecord {
714
+ id: string;
715
+ primaryName: string;
716
+ notes?: string;
717
+ createdAt: string;
718
+ updatedAt: string;
719
+ }
720
+ interface ResolvePersonInput {
721
+ platform: string;
722
+ platformChatId: string;
723
+ senderId: string;
724
+ senderName: string;
725
+ source: PersonIdentitySource;
726
+ observedAt?: string;
727
+ }
728
+ interface ProfileEvidenceInput {
729
+ messageId: string;
730
+ quote: string;
731
+ reason: string;
732
+ }
733
+ interface UpsertProfileEntryInput {
734
+ personId: string;
735
+ category: string;
736
+ content: string;
737
+ entryType: ProfileEntryType;
738
+ confidence: number;
739
+ source: ProfileEntrySource;
740
+ evidence: ProfileEvidenceInput[];
741
+ observedAt?: string;
742
+ }
743
+ interface ProfileEvidenceRecord extends ProfileEvidenceInput {
744
+ entryId: string;
745
+ }
746
+ interface ProfileEntryRecord {
747
+ id: string;
748
+ personId: string;
749
+ category: string;
750
+ content: string;
751
+ entryType: ProfileEntryType;
752
+ confidence: number;
753
+ status: ProfileEntryStatus;
754
+ source: ProfileEntrySource;
755
+ createdAt: string;
756
+ updatedAt: string;
757
+ lastObservedAt: string;
758
+ evidence?: ProfileEvidenceRecord[];
759
+ }
760
+ interface PersonIdentityRecord {
761
+ platform: string;
762
+ platformChatId: string;
763
+ externalUserId: string;
764
+ displayName: string;
765
+ alias?: string;
766
+ source: PersonIdentitySource;
767
+ firstSeenAt: string;
768
+ lastSeenAt: string;
769
+ }
770
+ interface DreamStateRecord {
771
+ platform: string;
772
+ platformChatId: string;
773
+ lastMessageId?: string;
774
+ lastMessageSentAt?: string;
775
+ updatedAt?: string;
776
+ }
777
+ interface DreamMessageRecord {
778
+ messageId: string;
779
+ personId: string;
780
+ senderName: string;
781
+ sentAt: string;
782
+ text: string;
783
+ }
784
+ interface DreamRunRecord {
785
+ id: string;
786
+ platform: string;
787
+ platformChatId: string;
788
+ status: "succeeded" | "failed" | "skipped";
789
+ processedMessageCount: number;
790
+ generatedEntryCount: number;
791
+ error?: string;
792
+ startedAt: string;
793
+ finishedAt: string;
794
+ }
795
+ interface DreamChatRecord {
796
+ platform: string;
797
+ platformChatId: string;
798
+ }
799
+
800
+ declare class ProfileRepository {
801
+ private readonly database;
802
+ constructor(database: SqliteDatabase);
803
+ resolvePersonForSender(input: ResolvePersonInput): PersonRecord;
804
+ listPersons(): PersonRecord[];
805
+ getPersonProfile(personId: string, options?: {
806
+ includeEvidence?: boolean;
807
+ includeInferred?: boolean;
808
+ }): {
809
+ person: PersonRecord;
810
+ identities: PersonIdentityRecord[];
811
+ entries: ProfileEntryRecord[];
812
+ } | undefined;
813
+ upsertProfileEntry(input: UpsertProfileEntryInput): string;
814
+ backfillMessagePersons({ limit }: {
815
+ limit: number;
816
+ }): {
817
+ updatedMessages: number;
818
+ };
819
+ getDreamState(platform: string, platformChatId: string): DreamStateRecord | undefined;
820
+ updateDreamState(input: {
821
+ platform: string;
822
+ platformChatId: string;
823
+ lastMessageId?: string;
824
+ lastMessageSentAt?: string;
825
+ updatedAt: string;
826
+ }): void;
827
+ listMessagesForDream(input: {
828
+ platform: string;
829
+ platformChatId: string;
830
+ afterSentAt?: string;
831
+ limit: number;
832
+ }): DreamMessageRecord[];
833
+ listChatsWithPendingDreamMessages(): DreamChatRecord[];
834
+ recordDreamRun(input: Omit<DreamRunRecord, "id"> & {
835
+ id?: string;
836
+ }): string;
837
+ resolvePersonIdForSender(input: {
838
+ senderId: string;
839
+ platformChatId: string;
840
+ platform?: string;
841
+ }): string | undefined;
842
+ searchPersonMessages(personId: string, query: string, limit: number, options?: {
843
+ excludeMessageIds?: string[];
844
+ }): MessageSearchResult[];
845
+ getProfileEntry(entryId: string): ProfileEntryRecord | undefined;
846
+ replaceProfileEntry(input: {
847
+ supersedeEntryId: string;
848
+ input: UpsertProfileEntryInput;
849
+ }): string;
850
+ markProfileEntryDeleted(entryId: string): void;
851
+ personExists(personId: string): boolean;
852
+ private getEvidence;
853
+ }
854
+
701
855
  interface GatewayIngestResult {
702
856
  accepted: boolean;
703
857
  messageId?: string;
@@ -718,12 +872,17 @@ interface GatewayAttachmentIngestResult {
718
872
  interface GatewayIngestAndDownloadResult extends GatewayIngestResult {
719
873
  attachment?: GatewayAttachmentIngestResult;
720
874
  }
875
+ interface GatewayIngestorOptions {
876
+ profiles?: ProfileRepository;
877
+ }
721
878
  declare class GatewayIngestor {
722
879
  readonly database: SqliteDatabase;
880
+ private readonly options;
723
881
  private readonly messages;
724
882
  private readonly jobs;
725
883
  private readonly imageTasks;
726
- constructor(database: SqliteDatabase);
884
+ constructor(database: SqliteDatabase, options?: GatewayIngestorOptions);
885
+ private enrichWithPerson;
727
886
  ingestFeishuEvent(payload: FeishuReceiveMessageEvent): GatewayIngestResult;
728
887
  ingestFeishuEventWithMembers(input: {
729
888
  payload: FeishuReceiveMessageEvent;
@@ -1125,6 +1284,7 @@ declare function createAgenticRagSearchTools(input: {
1125
1284
  messages: MessageRepository;
1126
1285
  excludeMessageIds?: string[];
1127
1286
  scope?: MessageSearchScope;
1287
+ profileTools?: RagSearchTool[];
1128
1288
  }): Promise<{
1129
1289
  tools: RagSearchTool[];
1130
1290
  close: () => void;
@@ -1177,4 +1337,4 @@ interface WebAppOptions {
1177
1337
  declare function createWebApp(config: AppConfig, options?: WebAppOptions): FastifyInstance;
1178
1338
  declare function startWebServer(config: AppConfig, options?: WebAppOptions): Promise<void>;
1179
1339
 
1180
- export { type AppConfig, type AppSecrets, type AskWithRagInput, type BuildEvidencePromptInput, type BuildEvidencePromptOptions, type ChatMessage, type ChatModel, type ChatRecord, type ChatTool, type Citation, type CreateImageSummaryMessageInput, type CronJobRecord, CronJobRepository, type CronJobScheduler, type CronJobStatus, type CronJobTool, type DataExportResult, type DataRestoreResult, type DeleteLocalDataResult, type DeleteTargetType, type DoctorCheck, type DoctorOptions, type DoctorStatus, type EmbeddingModel, type EpisodeListItem, type EpisodeMessage, EpisodeRepository, type EpisodeSearchResult, type EpisodeSummaryRecord, type EpisodeWindow, type EvidenceBlock, type EvidencePrompt, type EvidenceSource, type FeishuAttachmentMetadata, type FeishuDownloadResourceInput, type FeishuDownloadedResource, type FeishuGatewayOptions, type FeishuGatewayRuntime, FeishuMessageSender, type FeishuQuestionDecision, FeishuQuestionHandler, type FeishuQuestionHandlerOptions, type FeishuReceiveMessageEvent, FeishuResourceDownloader, type FeishuTextMention, type FileJobRecord, FileJobRepository, type FileJobStatus, type FileRecord, type GatewayAttachmentIngestResult, type GatewayIngestAndDownloadResult, type GatewayIngestResult, GatewayIngestor, type GatewayPidRecord, type GatewayRuntimeState, type GroundedAnswer, HybridRetriever, type HybridRetrieverOptions, type IngestLocalFileResult, type IngestMessageInput, type LogFileInfo, type LogTailResult, type ManualMessageIndexResult, MemoryVectorStore, MessageFtsRetriever, type MessageRecord, MessageRepository, type MessageSearchResult, type MessageSearchScope, type MessageSender, OpenAICompatibleChatModel, type OpenAICompatibleChatOptions, OpenAICompatibleEmbeddingModel, type OpenAICompatibleEmbeddingOptions, type ParsedFile, type ProcessEpisodesResult, type SendTextOptions, type SourceType, type SqliteDatabase, type StopGatewayResult, type TextChunk, type ToolCall, type ToolChatResult, type VectorIndexStats, type VectorRecord, VectorRetriever, type VectorSearchResult, type VectorStore, type WebAppOptions, appConfigSchema, appSecretsSchema, applySecretInput, askWithRag, buildEvidencePrompt, chunkText, cosineSimilarity, createAgenticRagSearchTools, createChatModel, createCronJobScheduler, createCronJobTools, createDefaultConfig, createDefaultSecrets, createEmbeddingModel, createFeishuEventDispatcher, createFeishuGateway, createHybridRetriever, createWebApp, deleteLocalData, describeSupportedParseTypes, ensureConfigFiles, exportLocalData, extractFeishuAttachment, followLogFile, formatCitation, formatCitations, formatDoctorChecks, generateCronJobMessage, generateGroundedAnswer, getDatabasePath, getFeishuQuestionDecision, getGatewayLogPath, getGatewayPidPath, getGatewayRuntimeState, getLogsDirectory, getNextCronRun, hasEmbeddingConfig, indexMessageChunks, ingestLocalFile, isFeishuMessageAddressedToBot, isProcessRunning, isSupportedParseFile, isSupportedTextFile, isValidCronSchedule, listLogFiles, loadConfig, loadSecrets, mapDomain, maskSecret, matchesCronSchedule, migrateDatabase, normalizeFeishuReceiveMessageEvent, normalizeLineCount, openDatabase, parseFileToText, processEpisodesNow, processMessagesNow, rankEvidenceForPrompt, readGatewayPidRecord, readLatestLogTail, readLogTail, removeGatewayPidRecord, resetConfigFiles, resolveEmbeddingApiKey, resolveLogPath, restoreLocalData, runDoctor, sanitizeEpisodeSummary, saveConfig, saveSecrets, startWebServer, stopGatewayProcess, summarizeEpisodeWindow, writeGatewayPidRecord };
1340
+ export { type AppConfig, type AppSecrets, type AskWithRagInput, type BuildEvidencePromptInput, type BuildEvidencePromptOptions, type ChatMessage, type ChatModel, type ChatRecord, type ChatTool, type Citation, type CreateImageSummaryMessageInput, type CronJobRecord, CronJobRepository, type CronJobScheduler, type CronJobStatus, type CronJobTool, type DataExportResult, type DataRestoreResult, type DeleteLocalDataResult, type DeleteTargetType, type DoctorCheck, type DoctorOptions, type DoctorStatus, type EmbeddingModel, type EpisodeListItem, type EpisodeMessage, EpisodeRepository, type EpisodeSearchResult, type EpisodeSummaryRecord, type EpisodeWindow, type EvidenceBlock, type EvidencePrompt, type EvidenceSource, type FeishuAttachmentMetadata, type FeishuDownloadResourceInput, type FeishuDownloadedResource, type FeishuGatewayOptions, type FeishuGatewayRuntime, FeishuMessageSender, type FeishuQuestionDecision, FeishuQuestionHandler, type FeishuQuestionHandlerOptions, type FeishuReceiveMessageEvent, FeishuResourceDownloader, type FeishuTextMention, type FileJobRecord, FileJobRepository, type FileJobStatus, type FileRecord, type GatewayAttachmentIngestResult, type GatewayIngestAndDownloadResult, type GatewayIngestResult, GatewayIngestor, type GatewayIngestorOptions, type GatewayPidRecord, type GatewayRuntimeState, type GroundedAnswer, HybridRetriever, type HybridRetrieverOptions, type IngestLocalFileResult, type IngestMessageInput, type LogFileInfo, type LogTailResult, type ManualMessageIndexResult, MemoryVectorStore, MessageFtsRetriever, type MessageRecord, MessageRepository, type MessageSearchResult, type MessageSearchScope, type MessageSender, OpenAICompatibleChatModel, type OpenAICompatibleChatOptions, OpenAICompatibleEmbeddingModel, type OpenAICompatibleEmbeddingOptions, type ParsedFile, type ProcessEpisodesResult, type SendTextOptions, type SourceType, type SqliteDatabase, type StopGatewayResult, type TextChunk, type ToolCall, type ToolChatResult, type VectorIndexStats, type VectorRecord, VectorRetriever, type VectorSearchResult, type VectorStore, type WebAppOptions, appConfigSchema, appSecretsSchema, applySecretInput, askWithRag, buildEvidencePrompt, chunkText, cosineSimilarity, createAgenticRagSearchTools, createChatModel, createCronJobScheduler, createCronJobTools, createDefaultConfig, createDefaultSecrets, createEmbeddingModel, createFeishuEventDispatcher, createFeishuGateway, createHybridRetriever, createWebApp, deleteLocalData, describeSupportedParseTypes, ensureConfigFiles, exportLocalData, extractFeishuAttachment, followLogFile, formatCitation, formatCitations, formatDoctorChecks, generateCronJobMessage, generateGroundedAnswer, getDatabasePath, getFeishuQuestionDecision, getGatewayLogPath, getGatewayPidPath, getGatewayRuntimeState, getLogsDirectory, getNextCronRun, hasEmbeddingConfig, indexMessageChunks, ingestLocalFile, isFeishuMessageAddressedToBot, isProcessRunning, isSupportedParseFile, isSupportedTextFile, isValidCronSchedule, listLogFiles, loadConfig, loadSecrets, mapDomain, maskSecret, matchesCronSchedule, migrateDatabase, normalizeFeishuReceiveMessageEvent, normalizeLineCount, openDatabase, parseFileToText, processEpisodesNow, processMessagesNow, rankEvidenceForPrompt, readGatewayPidRecord, readLatestLogTail, readLogTail, removeGatewayPidRecord, resetConfigFiles, resolveEmbeddingApiKey, resolveLogPath, restoreLocalData, runDoctor, sanitizeEpisodeSummary, saveConfig, saveSecrets, startWebServer, stopGatewayProcess, summarizeEpisodeWindow, writeGatewayPidRecord };