claude-mem 13.9.0 → 13.9.2

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.
@@ -259,6 +259,7 @@ declare class PostgresObservationRepository {
259
259
  teamId: string;
260
260
  query: string;
261
261
  limit?: number;
262
+ platformSource?: string | null;
262
263
  }): Promise<PostgresObservation[]>;
263
264
  }
264
265
  declare class PostgresObservationSourcesRepository {
@@ -345,11 +346,13 @@ declare class PostgresServerSessionsRepository {
345
346
  externalSessionId: string;
346
347
  projectId: string;
347
348
  teamId: string;
349
+ platformSource?: string | null;
348
350
  }): Promise<PostgresServerSession | null>;
349
351
  findIdByContentSessionId(input: {
350
352
  contentSessionId: string;
351
353
  projectId: string;
352
354
  teamId: string;
355
+ platformSource?: string | null;
353
356
  }): Promise<string | null>;
354
357
  /**
355
358
  * End a server session by setting `ended_at = now()` if not already set.
@@ -426,6 +429,52 @@ declare class PostgresTeamsRepository {
426
429
  }): Promise<PostgresTeam | null>;
427
430
  }
428
431
 
432
+ type UsageKind = 'request' | 'observation' | 'tokens_in' | 'tokens_out' | (string & {});
433
+ declare class PostgresUsageRepository {
434
+ private readonly client;
435
+ constructor(client: PostgresQueryable);
436
+ record(input: {
437
+ teamId: string;
438
+ projectId?: string | null;
439
+ kind: UsageKind;
440
+ quantity?: number;
441
+ metadata?: JsonObject;
442
+ }): Promise<void>;
443
+ /** Total quantity of one `kind` for a team since `since` — the quota read. */
444
+ total(input: {
445
+ teamId: string;
446
+ kind: UsageKind;
447
+ since: Date;
448
+ }): Promise<number>;
449
+ /** Per-kind totals for a team since `since` — the /v1/usage read. */
450
+ summarize(input: {
451
+ teamId: string;
452
+ since: Date;
453
+ }): Promise<Record<string, number>>;
454
+ }
455
+
456
+ interface RateLimitResult {
457
+ allowed: boolean;
458
+ count: number;
459
+ limit: number;
460
+ windowStart: Date;
461
+ }
462
+ declare class PostgresRateLimitRepository {
463
+ private readonly client;
464
+ constructor(client: PostgresQueryable);
465
+ /**
466
+ * Atomically increment the current window's counter for `subjectId` and
467
+ * report whether it is still within `limit`.
468
+ */
469
+ hit(input: {
470
+ subjectId: string;
471
+ windowStart: Date;
472
+ limit: number;
473
+ }): Promise<RateLimitResult>;
474
+ /** Best-effort cleanup of expired windows. Call off the hot path. */
475
+ prune(before: Date): Promise<void>;
476
+ }
477
+
429
478
  interface PostgresStorageRepositories {
430
479
  teams: PostgresTeamsRepository;
431
480
  projects: PostgresProjectsRepository;
@@ -436,6 +485,8 @@ interface PostgresStorageRepositories {
436
485
  observationSources: PostgresObservationSourcesRepository;
437
486
  observationGenerationJobs: PostgresObservationGenerationJobRepository;
438
487
  observationGenerationJobEvents: PostgresObservationGenerationJobEventsRepository;
488
+ usage: PostgresUsageRepository;
489
+ rateLimits: PostgresRateLimitRepository;
439
490
  }
440
491
 
441
492
  interface ParsedObservation {
@@ -474,6 +525,7 @@ interface ObservationRecord {
474
525
  }
475
526
  interface UserPromptRecord {
476
527
  id: number;
528
+ session_db_id?: number | null;
477
529
  content_session_id: string;
478
530
  prompt_number: number;
479
531
  prompt_text: string;
@@ -484,6 +536,7 @@ interface UserPromptRecord {
484
536
  }
485
537
  interface LatestPromptResult {
486
538
  id: number;
539
+ session_db_id?: number | null;
487
540
  content_session_id: string;
488
541
  memory_session_id: string;
489
542
  project: string;
@@ -540,7 +593,13 @@ interface SessionSummarySearchResult extends SessionSummaryRow {
540
593
  declare class SessionStore$1 {
541
594
  db: Database;
542
595
  constructor(dbPathOrDb?: string | Database);
596
+ private getIndexColumns;
597
+ private hasUniqueIndexOnColumns;
598
+ private resolvePromptSessionDbId;
543
599
  private dropWorkerPidColumn;
600
+ private ensureSDKSessionsPlatformContentIdentity;
601
+ private ensureUserPromptsSessionDbId;
602
+ private ensurePendingMessagesSessionToolUniqueIndex;
544
603
  private dropDeadPendingMessagesColumns;
545
604
  private initializeSchema;
546
605
  private ensureWorkerPortColumn;
@@ -640,7 +699,7 @@ declare class SessionStore$1 {
640
699
  sources: string[];
641
700
  projectsBySource: Record<string, string[]>;
642
701
  };
643
- getLatestUserPrompt(contentSessionId: string): {
702
+ getLatestUserPrompt(contentSessionId: string, sessionDbId?: number): {
644
703
  id: number;
645
704
  content_session_id: string;
646
705
  memory_session_id: string;
@@ -650,30 +709,31 @@ declare class SessionStore$1 {
650
709
  prompt_text: string;
651
710
  created_at_epoch: number;
652
711
  } | undefined;
653
- findRecentDuplicateUserPrompt(contentSessionId: string, promptText: string, windowMs: number): LatestPromptResult | undefined;
654
- getRecentSessionsWithStatus(project: string, limit?: number): Array<{
712
+ findRecentDuplicateUserPrompt(contentSessionId: string, promptText: string, windowMs: number, sessionDbId?: number): LatestPromptResult | undefined;
713
+ getRecentSessionsWithStatus(project: string, limit?: number, platformSource?: string): Array<{
655
714
  memory_session_id: string | null;
656
715
  status: string;
657
716
  started_at: string;
658
717
  user_prompt: string | null;
659
718
  has_summary: boolean;
660
719
  }>;
661
- getObservationsForSession(memorySessionId: string): Array<{
720
+ getObservationsForSession(memorySessionId: string, platformSource?: string): Array<{
662
721
  title: string;
663
722
  subtitle: string;
664
723
  type: string;
665
724
  prompt_number: number | null;
666
725
  }>;
667
- getObservationById(id: number): ObservationRecord | null;
726
+ getObservationById(id: number, platformSource?: string): ObservationRecord | null;
668
727
  getObservationsByIds(ids: number[], options?: {
669
728
  orderBy?: 'date_desc' | 'date_asc' | 'relevance';
670
729
  limit?: number;
671
730
  project?: string;
731
+ platformSource?: string;
672
732
  type?: string | string[];
673
733
  concepts?: string | string[];
674
734
  files?: string | string[];
675
735
  }): ObservationSearchResult[];
676
- getSummaryForSession(memorySessionId: string): {
736
+ getSummaryForSession(memorySessionId: string, platformSource?: string): {
677
737
  request: string | null;
678
738
  investigated: string | null;
679
739
  learned: string | null;
@@ -714,10 +774,10 @@ declare class SessionStore$1 {
714
774
  completed_at_epoch: number | null;
715
775
  status: string;
716
776
  }[];
717
- getPromptNumberFromUserPrompts(contentSessionId: string): number;
777
+ getPromptNumberFromUserPrompts(contentSessionId: string, sessionDbId?: number): number;
718
778
  createSDKSession(contentSessionId: string, project: string, userPrompt: string, customTitle?: string, platformSource?: string): number;
719
- saveUserPrompt(contentSessionId: string, promptNumber: number, promptText: string): number;
720
- getUserPrompt(contentSessionId: string, promptNumber: number): string | null;
779
+ saveUserPrompt(contentSessionId: string, promptNumber: number, promptText: string, sessionDbId?: number): number;
780
+ getUserPrompt(contentSessionId: string, promptNumber: number, sessionDbId?: number): string | null;
721
781
  storeObservation(memorySessionId: string, project: string, observation: {
722
782
  type: string;
723
783
  title: string | null;
@@ -772,18 +832,20 @@ declare class SessionStore$1 {
772
832
  orderBy?: 'date_desc' | 'date_asc' | 'relevance';
773
833
  limit?: number;
774
834
  project?: string;
835
+ platformSource?: string;
775
836
  }): SessionSummarySearchResult[];
776
837
  getUserPromptsByIds(ids: number[], options?: {
777
838
  orderBy?: 'date_desc' | 'date_asc' | 'relevance';
778
839
  limit?: number;
779
840
  project?: string;
841
+ platformSource?: string;
780
842
  }): UserPromptRecord[];
781
- getTimelineAroundTimestamp(anchorEpoch: number, depthBefore?: number, depthAfter?: number, project?: string): {
843
+ getTimelineAroundTimestamp(anchorEpoch: number, depthBefore?: number, depthAfter?: number, project?: string, platformSource?: string): {
782
844
  observations: any[];
783
845
  sessions: any[];
784
846
  prompts: any[];
785
847
  };
786
- getTimelineAroundObservation(anchorObservationId: number | null, anchorEpoch: number, depthBefore?: number, depthAfter?: number, project?: string): {
848
+ getTimelineAroundObservation(anchorObservationId: number | null, anchorEpoch: number, depthBefore?: number, depthAfter?: number, project?: string, platformSource?: string): {
787
849
  observations: any[];
788
850
  sessions: any[];
789
851
  prompts: any[];
@@ -866,7 +928,9 @@ declare class SessionStore$1 {
866
928
  };
867
929
  rebuildObservationsFTSIndex(): void;
868
930
  importUserPrompt(prompt: {
931
+ session_db_id?: number | null;
869
932
  content_session_id: string;
933
+ platform_source?: string | null;
870
934
  prompt_number: number;
871
935
  prompt_text: string;
872
936
  created_at: string;
@@ -910,10 +974,10 @@ declare class ChromaSync {
910
974
  * Postgres UUID path. See plan §6 line 244-247.
911
975
  */
912
976
  addDocuments(documents: ChromaDocument[]): Promise<number>;
913
- syncObservation(observationId: number, memorySessionId: string, project: string, obs: ParsedObservation, promptNumber: number, createdAtEpoch: number): Promise<void>;
914
- syncSummary(summaryId: number, memorySessionId: string, project: string, summary: ParsedSummary, promptNumber: number, createdAtEpoch: number): Promise<void>;
977
+ syncObservation(observationId: number, memorySessionId: string, project: string, obs: ParsedObservation, promptNumber: number, createdAtEpoch: number, platformSource?: string): Promise<void>;
978
+ syncSummary(summaryId: number, memorySessionId: string, project: string, summary: ParsedSummary, promptNumber: number, createdAtEpoch: number, platformSource?: string): Promise<void>;
915
979
  private formatUserPromptDoc;
916
- syncUserPrompt(promptId: number, memorySessionId: string, project: string, promptText: string, promptNumber: number, createdAtEpoch: number): Promise<void>;
980
+ syncUserPrompt(promptId: number, memorySessionId: string, project: string, promptText: string, promptNumber: number, createdAtEpoch: number, platformSource?: string): Promise<void>;
917
981
  private getExistingChromaIds;
918
982
  bootstrapWatermarksFromChroma(project: string): Promise<void>;
919
983
  ensureBackfilled(projectOverride?: string, storeOverride?: SessionStore): Promise<void>;