remdb 0.3.114__py3-none-any.whl → 0.3.172__py3-none-any.whl

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.

Potentially problematic release.


This version of remdb might be problematic. Click here for more details.

Files changed (83) hide show
  1. rem/agentic/agents/__init__.py +16 -0
  2. rem/agentic/agents/agent_manager.py +311 -0
  3. rem/agentic/agents/sse_simulator.py +2 -0
  4. rem/agentic/context.py +103 -5
  5. rem/agentic/context_builder.py +36 -9
  6. rem/agentic/mcp/tool_wrapper.py +161 -18
  7. rem/agentic/otel/setup.py +1 -0
  8. rem/agentic/providers/phoenix.py +371 -108
  9. rem/agentic/providers/pydantic_ai.py +172 -30
  10. rem/agentic/schema.py +8 -4
  11. rem/api/deps.py +3 -5
  12. rem/api/main.py +26 -4
  13. rem/api/mcp_router/resources.py +15 -10
  14. rem/api/mcp_router/server.py +11 -3
  15. rem/api/mcp_router/tools.py +418 -4
  16. rem/api/middleware/tracking.py +5 -5
  17. rem/api/routers/admin.py +218 -1
  18. rem/api/routers/auth.py +349 -6
  19. rem/api/routers/chat/completions.py +255 -7
  20. rem/api/routers/chat/models.py +81 -7
  21. rem/api/routers/chat/otel_utils.py +33 -0
  22. rem/api/routers/chat/sse_events.py +17 -1
  23. rem/api/routers/chat/streaming.py +126 -19
  24. rem/api/routers/feedback.py +134 -14
  25. rem/api/routers/messages.py +24 -15
  26. rem/api/routers/query.py +6 -3
  27. rem/auth/__init__.py +13 -3
  28. rem/auth/jwt.py +352 -0
  29. rem/auth/middleware.py +115 -10
  30. rem/auth/providers/__init__.py +4 -1
  31. rem/auth/providers/email.py +215 -0
  32. rem/cli/commands/README.md +42 -0
  33. rem/cli/commands/cluster.py +617 -168
  34. rem/cli/commands/configure.py +4 -7
  35. rem/cli/commands/db.py +66 -22
  36. rem/cli/commands/experiments.py +468 -76
  37. rem/cli/commands/schema.py +6 -5
  38. rem/cli/commands/session.py +336 -0
  39. rem/cli/dreaming.py +2 -2
  40. rem/cli/main.py +2 -0
  41. rem/config.py +8 -1
  42. rem/models/core/experiment.py +58 -14
  43. rem/models/entities/__init__.py +4 -0
  44. rem/models/entities/ontology.py +1 -1
  45. rem/models/entities/ontology_config.py +1 -1
  46. rem/models/entities/subscriber.py +175 -0
  47. rem/models/entities/user.py +1 -0
  48. rem/schemas/agents/core/agent-builder.yaml +235 -0
  49. rem/schemas/agents/examples/contract-analyzer.yaml +1 -1
  50. rem/schemas/agents/examples/contract-extractor.yaml +1 -1
  51. rem/schemas/agents/examples/cv-parser.yaml +1 -1
  52. rem/services/__init__.py +3 -1
  53. rem/services/content/service.py +4 -3
  54. rem/services/email/__init__.py +10 -0
  55. rem/services/email/service.py +513 -0
  56. rem/services/email/templates.py +360 -0
  57. rem/services/phoenix/client.py +59 -18
  58. rem/services/postgres/README.md +38 -0
  59. rem/services/postgres/diff_service.py +127 -6
  60. rem/services/postgres/pydantic_to_sqlalchemy.py +45 -13
  61. rem/services/postgres/repository.py +5 -4
  62. rem/services/postgres/schema_generator.py +205 -4
  63. rem/services/session/compression.py +120 -50
  64. rem/services/session/reload.py +14 -7
  65. rem/services/user_service.py +41 -9
  66. rem/settings.py +442 -23
  67. rem/sql/migrations/001_install.sql +156 -0
  68. rem/sql/migrations/002_install_models.sql +1951 -88
  69. rem/sql/migrations/004_cache_system.sql +548 -0
  70. rem/sql/migrations/005_schema_update.sql +145 -0
  71. rem/utils/README.md +45 -0
  72. rem/utils/__init__.py +18 -0
  73. rem/utils/files.py +157 -1
  74. rem/utils/schema_loader.py +139 -10
  75. rem/utils/sql_paths.py +146 -0
  76. rem/utils/vision.py +1 -1
  77. rem/workers/__init__.py +3 -1
  78. rem/workers/db_listener.py +579 -0
  79. rem/workers/unlogged_maintainer.py +463 -0
  80. {remdb-0.3.114.dist-info → remdb-0.3.172.dist-info}/METADATA +218 -180
  81. {remdb-0.3.114.dist-info → remdb-0.3.172.dist-info}/RECORD +83 -68
  82. {remdb-0.3.114.dist-info → remdb-0.3.172.dist-info}/WHEEL +0 -0
  83. {remdb-0.3.114.dist-info → remdb-0.3.172.dist-info}/entry_points.txt +0 -0
@@ -604,6 +604,162 @@ CREATE INDEX IF NOT EXISTS idx_rate_limits_expires ON rate_limits (expires_at);
604
604
  COMMENT ON TABLE rate_limits IS
605
605
  'UNLOGGED rate limiting table. Counts may be lost on crash (acceptable for rate limiting).';
606
606
 
607
+ -- ============================================================================
608
+ -- SHARED SESSIONS HELPER FUNCTIONS
609
+ -- ============================================================================
610
+ -- Note: The shared_sessions TABLE is created by 002_install_models.sql (auto-generated)
611
+ -- These functions provide aggregate queries for the session sharing workflow.
612
+
613
+ -- Count distinct users sharing sessions with the current user
614
+ CREATE OR REPLACE FUNCTION fn_count_shared_with_me(
615
+ p_tenant_id VARCHAR(100),
616
+ p_user_id VARCHAR(256)
617
+ )
618
+ RETURNS BIGINT AS $$
619
+ BEGIN
620
+ RETURN (
621
+ SELECT COUNT(DISTINCT owner_user_id)
622
+ FROM shared_sessions
623
+ WHERE tenant_id = p_tenant_id
624
+ AND shared_with_user_id = p_user_id
625
+ AND deleted_at IS NULL
626
+ );
627
+ END;
628
+ $$ LANGUAGE plpgsql STABLE;
629
+
630
+ COMMENT ON FUNCTION fn_count_shared_with_me IS
631
+ 'Count distinct users sharing sessions with the specified user.';
632
+
633
+ -- Get aggregated summary of users sharing sessions with current user
634
+ CREATE OR REPLACE FUNCTION fn_get_shared_with_me(
635
+ p_tenant_id VARCHAR(100),
636
+ p_user_id VARCHAR(256),
637
+ p_limit INTEGER DEFAULT 50,
638
+ p_offset INTEGER DEFAULT 0
639
+ )
640
+ RETURNS TABLE(
641
+ user_id VARCHAR(256),
642
+ name VARCHAR(256),
643
+ email VARCHAR(256),
644
+ session_count BIGINT,
645
+ message_count BIGINT,
646
+ first_message_at TIMESTAMP,
647
+ last_message_at TIMESTAMP
648
+ ) AS $$
649
+ BEGIN
650
+ RETURN QUERY
651
+ SELECT
652
+ ss.owner_user_id AS user_id,
653
+ COALESCE(u.name, ss.owner_user_id) AS name,
654
+ u.email AS email,
655
+ COUNT(DISTINCT ss.session_id)::BIGINT AS session_count,
656
+ COALESCE(SUM(msg_counts.msg_count), 0)::BIGINT AS message_count,
657
+ MIN(msg_counts.first_msg)::TIMESTAMP AS first_message_at,
658
+ MAX(msg_counts.last_msg)::TIMESTAMP AS last_message_at
659
+ FROM shared_sessions ss
660
+ LEFT JOIN users u ON u.id::text = ss.owner_user_id AND u.tenant_id = ss.tenant_id
661
+ LEFT JOIN (
662
+ SELECT
663
+ m.session_id,
664
+ m.user_id,
665
+ COUNT(*)::BIGINT AS msg_count,
666
+ MIN(m.created_at) AS first_msg,
667
+ MAX(m.created_at) AS last_msg
668
+ FROM messages m
669
+ WHERE m.tenant_id = p_tenant_id
670
+ AND m.deleted_at IS NULL
671
+ GROUP BY m.session_id, m.user_id
672
+ ) msg_counts ON msg_counts.session_id = ss.session_id AND msg_counts.user_id = ss.owner_user_id
673
+ WHERE ss.tenant_id = p_tenant_id
674
+ AND ss.shared_with_user_id = p_user_id
675
+ AND ss.deleted_at IS NULL
676
+ GROUP BY ss.owner_user_id, u.name, u.email
677
+ ORDER BY MAX(msg_counts.last_msg) DESC NULLS LAST
678
+ LIMIT p_limit
679
+ OFFSET p_offset;
680
+ END;
681
+ $$ LANGUAGE plpgsql STABLE;
682
+
683
+ COMMENT ON FUNCTION fn_get_shared_with_me IS
684
+ 'Get aggregated summary of users sharing sessions with the specified user.';
685
+
686
+ -- Count messages in sessions shared by a specific user
687
+ CREATE OR REPLACE FUNCTION fn_count_shared_messages(
688
+ p_tenant_id VARCHAR(100),
689
+ p_recipient_user_id VARCHAR(256),
690
+ p_owner_user_id VARCHAR(256)
691
+ )
692
+ RETURNS BIGINT AS $$
693
+ BEGIN
694
+ RETURN (
695
+ SELECT COUNT(*)
696
+ FROM messages m
697
+ WHERE m.tenant_id = p_tenant_id
698
+ AND m.deleted_at IS NULL
699
+ AND m.session_id IN (
700
+ SELECT ss.session_id
701
+ FROM shared_sessions ss
702
+ WHERE ss.tenant_id = p_tenant_id
703
+ AND ss.owner_user_id = p_owner_user_id
704
+ AND ss.shared_with_user_id = p_recipient_user_id
705
+ AND ss.deleted_at IS NULL
706
+ )
707
+ );
708
+ END;
709
+ $$ LANGUAGE plpgsql STABLE;
710
+
711
+ COMMENT ON FUNCTION fn_count_shared_messages IS
712
+ 'Count messages in sessions shared by a specific user with the recipient.';
713
+
714
+ -- Get messages from sessions shared by a specific user
715
+ CREATE OR REPLACE FUNCTION fn_get_shared_messages(
716
+ p_tenant_id VARCHAR(100),
717
+ p_recipient_user_id VARCHAR(256),
718
+ p_owner_user_id VARCHAR(256),
719
+ p_limit INTEGER DEFAULT 50,
720
+ p_offset INTEGER DEFAULT 0
721
+ )
722
+ RETURNS TABLE(
723
+ id UUID,
724
+ content TEXT,
725
+ message_type VARCHAR(256),
726
+ session_id VARCHAR(256),
727
+ model VARCHAR(256),
728
+ token_count INTEGER,
729
+ created_at TIMESTAMP,
730
+ metadata JSONB
731
+ ) AS $$
732
+ BEGIN
733
+ RETURN QUERY
734
+ SELECT
735
+ m.id,
736
+ m.content,
737
+ m.message_type,
738
+ m.session_id,
739
+ m.model,
740
+ m.token_count,
741
+ m.created_at,
742
+ m.metadata
743
+ FROM messages m
744
+ WHERE m.tenant_id = p_tenant_id
745
+ AND m.deleted_at IS NULL
746
+ AND m.session_id IN (
747
+ SELECT ss.session_id
748
+ FROM shared_sessions ss
749
+ WHERE ss.tenant_id = p_tenant_id
750
+ AND ss.owner_user_id = p_owner_user_id
751
+ AND ss.shared_with_user_id = p_recipient_user_id
752
+ AND ss.deleted_at IS NULL
753
+ )
754
+ ORDER BY m.created_at DESC
755
+ LIMIT p_limit
756
+ OFFSET p_offset;
757
+ END;
758
+ $$ LANGUAGE plpgsql STABLE;
759
+
760
+ COMMENT ON FUNCTION fn_get_shared_messages IS
761
+ 'Get messages from sessions shared by a specific user with the recipient.';
762
+
607
763
  -- ============================================================================
608
764
  -- RECORD INSTALLATION
609
765
  -- ============================================================================